how to do this : mouse or cursor detects color, for example (color
Code: Select all
Sorry for my bad Text: D
Code: Select all
Code: Select all
#SingleInstance, Force
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
DetectHiddenWindows, On
return
esc:: ;<- use the esc key to end the script
suspend permit
MsgBox, 0x1000, Line%A_LineNumber%, End of script, 3
exitapp
^!s:: ;<- use control-alt-s to check the color
suspend on
someX := 0 ;x location on screen where you want to check
somey := 0 ;y location on screen where you want to check
someOtherColor = 0x000000 ;the color you're looking for in RGB format
pixelGetColor, somecolor, %someX%, %someY%, RGB ;check the color on the screen
sleep 200
isMatch := someColor = someOtherColor ? "matches" : "does not match"
MsgBox,0x1000, Line%A_LineNumber%, The color at %someX%`,%someY% is %someColor%,`n%someColor% %isMatch% %someOtherColor%
if (somecolor = someOtherColor) ;see if the colors match
{ click, %someX%, %someY% ;if they do then click the left mouse button
sleep 100
}
suspend off
return ;end the routing
Code: Select all
#SingleInstance, Force
SendMode, Event
settitlematchmode,2 ;<- so you don't need the whole nopad window title
detecthiddenwindows On ;<- so the script can detect the target window even if hidden
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SplitPath, A_ScriptFullPath, ofname, ofdir, ofext, ofnamene, odrv
SetWorkingDir, %ofdir%
inifile = %ofnamene%.ini
;; uses windows notepad for testing
;tstwin := "Untitled"
;ifwinnotexist, %tstwin%
;{ run, Notepad.exe
;}
;WinActivate, %tstwin%
return
esc::
suspend permit
MsgBox, 0x1000, Line%A_LineNumber%, End of script, 3
exitapp
!m:: ;Center mouse in active window
; note this does not work on text windows because they
; essentially have no "center" until full of text
CenterMouse: ;<- center the mouse in the active window
Suspend Permit
WinGet, vWinID, ID, A
rawID := vWinID
vwinid = ahk_id %vWinID%
WinGetActiveStats, vWinTitle, vWinWidth, vWinHeight, vWinX, vWinY
mx := (vWinX + (vWinWidth // 2))
my := (vWinY + (vwinHeight // 2))
MouseMove, %mx%, %my%
sleep 200
return
;-----------------------------------------------
;Mouse Color Setup Routine
; prompt user to place mouse where they want a color check
; once user hits the ok button. grab the location and color
; write the location and color to an ini file
; build a routine to read the color and location from the ini file
; build a routine that will check the location for the desired color and
; tell the user if it's there or not
;
+!u:: ;retrieve color from screen at mouse position and save
retval := fntkColorGrab()
;msgBox, 0x1000, Line%A_LineNumber%, retval = %retval%
stringsplit, colordat, retval, " "
gosub, writeini
run, %inifile%
return
+!c:: ;retrieve static color from file and check
gosub, readini
found := fnCheckColorAt(xloc,yloc,searchcolor)
foundstring := found ? "was found" : "was not found"
msgbox, Color %searchcolor% %foundstring% at %xloc%`,%yloc% on screen
return
fntkColorGrab()
{ MouseGetPos, fgmx, fgmy
pixelGetColor, fgColor, %fgmx%, %fgmy%, Alt Slow RGB
retval = %fgmx% %fgmy% %fgcolor%
;msgBox, 0x1000, Line%A_LineNumber%, coords=%fgmx%`,%fgmy% color=%fgcolor%
return (retval)
}
writeini:
iniWrite,%retval%, %inifile%, Setup, ColorString
IniWrite,%colordat1%, %inifile%, Setup, LocX
iniwrite,%colordat2%, %inifile%, Setup, LocY
iniWrite,%colordat3%, %inifile%, Setup, colorcheck
return
readini:
iniRead,colorstring, %inifile%, Setup, colorstring, none
iniRead,xloc, %inifile%, Setup, LocX, none
iniread,yloc, %inifile%, Setup, LocY, none
iniRead,searchcolor, %inifile%, Setup, colorcheck, none
return
fnCheckColorAt(x,y,tstcolor)
{ PixelGetColor, somecolor, %x%, %y%, RGB
if (somecolor = tstcolor)
return 1
return 0
}
Users browsing this forum: No registered users and 45 guests