after 4 hours i decided i should get help lol Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest

after 4 hours i decided i should get help lol  Topic is solved

24 Feb 2017, 00:24

Hi guys. I'm sort of new to the whole ahk thing. I've been making great progress, but I'm finally at the point where I can't find the answer on the internet

Code: Select all

stuck = 0
while stuck<5
{
PixelSearch, Px, Py, 446, 356, 799, 508, 0x04051E,3 , fast RGB
if ErrorLevel
	break
else
;---------------------------------------------------- clicking
MouseGetPos, oldx, oldy
MouseMove, %px%, %py%
Sleep, 200
Send, {Ctrl Down}
Click
Send, {Ctrl up}
MouseGetPos, newx, newy
if (oldx =newx and oldy = newy)
{
	stuck++
	MsgBox, ,,number of stucks triggered %stuck%,1
}
;---------------------------------------------------done
}
Basically I'm trying to make sure the script doesn't back track on pixels, if its trying to back track to much i'm trying to break the loop. It all works great, except the

"if (oldx =newx and oldy = newy)" I've also tried
if (oldx and oldy = newx and newy)
and so many other varations, i just can't figure it out.
4GForce
Posts: 553
Joined: 25 Jan 2017, 03:18
Contact:

Re: after 4 hours i decided i should get help lol

24 Feb 2017, 02:27

Guest wrote:Basically I'm trying to make sure the script doesn't back track on pixels, if its trying to back track to much i'm trying to break the loop. It all works great, except the
"if (oldx =newx and oldy = newy)" I've also tried
if (oldx and oldy = newx and newy)
and so many other varations, i just can't figure it out.
I'm surprised the 1st one doesn't work even tho I would usually write it like this

Code: Select all

if((oldX == newX) AND (oldY == newY)) {
	; stuck++ blablabla
}
Side notes:
I think that the MouseGetPos, newx, newy is useless since its going to be px and py unless the user moved the mouse
User mouse action could be prevented with BlockInput


Edit: Actually, I don't think PixelSearch would ever backtrack.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: after 4 hours i decided i should get help lol

24 Feb 2017, 15:00

I'm not sure if this is relevant to what you're trying to achieve, but I thought I'd share it. It's based on my ImageSearch script at:
My first project: How hard/easy it is to develop a script for this? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28023

To move the mouse to each pixel of a certain colour:

Code: Select all

q:: ;jump to next instance of pixel on screen
vPosW := 1, vPosH := 1

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

vPosX1 := 0, vPosY1 := 0
vPosX2 := A_ScreenWidth, vPosY2 := A_ScreenHeight

vCheckingStrip := 0
Loop
{
PixelSearch, vPosX, vPosY, vPosX1, vPosY1, vPosX2, vPosY2, 0xFF0000, 0, Fast RGB
vImageFound := !ErrorLevel ;0/1/2 found/not found/problem
if !vCheckingStrip && !vImageFound
	break
if vCheckingStrip && !vImageFound
	vPosX1 := 0, vPosY1 := vPosYg+1, vPosX2 := A_ScreenWidth, vPosY2 := A_ScreenHeight, vCheckingStrip := 0

if vImageFound
{
	vPosXg := vPosX, vPosYg := vPosY
	vCheckingStrip := 1 ;this variable means we are checking the rest of the strip to the right of a found image
	MouseMove, %vPosX%, %vPosY%, 0
	vPosX1 := vPosX+1, vPosY1 := vPosY, vPosX2 := A_ScreenWidth, vPosY2 := vPosY + vPosH

	if (vPosY + vPosW > A_ScreenWidth)
		vPosX1 := 0, vPosY1 := vPosY+1, vPosX2 := A_ScreenWidth, vPosY2 := A_ScreenHeight, vCheckingStrip := 0
	Sleep 500
}
}
MsgBox % "done"
Return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 124 guests