Help with click

Ask gaming related questions (AHK v1.1 and older)
lacco
Posts: 1
Joined: 08 Jul 2019, 17:11

Help with click

12 May 2021, 16:04

Hello! I'm having trouble making a simple imagesearch > click script.

Code: Select all

SetWorkingDir %A_ScriptDir%
SetMouseDelay, 50

Loop
{
	ImageSearch, px, py, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *10 %A_ScriptDir%\imageName.png
	if ErrorLevel = 0 
	{
		MouseMove, %px%, %py%
		Sleep, 1000
		MouseClick, left, px, py
		Sleep, 1000
		MsgBox % "Errorlevel: " . errorlevel . "`nX: " . px . "`nY: " . py
	}
}
This is the code that I have atm. Neither MouseMove or MouseClick works.
The ImageSearch works, it goes to the MsgBox which shows the right X and Y positions (comparing with the WindowSpy), but the rest doesn't. Already tried every other click/move option and still it doesn't work.

I THINK it's something with the game/application blocking the input that AK is sending, but I'm just a newbie on this so I'm not sure.

I've tried it on the game called "Bloodstone" a long time ago, and now it's "Axie Infinity" that I'm trying, with the same problem.
*Already had the same script working on other games/applications.


Anyone know what I can do?
User avatar
mikeyww
Posts: 26849
Joined: 09 Sep 2014, 18:38

Re: Help with click

12 May 2021, 18:05

Test in a different program-- Notepad, etc.-- to see if it works there. If it does, then you could have a look at the tips for games.

https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/

If you do not add a sleep after a failed search, your loop will cycle very quickly and probably tie up the CPU.

Advice: if you intend to search the entire screen, then set the CoordMode (both Mouse & Pixel) first. If you intend to search only the active window, then fix the range of coordinates.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 44 guests