Guest User

color clicker

a guest
Jul 19th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; color clicker - select point on screen which will be clicked once it becomes the color it was when
  2. ; you selected it
  3.  
  4. ;global Points := Object()
  5. ResetPoints()
  6.  
  7. F9::AddCurrentPoint(Points)
  8. F10::ResetPoints()
  9. F11::Run()
  10.  
  11. ResetPoints() {
  12.     global Points := Object()
  13.     #Persistent
  14.     ToolTip, "All points reset"
  15.     SetTimer, RemoveToolTip, 1000
  16. }
  17.  
  18. AddPoint(arr, x, y, col) {  
  19.     tt := Object()
  20.     tt.Push(x, y, col)
  21.     arr.Push(tt)
  22. }
  23.  
  24. AddCurrentPoint(ar) {
  25.  
  26.     MouseGetPos, MouseX, MouseY
  27.     PixelGetColor, col, MouseX, MouseY
  28.     AddPoint(ar, MouseX, MouseY, col)
  29.     tt := ar.Length()
  30.  
  31.     #Persistent
  32.     ToolTip, %tt% %MouseX% %MouseY% %col%
  33.     SetTimer, RemoveToolTip, 1000
  34. }
  35.  
  36. CheckPoint(ar, i) {
  37.     ; CheckPoint(ar, ar.Length())
  38.     x := ar[i, 1]
  39.     y := ar[i, 2]
  40.     col := ar[i, 3]
  41.     PixelGetColor, newcol, x, y
  42.  
  43.     return (newcol == col)
  44. }
  45.  
  46. ProcessAllPoints(ar) {
  47.     i := 1
  48.     #Persistent
  49.     t := ar.Length()
  50.     ;ToolTip, %t%
  51.     ;SetTimer, RemoveToolTip, 500
  52.  
  53.     loop %t% {
  54.        
  55.         GetKeyState, RB, RButton
  56.         GetKeyState, LB, LButton
  57.         if CheckPoint(ar, i) {
  58.             ToolTip, Ready %i%
  59.             SetTimer, RemoveToolTip, 500
  60.             if (RB <> "D") and (LB <> "D") {
  61.                 MouseGetPos, OutputVarX, OutputVarY, OutputVarWin
  62.                 MouseClick, left, ar[i, 1],  ar[i, 2], 2, 0
  63.                 MouseMove, OutputVarX, OutputVarY, 0
  64.                 Sleep, 200
  65.             }
  66.         }
  67.         i := i + 1
  68.     }
  69. }
  70.  
  71. RemoveToolTip() {
  72.     SetTimer, RemoveToolTip, Off
  73.     ToolTip
  74. }
  75.  
  76. Run(Interval=1000){
  77.     global Points
  78.     static Toggler
  79.     Toggler := !Toggler
  80.     TPer := Toggler ? Interval : "off"
  81.     SetTimer, ClickClick, %TPer%
  82.  
  83.     ;ToolTip, Multiline`nTooltip, 0, 0
  84.  
  85.     ; To have a ToolTip disappear after a certain amount of time
  86.     ; without having to use Sleep (which stops the current thread):
  87.     #Persistent
  88.     ToolTip, %OutputVarX% %OutputVarY% %LB% %RB% Toggler: %Toggler%
  89.     SetTimer, RemoveToolTip, 1000
  90.     return
  91.  
  92.  
  93.     ClickClick:
  94.        
  95.         ProcessAllPoints(Points)
  96.         Sleep, 100
  97.         return
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment