Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;================================================
- ; loc/color grabber with timer display
- ; Use alt-g to start the grabber.
- ; Use the middle mouse button to exit the routine.
- ;
- ; Note: Because some applications hightlight or
- ; change the color of the the item the mouse is hovering
- ; over, this this routine grabs two colors from
- ; the selected location -- the color displayed
- ; when the mouse is on the location and the color
- ; that is displayed when the mouse is not on the
- ; location. This method allows you to choose which
- ; color choice best works for you. The location and
- ; colors are copied to the clipboard as a comma-
- ; separated value so it can be pasted into a text
- ; file or directly into a variable in a script.
- ; -----------------------------------------------
- !g:: ;<-- grabit
- CoordMode, pixel, screen
- CoordMode, mouse, screen
- CoordMode, tooltip, screen
- CheckitTimerInit:
- MouseGetPos, oposx, oposy
- CheckitTimerInitFlag = 1
- gosub CheckItTimer
- Return
- CheckItTimer:
- Suspend on
- MouseGetPos, mx, my
- ;Sleep 200
- PixelGetColor, mouseoncolor, %mx%,%my%, Alt RGB
- ;Sleep 300
- str = %mx%`,%my%`,%mouseoncolor%
- Tooltip, %str%`nUse the Mouse MButton to grab,,,3
- If (GetKeyState("Mbutton", "P"))
- { If (CheckitTimerInitFlag)
- { CheckItTimerInitFlag = 0
- MouseMove, %oposx%, %oposy%
- PixelGetColor, mouseoffcolor, %mx%,%my%, Alt RGB
- str = %str%`,%mouseoffcolor%
- }
- clipboard = %str%
- ClipWait
- tooltip,,,,3
- Suspend, Off
- Return
- }
- SetTimer, CheckItTimer, -100
- Return
- ;================================================
- ; This routine returns a 1 if the color on the screen matches
- ; either of the input colors and a 0 if they do not. This routine
- ; is a companion for the grabber above and expects the same
- ; format for the data. (example x,y,color1,color2)
- ; -----------------------------------------------
- fnCheckLocationandColors(csv)
- { retval = 0
- StringSplit, data_array, csv, `,
- PixelGetColor, thiscolor, %data_array1%, %data_array2%, RGB
- sleep, 200
- If ((thiscolor = %data_array3%) || (thiscolor = %data_array4%))
- retval = 1
- Return retval
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement