Simple command not working???

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Simple command not working???

Post by Ryder » 17 Aug 2022, 15:53

Hi All...

Something about this usage that is preventing the While statement to work...

Code: Select all


Gui, Add, Button, gok1 x9    y582  w306 h440 HWNDhScrolla

;[...]

ok1:
while GetKeyState("LButton","P")
{
	MouseGetPos, MouseX, MouseY, MouseWin, MouseCtl, 2		;Get MouseCtl
	ControlClick, x%MouseX% y%MouseY%, %MainTitle%, , Left		;ElSCP1 is the Navigator control
	Sleep 10
}
Return
When I click on the button, the ok1: does fire off... but GetKeyState is apparently not evaluating to 1

What could be going on here?

OH WAIT!!! is it because ok1: is firing off when the mouse button is released???!!! Damn. I bet that's it.

Thank you!

R

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Simple command not working???

Post by mikeyww » 17 Aug 2022, 20:07

The script executes from one line to the next. It does not wait for you. If the button is not held at the exact moment when the command executes, then its value (GetKeyState) is zero. You can test that yourself simply by displaying its value in the script.

Post Reply

Return to “Ask for Help (v1)”