WinWait not always consistent...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jsmain
Posts: 62
Joined: 07 Feb 2014, 08:21

WinWait not always consistent...

04 Jan 2018, 13:37

Is it just me, or do others also find that WinWait, WinWaitExist, and WinWaitActive are not always consistent?

If I run a loop that starts say notepad, WinWait for it to open, and then open the open dialog, then wait for it to open then close the entire works, 1 of say 100 loops will get stuck with either notepad open, or it's open dialog, and it will sit there until you intervene.

If you are seeing this. how do you cope with fixing it?
jsmain
Posts: 62
Joined: 07 Feb 2014, 08:21

Re: WinWait not always consistent...

04 Jan 2018, 20:11

Seems as though I found an acceptable solution.... :superhappy:

Code: Select all

	loop{
	;	WinActivate, ahk_pid %PID% 
		; Click the Start Batch Conversion button ClassNN:Button1
		ControlClick, &Start Batch Conversion, ahk_pid %PID%,, L,1,NA	;Batch Convert to Ots
		WinWait, Really Overwrite Existing Files?,,1
	}
	until ErrorLevel=0
Thanks anyhow!
Hotte
Posts: 32
Joined: 03 Jan 2018, 14:39

Re: WinWait not always consistent...

04 Jan 2018, 20:32

Generally it is very difficult to get 100% reliabilty.
If macros get more complex you are getting a lot of timing difficulties and you will eventually need some nasty loops & sleep-statements to get things working.
Its a matter of a lot of fine-tuning and hopefully no user-interference.

=> ifWinExist is very reliable and very, very fast
=> ifWinActive is very, very fast but not very reliable. If the sends come to quickly, they might get lost
=> winWaitActive is pretty slow (~120ms) but generally reliable. Prefer it to ifWinActive in terms of reliabilty

If you run into trouble with winWaitActive, it is usually a coding or application issue.

I have a pretty good advice for you: Search for "winSend" in the scripting examples forum. I have written this powerful function to get a very fast and reliable and very easy to use alternative to send. I hardly use activate, ifwinactivate etc. send, click, loops and other stuff anymore and replaced them all with winSend and winClick. These command make sure, that your sends, clicks or pixegetcolor-calls ALWAYS hit the right window - even if you interfere with your mouse.
Copy my code into your macro an do calls like this:

Code: Select all

WinSend("^shello!{Enter}","myWindowTitle,myWindowText")
I´d be glad to here your feedback.
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: WinWait not always consistent...

25 Jul 2021, 19:24

Does anyone have a more reliable function to ensure WinWaitActive literally says what it does? To me it works only 60% of the time.

Take one of my scripts For instance, it doesn't always fully load the window before sending "Remove":

Code: Select all

#NumpadSub:: ;uninstall or remove programs
#-::
Send ^{Esc} 
WinWaitActive,ahk_class Windows.UI.Core.CoreWindow,,2
SendInput Remove
Sleep 100
SendInput {enter}
Sleep 1200
SendInput {tab 2}
return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: WinWait not always consistent...

26 Jul 2021, 03:59

Hotte wrote:
04 Jan 2018, 20:32
=> winWaitActive is pretty slow (~120ms)
100 is the default windelay. if u need it to be faster, change the defaults
milkygirl90 wrote:
25 Jul 2021, 19:24
Does anyone have a more reliable function to ensure WinWaitActive literally says what it does? To me it works only 60% of the time.

Code: Select all

WinWaitActive,ahk_class Windows.UI.Core.CoreWindow,,2
get rid of the timeout and it will be 100% reliable. in other words, it will wait unconditionally until the specified window becomes active

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 210 guests