Page 1 of 1

Making a script that clicks when any pixels move

Posted: 07 Jun 2018, 07:21
by nightreaper2000
I want to make a script that clicks when any pixels move on the screen. I understand that AHK has its limitations but I figured id ask anyway. Im somewhat new to AHK and trying to learn something new.
This is what I have so far:

Code: Select all

g::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
; If pixel color no longer equals %MouseX%, %MouseY%, click
return
Im just not sure how to express the last line of code properly.

Re: Making a script that clicks when any pixels move

Posted: 07 Jun 2018, 10:41
by Rohwedder
Hallo,
perhaps:

Code: Select all

g::
	MouseGetPos, MouseX, MouseY
	PixelGetColor, ColorOld, MouseX, MouseY
	SetTimer, ColorOld, 100
return
ColorOld:
	PixelGetColor, ColorNew, MouseX, MouseY
	If (ColorNew <> ColorOld)
	{ ;If pixel color no longer equals %MouseX%, %MouseY%, click
		Click
		SetTimer, ColorOld, Off
	}
Return

Re: Making a script that clicks when any pixels move

Posted: 07 Jun 2018, 10:56
by brutus_skywalker
Ah, my solution didn't relate to ur question.....my bad [BadPost]

Re: Making a script that clicks when any pixels move

Posted: 07 Jun 2018, 11:20
by nightreaper2000
Rohwedder wrote:Hallo,
perhaps:

Code: Select all

g::
	MouseGetPos, MouseX, MouseY
	PixelGetColor, ColorOld, MouseX, MouseY
	SetTimer, ColorOld, 100
return
ColorOld:
	PixelGetColor, ColorNew, MouseX, MouseY
	If (ColorNew <> ColorOld)
	{ ;If pixel color no longer equals %MouseX%, %MouseY%, click
		Click
		SetTimer, ColorOld, Off
	}
Return
Thank you so much... spent the last few hours tryna get that. When i use the script, it only clicks when i move my mouse after pressing g regaurdless of what is happening ingame.