AHK clicks window button before it is ready

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
teknowledgist
Posts: 14
Joined: 22 Nov 2016, 10:20
Contact:

AHK clicks window button before it is ready

23 Mar 2018, 08:33

I have a script for auto-installing an app that can't be silently installed. It is about 5 windows long and has a WinWait command with a very specific identifier before every set of ControlClick commands, but sometimes (especially on slower machines) AHK claims it clicked the buttons and is waiting for the next window while the previous window still sits there. The craziest part of this is that the sticking point can be any of the windows. It feels like the chances are weighted toward the first windows, but it has happened (mostly randomly) on all of the windows.

How can this be? Does Windows create a window before the buttons are available and AHK is just too efficient? 8-)

I haven't experienced this issue with my (few) other AHK scripts. Could the specific installer be doing something different to confuse an automated install like this?

Is there any way to wait for the buttons to be "active" before they are clicked without a fixed, arbitrary sleep time or some other "trick" that I can employ to get this to work?

Thanks.
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: AHK clicks window button before it is ready

23 Mar 2018, 09:35

Use WinWaitActive instead of WinWait. If you are still having problems, put a timeout on the WinWaitActive and some kind of error catching fix the problem.
teknowledgist
Posts: 14
Joined: 22 Nov 2016, 10:20
Contact:

Re: AHK clicks window button before it is ready

23 Mar 2018, 12:32

WinWaitActive made no difference. I ended up setting a short timeout on WinWait whereupon if the previous window was open it would goto the commands for the previous window again and a While loop for the last window where AHK clicks until the window disappears.

Ugly, but working.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen and 424 guests