Sign in to follow this  
Followers 0
ddr4lyfe

Clicking after a different location's color is red

7 posts in this topic

I've been at this thing for a few hours now and I just can't seem to get it right. What I want the script to do is scan a specific region (very small) for red (0xFF0000). And when that section is red, then click somewhere else on the screen. I need to do this with 4 different click locations. This is what I have so far:

While 1
Global $pos, $var, $search
HotKeySet ("s", "Start")
HotKeySet ("o", "CursorPos")
WEnd

Func CursorPos()
    $pos = MouseGetPos()
EndFunc

Func Start()
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 655, 465, 1, 1)
        EndIf
    EndIf
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 745, 465, 1, 1)
        EndIf
    EndIf   
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 835, 465, 1, 1)
        EndIf
    EndIf   
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 925, 465, 1, 1)
        EndIf
    EndIf
EndFunc

What am I doing wrong?

Thanks in advance

Share this post


Link to post
Share on other sites



I've been at this thing for a few hours now and I just can't seem to get it right. What I want the script to do is scan a specific region (very small) for red (0xFF0000). And when that section is red, then click somewhere else on the screen. I need to do this with 4 different click locations. This is what I have so far:

While 1
Global $pos, $var, $search
HotKeySet ("s", "Start")
HotKeySet ("o", "CursorPos")
WEnd

Func CursorPos()
    $pos = MouseGetPos()
EndFunc

Func Start()
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 655, 465, 1, 1)
        EndIf
    EndIf
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 745, 465, 1, 1)
        EndIf
    EndIf   
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 835, 465, 1, 1)
        EndIf
    EndIf   
    $search = PixelSearch (775, 785, 790, 790, 0xFF0000, 0, 2)
    If Not @error Then
        If Hex ($search, 6) = FF0000 Then
            MouseClick ("left", 925, 465, 1, 1)
        EndIf
    EndIf
EndFunc

What am I doing wrong?

Thanks in advance

Put quotes around your hex value "FF0000"

Share this post


Link to post
Share on other sites

Alright, well I'm not getting any errors...but the script won't even click, lol?

Share this post


Link to post
Share on other sites

Alright, well I'm not getting any errors...but the script won't even click, lol?

Are you sure the red your checking is EXACTLY FF0000?

Share this post


Link to post
Share on other sites

Yes, I've used the window information application and the PixelGetColor example in the Online Documentation to find the color.

Share this post


Link to post
Share on other sites

Yes, I've used the window information application and the PixelGetColor example in the Online Documentation to find the color.

You do know pixelsearch returns mouse coords not a decimal value. I recommend using PixelGetColor :)

Share this post


Link to post
Share on other sites

But I thought that PixelGetColor will click only at the location that it finds the specified color. How would I make the mouse click somewhere else?

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
Sign in to follow this  
Followers 0