mosow Posted November 22, 2006 Share Posted November 22, 2006 I have a VBScript in which I start a program and send keystrokes. This is run through the Windows Scheduler. My problem is that it does not seem to always activate the Window, so my application just sits. Below is the snippet of code that I use to start the program, activate the window and send keys. Any ideas on why it will not activate the window. I am getting a return result of 0 from WinWaitActive rather than a 1, which means it was successful. TIA VBScript Code: AutoIT.Run ServerUTL1751Path, Replace(Trim(UCase(ServerUTL1751Path)), "\UTL1751.EXE", "") If Err.number <> 0 Then Log.ErrorMessage Err.number, Err.Description, "Error running " & ServerUTL1751Path & ": " EndScript End If WScript.Sleep 10000 Err.Clear AutoIT.WinActivate "Premier Application Deployment Manager" AutoITResult = "" AutoITResult = AutoIT.WinWaitActive("Premier Application Deployment Manager", "", 60) Log.WriteLog "The first WinWaitActive result was " & AutoITResult, True If AutoITResult = 0 Then Log.WriteLog "The first WinWaitActive failed", True End If Log.WriteLog "First Winactive status: " & AutoIT.WinActive, True WScript.Sleep 10000 AutoIT.Send "{Alt}FSD" WScript.Sleep 10000 AutoITResult = "" AutoITResult = AutoIT.WinWaitActive("Premier Application Deployment Manager", "", 60) Log.WriteLog "The second WinWaitActive result was " & AutoITResult, True If AutoITResult = 0 Then Log.WriteLog "The second WinWaitActive failed", True End If Log.WriteLog "Second Winactive status: " & AutoIT.WinActive, True WScript.Sleep 10000 AutoIT.Send "{F8}" WScript.Sleep 10000 Link to comment Share on other sites More sharing options...
mosow Posted November 22, 2006 Author Share Posted November 22, 2006 The task scheduler service is set to interact with the desktop and is running as the local system account. The task is set to run as a domain account. The problem seems to be intermittent. Link to comment Share on other sites More sharing options...
mosow Posted November 27, 2006 Author Share Posted November 27, 2006 I have included the WinActivate but the same problem occurs. My application does not receive the keystrokes. Here is my code with the WinActivate: Err.Clear Log.WriteLog "Starting " & ServerUTL1751Path, True AutoIT.Run ServerUTL1751Path, Replace(Trim(UCase(ServerUTL1751Path)), "\UTL1751.EXE", "") If Err.number <> 0 Then Log.ErrorMessage Err.number, Err.Description, "Error running " & ServerUTL1751Path & ": " EndScript End If AutoITResult = "" AutoITResult = AutoIT.WinWait ("Premier Application Deployment Manager", ,60) Log.WriteLog "WinWait result was " & AutoITResult, True If AutoITResult = 0 Then Log.WriteLog "The WinWait failed", True End If Err.Clear AutoIT.WinActivate "Premier Application Deployment Manager" AutoITResult = "" AutoITResult = AutoIT.WinWaitActive("Premier Application Deployment Manager", "", 60) Log.WriteLog "The first WinWaitActive result was " & AutoITResult, True If AutoITResult = 0 Then Log.WriteLog "The first WinWaitActive failed", True End If Log.WriteLog "First Winactive status: " & AutoIT.WinActive, True WScript.Sleep 10000 AutoIT.Send "{Alt}FSD" WScript.Sleep 10000 AutoITResult = "" AutoITResult = AutoIT.WinWaitActive("Premier Application Deployment Manager", "", 60) Log.WriteLog "The second WinWaitActive result was " & AutoITResult, True If AutoITResult = 0 Then Log.WriteLog "The second WinWaitActive failed", True End If Log.WriteLog "Second Winactive status: " & AutoIT.WinActive, True WScript.Sleep 10000 AutoIT.Send "{F8}" WScript.Sleep 10000 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now