Mouse Maze

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
thegame2010
Posts: 29
Joined: 04 Feb 2016, 18:14
Location: 'Murica

Mouse Maze

18 Mar 2016, 13:31

So I made a script to move the mouse around obnoxiously. It's terrible, and I love it. :trollface:

Code: Select all

#persistent
Loop
{
	random, X, -10, 10 
	random, Y, -10, 10 
	MouseMove, X, Y, 5, R
}

^Esc::run taskkill /IM MouseMove.exe
I think it would be sweet if I could get it to navigate a maze like this one:
Maze1.png
In order to do this, I need to have a script check the color under the mouse. It would be cool to have two different modes: one where hitting a black pixel forces restart, and one where hitting a black pixel reverts the cursor to its position prior to hitting the wall.

Here's what I have so far, and it doesn't work:

Code: Select all

#persistent
Loop
{
	MouseGetPos, Xpos1, Ypos1
	PixelGetColor, Colour, Xpos1, Ypos1
	Sleep, 75
	If Colour=0x00FF00
	; if green
		run taskkill /IM MouseMaze.exe
		return
	If Colour=0x000000
	; if black
		PixelSearch, Px, Py, 0, 0, 1920, 1080, 0xFF0000, 3, Fast RGB
			MouseMove, Px, Py, 1
		return
;	If Colour=0xFFFFFF   <- I don't think I need anything for "if white"
;		return
return
}

^Esc::
	run taskkill /IM MouseMaze.exe ,, hide
	run taskkill /IM MouseMove.exe ,, hide
	run taskkill /IM AutoHotKey.exe ,, hide
What am I missing?
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Mouse Maze

18 Mar 2016, 17:47

Several issues...
First, you did not include the multiple lines for each If inside curly braces. IE:

Code: Select all

	If Colour=0x00FF00
	{	; if green
		run taskkill /IM MouseMaze.exe
		return
	}
Second, you have a Return right before the closing brace of your loop, which effectively negates the loop.


There may be more issues, as I have not actually tested the code - however, the ones I mentioned above will definitely prevent the script from functioning as you intended.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Joey5 and 268 guests