Help with PixelGetColor Conflict

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Xero-Kill
Posts: 8
Joined: 03 Feb 2018, 02:25

Help with PixelGetColor Conflict

06 Jun 2018, 13:48

I am working on a very simple script that is working 99% so far, with only one minor issue.

Code: Select all

NumPad8::Suspend, Toggle
NumPad9::Reload

CoordMode, Pixel, Relative

NumPad2::
 
PixelSearch, TargetX, TargetY, 323, 316, 1047, 599, %color%, 15, Fast
MouseMove, %TargetX%, %TargetY%
Sleep 250
MouseClick
Return

Numpad3::

MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox Bobber color has been captured. %color%
Return

NumPad7::

CoordMode, Pixel, Screen

loop
{
PixelGetColor, thiscolor, 1831, 910
thiscolor := (thiscolor >> 16)
if (thiscolor = 0x33){
	Send, {NumPad2}
	Sleep, 1200
	Send, {NumPad1}	
	}
		
else {
	Sleep, 67
	}
	
}
return
So when I press NumPad3 it gets the pixel color at my cursor and stores it for use in the NumPad 2 hotkey so that when NumPad2 is pressed it seeks out pixels in the defined area. This works just fine unless I reload the script, which I do often, at which time it seems to revert to the PixelGetColor value that is stored hotkey NumPad7 because when NumPad 2 is depressed after a script reload, it always goes to the same green location in my designated area. What I would like is for the stored value of %color% to persist through a reload and should ideally only change when I call for a change to that value with NumPad3. Also, if there is any other general clean up that can be done, that would be appreciated too. I realize that the script is sloppy.

EDIT: Changed the code a little, I used a copy of an older version that didn't work.
brutus_skywalker
Posts: 175
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: Help with PixelGetColor Conflict

07 Jun 2018, 14:21

https://autohotkey.com/docs/commands/IniRead.htm
https://autohotkey.com/docs/commands/IniWrite.htm

Code: Select all

NumPad8::Suspend, Toggle
NumPad9::Reload

CoordMode, Pixel, Relative

NumPad2::
 If !color
   IniRead, color, %A_ScriptName%.ini, SectionColor, KeyColor
 
PixelSearch, TargetX, TargetY, 323, 316, 1047, 599, %color%, 15, Fast
MouseMove, %TargetX%, %TargetY%
Sleep 250
MouseClick
Return

Numpad3::

MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
IniWrite, %color%, %A_ScriptName%.ini, SectionColor, KeyColor
MsgBox Bobber color has been captured. %color%
Return

NumPad7::

CoordMode, Pixel, Screen

loop
{
PixelGetColor, thiscolor, 1831, 910
thiscolor := (thiscolor >> 16)
if (thiscolor = 0x33){
	Send, {NumPad2}
	Sleep, 1200
	Send, {NumPad1}	
	}
		
else {
	Sleep, 67
	}
	
}
return
Also check out https://autohotkey.com/board/topic/3897 ... ix-search/.
Outsourcing Clicks & Presses Since 2004.
Xero-Kill
Posts: 8
Joined: 03 Feb 2018, 02:25

Re: Help with PixelGetColor Conflict

07 Jun 2018, 14:47

Thank you so much! That is perfect! I would have never even considered the iniwrite function. I will read through the whole thing in a bit.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Giresharu, RussF and 193 guests