Jump to content

Clicking after a different location's color is red


 Share

Recommended Posts

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

Link to comment
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"
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...