Jump to content

Recommended Posts

Posted

Hello everyone. Im trying to do a script to do the next:

1- Run a program (and wait til it close, because i call the autoit script with scart /wait from CMD)

2- Check if a window is opened (not allways happens), focus and send keys

I wrote this, and obviously its not working:

Run("wpi2.exe")
WinWait("[CLASS:HTML Application Host Window Class]")

 If WinActive("[CLASS:#32770]") Then
   Send("{TAB}")
   Send ("{SPACE}")
EndIf

WinWaitClose("[CLASS:HTML Application Host Window Class]")

The windows i need to close (#32770) sometimes is opened before this script is executed, Its not the result of the program im calling in first line.

I will apreciate your help!

 

Thanks in advance.

Posted

Yes, The problem i have is to send key only if the window is active, because i have to send tab and space and if the windows in not active theese commands will close another app.

Also i need to wait until the first app i run (wpi.exe) close.

 

Thanks!!

Posted (edited)

Try this then..

RunWait("wpi2.exe")

While 1
    If WinActive("[CLASS:#32770]") Then
        Send("{TAB}{SPACE}")
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Note that if the window in question is not active, it will have to be activated manually (IOW, by you). Also, the ExitLoop statement can be replaced by Exit, if there is not going to be any code added after the While loop.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
×
×
  • Create New...