Jump to content

Problem with WinActivate


mosow
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...