Advertisement
Guest User

Untitled

a guest
Dec 7th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;================================================
  2. ; loc/color grabber with timer display
  3. ; Use alt-g to start the grabber.
  4. ; Use the middle mouse button to exit the routine.
  5. ;
  6. ; Note: Because some applications hightlight or
  7. ; change the color of the the item the mouse is hovering
  8. ; over, this this routine grabs two colors from
  9. ; the selected location -- the color displayed
  10. ; when the mouse is on the location and the color
  11. ; that is displayed when the mouse is not on the
  12. ; location. This method allows you to choose which
  13. ; color choice best works for you. The location and
  14. ; colors are copied to the clipboard as a comma-
  15. ; separated value so it can be pasted into a text
  16. ; file or directly into a variable in a script.
  17. ; -----------------------------------------------
  18. !g::    ;<-- grabit
  19. CoordMode, pixel, screen
  20. CoordMode, mouse, screen
  21. CoordMode, tooltip, screen
  22. CheckitTimerInit:
  23. MouseGetPos, oposx, oposy
  24. CheckitTimerInitFlag = 1
  25. gosub CheckItTimer
  26. Return
  27.  
  28. CheckItTimer:
  29. Suspend on
  30. MouseGetPos, mx, my
  31. ;Sleep 200
  32. PixelGetColor, mouseoncolor, %mx%,%my%, Alt RGB
  33. ;Sleep 300
  34. str = %mx%`,%my%`,%mouseoncolor%
  35. Tooltip, %str%`nUse the Mouse MButton to grab,,,3
  36.  
  37. If (GetKeyState("Mbutton", "P"))
  38. {    If (CheckitTimerInitFlag)
  39.      {    CheckItTimerInitFlag = 0
  40.           MouseMove, %oposx%, %oposy%
  41.           PixelGetColor, mouseoffcolor, %mx%,%my%, Alt RGB
  42.           str = %str%`,%mouseoffcolor%
  43.      }
  44.      clipboard = %str%
  45.      ClipWait
  46.      tooltip,,,,3
  47.      Suspend, Off
  48.      Return
  49. }
  50. SetTimer, CheckItTimer, -100
  51. Return
  52.  
  53. ;================================================
  54. ; This routine returns a 1 if the color on the screen matches
  55. ; either of the input colors and a 0 if they do not.  This routine
  56. ; is a companion for the grabber above and expects the same
  57. ; format for the data. (example x,y,color1,color2)
  58. ; -----------------------------------------------
  59. fnCheckLocationandColors(csv)
  60. {     retval = 0
  61.      StringSplit, data_array, csv, `,
  62.      PixelGetColor, thiscolor, %data_array1%, %data_array2%, RGB
  63.      sleep, 200
  64.      If ((thiscolor = %data_array3%) || (thiscolor = %data_array4%))
  65.          retval = 1
  66.      Return retval
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement