Help with pixel color script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Richy-Rich
Posts: 2
Joined: 01 Oct 2023, 16:52

Help with pixel color script

01 Oct 2023, 17:04

I have this code working to press ctrl+F4 on a specific pixel color/coord when I press F1 but I notice that it only waits for a small amount of time before it deactivates and doesnt search for the color anymore. Does anyone know how to let it continuously search for the color until I tell it to stop searching or it detects the color?

Also I would like to have it loop about 25 times if anyone could help me with that as well thanks

P.S. the mousemove is only for me to see that the script activated its not a function for it to work.

Code: Select all

f1::
mousemove 1870, 1000, 0
Stop:= 0
i:=0
While Stop = 0
  {
    PixelSearch,ax,ay,1870,1000,1870,1000,0x333333,25,Fast RGB
    If ErrorLevel = 0
         {
	   ~ctrl::SendInput ^{F4}
	   ~ctrl Up::SendInput !{F4}
	}
  }
return
[Mod edit: [code][/code] tags added. Please use them yourself in future posts.]
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Help with pixel color script

01 Oct 2023, 17:47

Code: Select all

f1::
mousemove 1870, 1000, 0
Stop:= 0
i:=0
While (Stop = 0)
  {
    PixelSearch,ax,ay,1870,1000,1870,1000,0x333333,25,Fast RGB
    If ErrorLevel = 0
	{
	   SendInput ^{F4}
	   SendInput !{F4}
	   Stop := 1
	}
  } until (A_Index = 25)
return
You can limit the looping by setting the var stop to 1 and using until A_Index = 25
Also note in your code you are defining hotkeys when the pixel color is found. That is not how you set hotkeys. Since you want to send those keys I removed the hotkey assignments and only sending the keys.
Richy-Rich
Posts: 2
Joined: 01 Oct 2023, 16:52

Re: Help with pixel color script

01 Oct 2023, 18:05

Xtra wrote:
01 Oct 2023, 17:47

Code: Select all

f1::
mousemove 1870, 1000, 0
Stop:= 0
i:=0
While (Stop = 0)
  {
    PixelSearch,ax,ay,1870,1000,1870,1000,0x333333,25,Fast RGB
    If ErrorLevel = 0
	{
	   SendInput ^{F4}
	   SendInput !{F4}
	   Stop := 1
	}
  } until (A_Index = 25)
return
You can limit the looping by setting the var stop to 1 and using until A_Index = 25
Also note in your code you are defining hotkeys when the pixel color is found. That is not how you set hotkeys. Since you want to send those keys I removed the hotkey assignments and only sending the keys.
Attachments
Screenshot (129).png
Screenshot (129).png (7.7 KiB) Viewed 248 times
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Help with pixel color script

01 Oct 2023, 21:12

Code: Select all

f1::
mousemove 1870, 1000, 0
Stop:= 0
Loop, 25
{
    PixelSearch,ax,ay,1870,1000,1870,1000,0x333333,25,Fast RGB
    If (ErrorLevel = 0)
	{
	   SendInput ^{F4}
	   SendInput !{F4}
	   Stop := 1
	}
} until (Stop)
return
or

Code: Select all

f1::
mousemove 1870, 1000, 0
Loop, 25
{
    PixelSearch,ax,ay,1870,1000,1870,1000,0x333333,25,Fast RGB
    If (ErrorLevel = 0)
	{
	   SendInput ^{F4}
	   SendInput !{F4}
	   break
	}
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: bobstoner289, Google [Bot], peter_ahk and 322 guests