Pixel Click: Difference between revisions
Jump to navigation
Jump to search
(Syntax Highlighting, code cleanup, and wikify) |
m (+Category:Samples) |
||
Line 1: | Line 1: | ||
[[Category:Samples]] | |||
=Purpose= | =Purpose= | ||
Search for a pixel of a specific colour to click on, loop this process indefinitely, and provide a hotkey to stop the entire thing. | Search for a pixel of a specific colour to click on, loop this process indefinitely, and provide a hotkey to stop the entire thing. |
Latest revision as of 14:38, 14 November 2012
Purpose
Search for a pixel of a specific colour to click on, loop this process indefinitely, and provide a hotkey to stop the entire thing.
Illustrates:
- How to use PixelSearch() to find a specific coloured pixel.
- How to use MouseClick() to click on a specific point.
- How to check the registry to see if the mouse buttons are swapped.
- How to set a HotKey to exit a script.
Demonstration
Global $CheckSwap = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
Global $MousePrimary, $MouseSecondary
If $CheckSwap = 1 Then
$MousePrimary = "right"
$MouseSecondary = "left"
Else
$MousePrimary = "left"
$MouseSecondary = "right"
EndIf
; ************************************************* ;
; Change your settings here ;
; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ;
Global $ExitKey = "{ESC}"
Global $Color = 0xff00ff
Global $Left = 0
Global $Top = 0
Global $Right = 200
Global $Bottom = 200
Global $ClickMouse = $MousePrimary
Global $SearchResult
HotKeySet($ExitKey, '_Exit')
While 1
$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $Color)
If Not @error Then
MouseClick($ClickMouse, $SearchResult[0], $SearchResult[1], 1, 0)
EndIf
WEnd
Func _Exit()
Exit
EndFunc