Pixelsearch cant find color.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
frosse
Posts: 17
Joined: 03 Aug 2020, 12:20

Pixelsearch cant find color.

Post by frosse » 16 Jun 2021, 12:06

Hey i was trying to make script that use F5 key when there is 931305 colour. I made few scripts similar to this and they are working but im trying to make first time with " IF " statement and i need help. Simply, script is not working and should use F5 when there is hex color on screen.

Code: Select all

#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SendMode Input
SetKeyDelay, -1, -1
SetWinDelay, -1
SetControlDelay, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0


SetTimer, Paral, 11

Insert::
pause
return

Paral:

If WinActive, windowname
{
PixelSearch, Px, Py, 1713, 322, 1911, 396, 0x931305, 0, Fast
If ErrorLevel=0
{
 Send, {F5}
  KeyWait, F5
  Sleep, 100
return
 }
 Else
 {
  Sleep, 100
 return
}
}

return
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Pixelsearch cant find color.

Post by mikeyww » 16 Jun 2021, 12:14

If you are not using BGR color format, then you would need to do that or use the RGB option.

Other tips: you can MouseMove to your coordinates to verify that you have the right ones. You can also display some of the colors found there, to compare against your script. You could also add a MsgBox to display the ErrorLevel so that you know whether the search succeeded or failed.

Generally speaking, you would not use KeyWait following a Send command for that key. The KeyWait is usually for manual key presses, though there is an optional for a logical wait. In any case, since the Send issues a down and up sequence, the key is likely to be up when the Send command ends, which means that the KeyWait would have no real effect.

From this script, it is also not so clear what is supposed to happen when your key is sent.
frosse
Posts: 17
Joined: 03 Aug 2020, 12:20

Re: Pixelsearch cant find color.

Post by frosse » 16 Jun 2021, 16:21

mikeyww wrote:
16 Jun 2021, 12:14
If you are not using BGR color format, then you would need to do that or use the RGB option.

Other tips: you can MouseMove to your coordinates to verify that you have the right ones. You can also display some of the colors found there, to compare against your script. You could also add a MsgBox to display the ErrorLevel so that you know whether the search succeeded or failed.

Generally speaking, you would not use KeyWait following a Send command for that key. The KeyWait is usually for manual key presses, though there is an optional for a logical wait. In any case, since the Send issues a down and up sequence, the key is likely to be up when the Send command ends, which means that the KeyWait would have no real effect.

From this script, it is also not so clear what is supposed to happen when your key is sent.
It should just press F5 key after finding pixel in exactly x,y coords, nothing else and if there is no pixel found then just Sleep for 100ms
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Pixelsearch cant find color.

Post by mikeyww » 16 Jun 2021, 16:34

OK. Would start at the top of my suggestions, and work your way down.
Post Reply

Return to “Ask for Help (v1)”