Hi,
I know WinWait allows you to wait until a specified window appears, but is there a way to pause my script until any window appears? The reason is because after part of the script runs, one of two windows could then appear, and depending on the window that appears, certain actions need to be taken. Right now I have it set up to wait for one window to open for 10 seconds and to assume the other window opens if the first window didnt open within those 10 seconds. Thanks in advance for your help!
Raman

How to wait for a window to appear
Started by
Raman325
, Jan 04 2007 10:58 PM
2 replies to this topic
#1
-
Posted 04 January 2007 - 10:58 PM

You can try this. This will get any active window that is not named 'Program Manager'... Program Manager is the window title for the desktop, as far as I know, at least on XP.
HTH...
Loop { Sleep, 1000 WinGetActiveTitle, Var If Var <> Program Manager Break } MsgBox, %Var%
HTH...
#2
-
Posted 05 January 2007 - 12:33 AM

I use WinWaitNotActive to wait for "any next window"...
;//remember current window... hwndtmp:="ahk_id " WinExist("a") ;//insert code here to cause a window to become active...for example... Run, notepad ;//next line for debug only...show tooltip while waiting... Tooltip, waiting... ;//wait for remembered window to NOT be active...means "something" else is active... ;//increase/decrease timeout as needed for this situation...8 means 8 seconds... WinWaitNotActive, %hwndtmp%, , 8 if (errorlevel) { ;//next line for debug only...clear tooltip... Tooltip ;//it's good to handle timeouts in your code, so it doesn't get stuck...& you don't know why... ;//msgbox, 16, , WinWait Timeout waiting for <type helpful description here> window msgbox, 16, , WinWait Timeout waiting for Notepad window } ;//next line for debug only...clear tooltip... Tooltip ;//get an hwnd of JUST this window...& use it to reference this window... hwnd:="ahk_id " WinExist("a") ;//your code continues here... msgbox, 64, , Debug: hwnd(%hwnd%)`n`ndone!...this may be a bad example, since if you ARE using Run to "cause the window to appear"...you should try to use the pid param of run...but sometimes the pid fails, so this is a good workaround...just in-case you are using Run, here's an example of how to use the pid...
;//run a program, save the pid... Run, notepad, , , pid ;//next line for debug only...show tooltip while waiting... Tooltip, waiting... ;//wait for a window matching the Run pid, to EXIST... ;//change this to use active, if you want to only continue if it's active... ;//increase/decrease timeout as needed for this situation...8 means 8 seconds... WinWait, ahk_pid %pid%, , 8 if (errorlevel) { ;//next line for debug only...clear tooltip... Tooltip ;//it's good to handle timeouts in your code, so it doesn't get stuck...& you don't know why... ;//msgbox, 16, , WinWait Timeout waiting for <type helpful description here> window msgbox, 16, , WinWait Timeout waiting for Notepad window } ;//next line for debug only...clear tooltip... Tooltip ;//then for even better (more specific) code, trade the pid for an hwnd of JUST this window... hwndnotepad:="ahk_id " WinExist() ;//your code continues here... msgbox, 64, , Debug: pid(%pid%) hwndnotepad(%hwndnotepad%)`n`ndone!
#3
-
Posted 05 January 2007 - 06:19 AM

Useful forum links: New content since: Last visit ■ Past week ■ Past 2 weeks (links will show YOUR posts, not mine)
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?