mamo691 wrote: ↑12 Apr 2024, 20:57So basically can you make it work more accurately with much smaller targets, and also make a option to remove mask because my stupid head cant find the 3-4 lines of code that you mentioned here :
- If you don't need a mask you can comment out the 3-4 lines of code that handle displaying the block windows.
And also help me out with the keybinds please?
I think that the accuracy problem that you were having may have been due to an unpolished feature that I just duct taped in so that I could test with black as the target color. I have removed it so hopefully you won't have an issue with targets near the edge of the screen.
I have also removed the mask windows and a bunch of the other unused code, without the masking windows you won't be able to find multiple targets unless the act of finding them and interacting with them causes them to disappear on their own. From your gif it looks like they don't disappear so you will likely either have to use the mask or use @Chunjee's method if you want to find multiple targets.
As for the key stuff, I'm not really into writing sending key combos for other people or "hotkey" stuff in general, fortunately there are many people on the forum that do help with sending keys and other hotkey related things.
Code: Select all
#SingleInstance, Force
SetBatchLines, -1
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, ToolTip, Screen
;********************
colorList := [ "0xFF0000" ]
;********************
variation := 10
range := 300
rate := 20
currentFinds := 0
maxFinds := 1
;********************
return
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
*ESC::ExitApp
;********************
$g:: ;{ start search
dist := 1
currentFinds:= 0
Gui, t:New, +AlwaysOnTop -DPIScale -Caption +Border +LastFound +ToolWindow +E0x20
WinSet, TransColor, f0f0f0
While( GetKeyState( "g" , "p" ) ){
MouseGetPos, cx, cy
if( cx != lx || cy != ly ){
lx := cx
ly := cy
dist := 1
}
sx := cx - dist
ex := cx + dist
sy := cy - dist
ey := cy + dist
Gui, t:Show, % "x" sx - 1 " y" sy - 1 " w" ex - sx + 2 " h" ey - sy + 2 " NA"
for k , v in colorList {
PixelSearch, tx, ty, sx, sy, ex, ey, % colorList[ k ], % variation, RGB Fast
if( !ErrorLevel ){
++currentFinds
;********************
Action_Function_1( tx , ty ) ;<<<<<----- Call the function that contains the actions to perform if the color is found. Passing the found x and found y values.
;********************
if( currentFinds = maxFinds && maxFinds )
break 2
dist := 1
}
}
if( ( dist += rate ) >= ( range + rate ) )
dist := 1
}
Gui, t:Destroy
KeyWait, g
return
;}
;********************
;********************
;********************
;When the color is found it runs this code.
Action_Function_1( x , y ){ ;<--- You can "pass" as many arguments as you need to. In this example I am just passing the x and y values for where the color was found.
;~ MouseMove, x, y ;example of moving the cursor.
;~ Sleep, 500
;********************
;This is the action you asked for.
send, { Space, Down } ;hold the space key down
sleep, 30 ;wait a fraction of a second
Send, % "{ Click , " x " , " y " }" ;send a click
sleep, 30 ;wait a fraction of a second
send, { Space, Up } ;release the space key.
sleep, 30 ;wait a fraction of a second
;********************
return 1
}
;********************