Is pixelssearch buggy? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hieveryone
Posts: 43
Joined: 28 Nov 2022, 01:31

Is pixelssearch buggy?

11 Jun 2023, 00:57

I tried pixel search and its really buggy, it has a loading and you cant exit the app after running the script(after a while you can) . The other issue , it does work - only when the colour isn't there and after a while.
gregster
Posts: 9103
Joined: 30 Sep 2013, 06:48

Re: Is pixelssearch buggy?

11 Jun 2023, 01:09

It sounds like you are doing something wrong. But without code which would allow to reproduce your findings...
Perhaps you are searching too large areas.
https://www.autohotkey.com/docs/v2/lib/PixelSearch.htm#Remarks wrote:If the region to be searched is large and the search is repeated with high frequency, it may consume a lot of CPU time. To alleviate this, keep the size of the area to a minimum.
User avatar
boiler
Posts: 17329
Joined: 21 Dec 2014, 02:44

Re: Is pixelssearch buggy?

11 Jun 2023, 05:38

Another possibility is that you are posting in the wrong section and are actually using AHK v1 and didn’t specify Fast in the Mode parameter. From the v1 documentation:
v1 PixelSearch documentation wrote:Warning: The default slow mode is unusable on most modern systems due to an incompatibility with desktop composition, which causes it to be orders of magnitude slower.
hieveryone
Posts: 43
Joined: 28 Nov 2022, 01:31

Re: Is pixelssearch buggy?

11 Jun 2023, 22:43

@boiler
I was unsure what fast mode vs slowmode was so I left it blank. Ill try that thanks
hieveryone
Posts: 43
Joined: 28 Nov 2022, 01:31

Re: Is pixelssearch buggy?

11 Jun 2023, 22:52

@gregster
I think I might be doing something wrong since im not that great at coding.
The code is

Code: Select all

loop 1000{
PixelSearch, Px, Py, 1035, 440, 1201, 505, 0xffff00, 3,,
if ErrorLevel
mousemove 1114, 463, 10
Send {Click}
mousemove 100,0,10,r    

}
return
^y::exitapp
basically what i want is so whenever the color is is on a certain range,its a button, and so the mouse move to the button and clicks it then moves away.
My understanding is that before when I tried it it wouldnt work so I thought that the pixelsearch executes after clicking once(similar to if you just put one line of code like send::a and click the file it will only send a once and stop) so I thought that I should add a loop.
Im not reallly sure what error lever is but my understanding is that if the colour is detected than the errorlevel will=true and do the command inside.
I know I probably did something wrong because im dumb.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

[Mod action: Moved topic to v1 section since this is v1 code. The main section is for v2.]
User avatar
boiler
Posts: 17329
Joined: 21 Dec 2014, 02:44

Re: Is pixelssearch buggy?  Topic is solved

12 Jun 2023, 03:41

hieveryone wrote: Im not reallly sure what error lever is but my understanding is that if the colour is detected than the errorlevel will=true and do the command inside.
No, that is not correct. The documentation is very clear on this:
ErrorLevel is set to 0 if the color was found in the specified region, 1 if it was not found
And whether it executes any of the commands that follow it has to do with how you set up your conditional statement. They wouldn’t automatically be run when the color is found unless your code is written to do that. You would need to change your if statement to if !ErrorLevel or if not ErrorLevel or if (ErrorLevel = 0).

Only the line immediately after your if statement would be executed conditionally because you haven’t grouped the lines you intended to be together with braces { } to make a block. The way you currently have it, it would be clicking and performing the relative mouse move every time through the loop no matter what the result of the condition is.

Use break or return inside your if block to stop looping once the color is found and you’ve clicked. Otherwise, it will keep clicking while the color is still there.

To loop indefinitely until the color is found, instead of a large number, don’t use a number at all after your loop statement.

You don’t have anything in your code to have it execute the loop more than once after it finds the color, but you don’t want to stay in the loop because it will continue to click as long as the color is there. It’s sounding like you need to follow this loop with another that loops until the color is not found and surround both loops with an outer loop.

You definitely need to add the Fast option to the PixelSearch Mode parameter.

Regarding your forum posts, please use code tags ([code][/code]) when posting code, and please post in the v1 section when you are asking for help with AHK v1, as you are here.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 117 guests