turboxikka228 Posted August 23, 2015 Share Posted August 23, 2015 Hello guys I am newbie at autoitI trying to make macros which will press some buttons with conditionI have 2 colors (0x33FF33 , 0xFF6666) at same coordinatesif color is 0x33FF33must be pressed "a" and then "h"if color is 0xFF6666must be pressed "s" and then "h"and loop thishelp me please to do thissorry for my bad eng Link to comment Share on other sites More sharing options...
kaisies Posted August 23, 2015 Share Posted August 23, 2015 While 1 If PixelGetColor() = Whatever Then SendKeys("sh") If PixelGetColor() = Whatever Then SendKeys("ah") WendGo from there. Link to comment Share on other sites More sharing options...
EmilyLove Posted August 24, 2015 Share Posted August 24, 2015 (edited) While 1 If PixelGetColor() = Whatever Then SendKeys("sh") If PixelGetColor() = Whatever Then SendKeys("ah") WendGo from there.2 Problems with this script:1. Sendkeys should be Send.2. This example will repeatedly check those pixels. The script will spam whatever keys you have set until they do change colors so the statement becomes false. Try my example. It uses a hotkey to check.expandcollapse popup;Set to 2 if you are using Window Handles ($window# and $Handle#), Otherwise, set to 0. Opt("PixelCoordMode", 2) Opt("MouseCoordMode", 2);if using mouse. ;Refer to https://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm Opt("WinTitleMatchMode", -2) ;Some software requires a delay between keystrokes opt("sendkeydelay",15) opt("sendkeydowndelay",15) ;Defines the hotkey to use. Refer to Send() in the Help File. $Hotkey = "{f7}" HotKeySet($Hotkey, "_CheckPixels") ;Idle here until the hotkey is pressed. While 1 Sleep(1 * 1000);Sleep for a sec, or 1000 milliseconds. WEnd Func _CheckPixels() $window1 = "Notepad" $KeysToSend1 = "Hello World{!}";! is not sent raw, so must be Enclosed with {}. Refer to Send() $x1 = "734" $y1 = "643" $color1 = "0xF0F4F9" $handle1 = WinGetHandle($window1) If PixelGetColor($x1, $y1, $handle1) = $color1 Then Send($KeysToSend1) $window2 = "" $KeysToSend2 = "" $x2 = "" $y2 = "" $color2 = "" $handle2 = WinGetHandle($window2) If PixelGetColor($x2, $y2, $handle2) = $color2 Then Send($KeysToSend2) EndFunc ;==>_CheckPixels Edited August 24, 2015 by BetaLeaf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now