ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Removed Areas > AutoHotkey

AHK - Wait functions don't really wait

(1/2) > >>

I've never been able to make functions like WinWait, WinWaitActive, WinWaitNotActive really work for me. AHK just doesn't seem to wait for the window - it doesn't matter whether I use the ahk_class or title to identify the window... I don't set any seconds timeout either... AHK zips right past the wait fns and executes the following commands anyway. I've been dealing with this using Sleep calls which is a bit of a dirty hack. Is there any way to make the wait fns actually wait?

Usage example:
WinClose, desktop38.ico
WinWaitNotActive, desktop38.ico      

(desktop38.ico is a valid window title)            


if you're closing a window (as in the above example) try ifwinexist/ifwinnotexist

stupid question, but have you looked at the window(s) using a window spy app?

You can use the one that comes with AHK, or try Toralf's version here

Yes, I have been using AHK spy. It's doesn't seem like a matter of identifying the window though - everything works as intended if I use a Sleep command. I generally use spy but some windows keep being assigned different class names on each run so I have to use the title in those cases. I'll give the alternative spy app a try though, thanks for the link.

Regarding IfWinExist: I need the first window to close before the subsequent commands are executed or they are performed on the first window itself, despite my using WinActivate to activate the intended target window. Making the WinClose conditional should just make the program ignore the command altogether, having the same effect. I don't suppose there's a way to direct a Send command to a specific window only, rather than whichever window is active?

; Inserting a Sleep at this point makes the code run as intended
WinClose, desktop38.ico
WinActivate, CompuPic Pro - USER
Send {Alt}oo{Enter}   
--- End quote ---

i did say it was a stupid question... :-[

how about winwait close?

or maybe lookat SetTitleMatchMode?

does your target app have child windows (ala Excel)?  A colleague here has been trying to do something similar and is having problems cos he can't ID the relevant 'child' window (ie all windows appear the same to AHK)

WinWaitClose by itself bombs badly but, a

WinWait, desktop38.ico
WinClose, desktop38.ico
WinWaitClose, desktop38.ico

--- End quote ---

combination seems to do the trick.  :Thmbsup: Thanks for helping me out.


[0] Message Index

[#] Next page

Go to full version