Jump to content

Script is simply ignoring WinWait or WinWaitActive


Recommended Posts

I'm running a script that copies mobile number and SIM card numbers out of excel and pastes them into another program. In this other program I have a function to pull up the mobile number's information and then I need to access another window to paste the SIM number into which is opened using Alt-Shift-C. This new window is called "SIM Info" and I need the script to wait for a second to see if it pops up. If it doesn't then this means that the mobile number was canceled or invalid and I need to switch to another function using Ctrl-Shift-R. If the window does pop up then the script pastes in the sim card and moves onto the next mobile number. Here's the code for the function where I'm trying to make WinWait work:

Func SM2()
WinActivate ("Service Management")
Sleep (250)
Send ("{!+c}")
Sleep (250)
WinWait ("SIM Info", "" , 1)
If WinWait()=@error Then
Send ("^+r")
EndIf
Sleep (250)
Send ("CR")
Sleep (250)
Send ("{TAB}")
Sleep (250)
Send ("^c")
Sleep (250)
Send ("{ENTER}")
Sleep (250)
Send ("{F2}")
EndFunc
 
I'm a complete newb to AutoIT and have never used this function before, so I have no idea why it's not working. Right now the script is just straight up ignoring the WinWait and continuing on as if the SIM update window opened up even though it didn't. Tried using WinWaitActive as well because it would be just as effective, but same problem. 

 

Link to comment
Share on other sites

Hi and Welcome to the Autoit forum


 First thing to do is to change these lines in your function

WinWait("SIM Info", "", 1)
If WinWait() = @error Then
Send("^+r")
EndIf

 with

Local $hwnd = WinWait("SIM Info", "", 2) ;retrieve and declare the handle to the window
If Not HWnd($hwnd) Then ;checks if the declared handle is (not) valid
    Send("^+r")
    Return
EndIf

 

Link to comment
Share on other sites

  • Developers

Isn't that what you are telling it to do?

You have a 1 as 3rd parameter so it will continue after one second...right?

The subsequent "If" is coded wrong and should be without the winwait() function.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...