Samhane
03-17-2003, 05:58 AM
I am working on a launcher program. I am using the acitvex list control. When the user runs the laucher it will pull up their list of specified programs and then log the users on. The problem that I am having is I have to wait until the program finishes loading before sending the keystrokes. I have tried a timer but it does not work.. Does anyone have any suggestions??? Please HELP!
Ales Zigon
03-17-2003, 07:08 AM
You should probably check, if the target window is enabled (that would mean it is capable of receiving messages) with IsWindowEnabled API call.
Samhane
03-17-2003, 09:10 AM
etmswindow = IsWindowEnabled(enterprise.hwnd)
is the *.hwnd the actual process or the name of the application in the window??? I have tried to use it but maybe I am doing something wrong...
On Error GoTo ErrHandler
Dim itm As ListItem
Dim ctr As Integer
ctr = 0
For Each itm In lvwApp.ListItems
'If itm.Checked Then
txtStatus = txtStatus & "Launching Application " & itm.text & "... "
ScrollText
On Error Resume Next 'launch the application
Call Shell(arrApp(itm.Index - 1).Path, vbNormalNoFocus)
DoEvents
etmswindow = IsWindowEnabled(etmsprod.hwnd)
If etmswindow <> 0 Then
AppActivate ("Enterprise Trouble Management System")
SendKeys ("{DEL}{DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} {DEL} ")
SendKeys ("mgress {TAB}")
SendKeys ("password03 {ENTER}")
End If
'End If
If Err.Number <> 0 Then
txtStatus = txtStatus & Err.Description & "." & vbCrLf
Err.Clear
Else
txtStatus = txtStatus & "OK." & vbCrLf
End If
On Error GoTo ErrHandler
ScrollText
Next
ErrHandler:
txtStatus = txtStatus & "Error: " & Err.Description & vbCrLf & "Done."
ScrollText
End Sub
Ales Zigon
03-18-2003, 01:15 AM
What is "etmsprod"? IS it the name of the called application?
As the argument to the function you must pass the handle to the application window. To get it, you should probably use GetWindow or GetWindowDC and pass it thru.
Samhane
03-18-2003, 06:04 AM
Etmsprod is the application - One of the many actually. I will try what you mentioned. Unfortunately, I am new to VB and was wondering if you hand any syntax usage of that command. Thanks, Mark
Samhane
03-18-2003, 06:06 AM
The problem that I am having is I have to log the user onto about 5 different applications so I am going to have to find out which window handle corresponds to each program and then send the specific keystrokes and passwords for each program. I have finished everything else and I am stuck on this. 8-(
Robse
03-18-2003, 06:17 AM
Not sure if this is what you need, but you can find out
each window's name using the GetWindowText() API,
cycling through every active window using GetActiveWindow()
and GetWindow() API's