Please help fix my script. I feel so close to completing it

Ask gaming related questions (AHK v1.1 and older)
theboom123
Posts: 5
Joined: 29 Jun 2022, 00:49

Please help fix my script. I feel so close to completing it

Post by theboom123 » 29 Jun 2022, 00:56

Hello all, I am new to AHK and was wondering if someone can help me fix my script.

Code: Select all

CoordMode, Mouse, Screen

F11::
Loop
{
	Sleep 6000
	Send {E}
	Loop
	{	
		PixelSearch, FoundX, FoundY, 213, 235, 1569, 918, 0xeaba6f, 10, RGB Fast
		if (ErrorLevel = 0){
		Send {E}
		Break
		}
	}		
}
*ESC::ExitApp
Basically, I want the script to start off with inputting E and cycle through the pixelsearch until it finds the color. Afterwards, I want it to complete the errorlevel = 0 commands and break that loop and start over from the beginning. I will appreciate any input! thank you.

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

Re: Please help fix my script. I feel so close to completing it

Post by mikeyww » 29 Jun 2022, 05:26

Test in Notepad. Add a MsgBox that displays the ErrorLevel for you, so that you know what it is. You described what the script should do. What does it actually do? Test with a plain static colored image without any variation. For visual confirmation, you can MouseMove to your starting coordinate. Use PixelGetColor to get the color that you think the script should find. Display that color value. Remove the loops so that you can simply test a single search, until you get it working.

theboom123
Posts: 5
Joined: 29 Jun 2022, 00:49

Re: Please help fix my script. I feel so close to completing it

Post by theboom123 » 29 Jun 2022, 08:25

@mikeyww
The pixel search is not the problem, the script simply helps me navigate through a specific program easier so the msgbox isn't needed. Overall, I want this entire script to loop, but I don't want it repeatedly inputting E until after it finds the pixel. After it finds the pixel and completes the ErrorLevel = 0, I want it to start from the top again. Hope that makes sense

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

Re: Please help fix my script. I feel so close to completing it

Post by Rohwedder » 29 Jun 2022, 09:00

Hallo,
"to start from the top again" is ambiguous.
If you want to exit the F11:: thread, replace Break with Return or Exit.
If you want to terminate the script, then by Break, 2 or ExitApp.
If you want to restart the script, then by Reload.
But why did you include an outer Loop?
By the way, Break, 2 would terminate the script since there is neither a Return nor an Exit between the F11:: and the *Esc:: routine.

Post Reply

Return to “Gaming Help (v1)”