Script only works after one button press not repeatedly

Ask gaming related questions (AHK v1.1 and older)
alexng92
Posts: 1
Joined: 24 Sep 2022, 23:44

Script only works after one button press not repeatedly

Post by alexng92 » 24 Sep 2022, 23:47

Code: Select all

F1::
CoordMode, Pixel, Window
PixelSearch, HealthX, HealthY, 121, 150, 174, 157, 0x000000, 0, Fast RGB
If (ErrorLevel = 0)
{Send {3}
}

return 
Hey so I have this code I was testing in a flash game I was playing that when it detects the color black (000000) in a certain frame, then it would send the button 3, however, I wanted this to work so that when I press F1, it will always look for the color black in that window and constantly send the button 3 when there is black. Where am I doing this wrong? Do I need a boolean statement somewhere?? Thank you.

Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script only works after one button press not repeatedly

Post by Rohwedder » 25 Sep 2022, 02:32

Hallo,
try:

Code: Select all

F1 Up::SetTimer, TF1,% (TF1:=!TF1)?200:"Off" ; every 200 ms / off
TF1:
CoordMode, Pixel, Window
PixelSearch, HealthX, HealthY, 121, 150, 174, 157, 0x000000, 0, Fast RGB
If !ErrorLevel
	Send {3}
return

Post Reply

Return to “Gaming Help (v1)”