I have 2 scenarios I'm struggling with
Scenario 1:
step1.click a button
step2.then after .5seconds a dialog box *may* appear
step3.if it does appear then send ENTER
step4.now regardless of whether the dialog in step 2/3 appeared, a different dialog box will now appear, press TAB then ENTER on this dialog
Scenario 2:
The title of the main application is called blah
Step1.click a button
step2.then after .5seconds, 2 dialog boxs will appear. So there will be 3 windows of this application open. The main app window called blah, a new window in the background called other and then a smaller active window called blah (same title as the main application)
step3.the 2 new dialogs from step 2 may take between 10seconds and 2 minutes before they both closes by themself
step4.once those 2 windows from step3 close i wan't to send Shift + C
Can someone please provide the code?
Thanks in advance!

wait till window opens then wait till it closes
Started by
toop
, Feb 01 2012 08:27 AM
9 replies to this topic
#1
-
Posted 01 February 2012 - 08:27 AM

scenario 1:
IfWinActive, Warning - Opening Old Project File
{
SendInput {Enter}
}
scenario 2:
WinWaitClose, ahk_class #32770
Sleep, 1000
Send +C
for the first scenario, it seems to work
but for the 2nd scenario it never sends the Shift + C (because if it did a save window would then appear)
IfWinActive, Warning - Opening Old Project File
{
SendInput {Enter}
}
scenario 2:
WinWaitClose, ahk_class #32770
Sleep, 1000
Send +C
for the first scenario, it seems to work
but for the 2nd scenario it never sends the Shift + C (because if it did a save window would then appear)
#3
-
Posted 01 February 2012 - 09:00 AM

Is that what you need for scenario 1?
IfWinActive, Warning - Opening Old Project File { SendInput {Enter} } sleep 500 SendInput {Tab} sleep 100 SendInput {Enter}
#5
-
Posted 01 February 2012 - 11:14 AM

Is that what you need for scenario 1?
IfWinActive, Warning - Opening Old Project File { SendInput {Enter} } sleep 500 SendInput {Tab} sleep 100 SendInput {Enter}
THanks but this does not check for the 2nd dialog box appearing
also, scenario 2 is the real challenge.
#6
-
Posted 01 February 2012 - 11:46 AM

first let's finish with scenario 1, then we will move to scenario 2
[/code]
IfWinActive, Warning - Opening Old Project File { SendInput {Enter} } sleep 500 IfWinActive, <your new opened windows> { SendInput {Tab} sleep 100 SendInput {Enter} }
[/code]
#7
-
Posted 01 February 2012 - 12:01 PM

/* Scenario 1: step1.click a button step2.then after .5seconds a dialog box *may* appear step3.if it does appear then send ENTER step4.now regardless of whether the dialog in step 2/3 appeared, a different dialog box will now appear, press TAB then ENTER on this dialog */ WinWaitActive Window1 Send {Return} ; Valdiate the current window, ok if the windows contains a single button SetTimer CheckPopup, 100 WinWaitActive Window2 Send {Tab}{Return} Return CheckPopup: IfWinExist Popup { WinActivate Popup Send {Return} SetTimer Popup2, Off } Return
#8
-
Posted 01 February 2012 - 01:50 PM

/* Scenario 2: The title of the main application is called blah Step1.click a button step2.then after .5seconds, 2 dialog boxs will appear. So there will be 3 windows of this application open. The main app window called blah, a new window in the background called other and then a smaller active window called blah (same title as the main application) step3.the 2 new dialogs from step 2 may take between 10seconds and 2 minutes before they both closes by themself step4.once those 2 windows from step3 close i wan't to send Shift + C */ WinWaitActive blah Send {Return} ; same thing as scenario 1, that's depend of the number of buttons in the window, if it's a yes/no you must use some tabs or ControlClick Wait := True SetTimer WaitToClose, 100 While Wait Sleep 100 Send ^c Return WaitToClose: IfWinExist other other := True IfWinExist blah ; THIS WON'T WORK ! You should check the ahk_class of the second "blah" window or something to identify it (some text specific to the window perhaps) blah := True If other And !WinExist("other") otherClosed := True If blah And !WinExist("blah") ; Same thing as above blahClose := True If (otherClosed And blahClose) Wait := False ; This should stop the loop in the main code If !Wait SetTimer WaitToClose, Off Return
#9
-
Posted 01 February 2012 - 01:59 PM

Working example with the scenario 2 and Notepad :
1. Run the script.
2. Run Notepad
3. It should send some text.
4. Open the "Save As" menu and close it (doesn't save it's useless).
5. Open the "Open" menu (the button "No" will automaticaly be clicked, soemtime it seems the window is frozen, it's ok and should continue after some times it's because of the use of timer and no pause between actions).
5. The text should be changed.
4 and 5 can be inverted (Open first then Save As).
WinWaitActive ahk_class Notepad Sleep 100 Send This is a test Wait := True SetTimer WaitToClose, 100 While Wait Sleep 100 Sleep 100 Send ^aPrevious text erased ! Return WaitToClose: IfWinActive , , Do you want to save the changes? ControlClick Button2, , Do you want to save the changes? IfWinExist Save As other := True IfWinExist Open blah := True If other And !WinExist("Save As") otherClosed := True If blah And !WinExist("Open") blahClose := True If (otherClosed And blahClose) Wait := False If !Wait SetTimer WaitToClose, Off Return
1. Run the script.
2. Run Notepad
3. It should send some text.
4. Open the "Save As" menu and close it (doesn't save it's useless).
5. Open the "Open" menu (the button "No" will automaticaly be clicked, soemtime it seems the window is frozen, it's ok and should continue after some times it's because of the use of timer and no pause between actions).
5. The text should be changed.
4 and 5 can be inverted (Open first then Save As).
#10
-
Posted 01 February 2012 - 02:08 PM
