turboxikka228

Pixel search macro

3 posts in this topic

Hello guys 

I am newbie at autoit

I trying to make macros which will press some buttons with condition

I have 2 colors (0x33FF33 , 0xFF6666) at same coordinates

if color is 0x33FF33

must be pressed "a" and then "h"

if color is 0xFF6666

must be pressed "s" and then "h"

and loop this

help me please to do this

sorry for my bad eng :)

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

While 1
    If PixelGetColor() = Whatever Then SendKeys("sh")
    If PixelGetColor() = Whatever Then SendKeys("ah")
Wend

Go 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.

;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 by BetaLeaf

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for fast and easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

SoundBoard - Play any song or sound you want at the press of a hotkey.

My GitHub Page: https://github.com/BetaLeaf

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now