Jump to content

Recommended Posts

Posted

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

Posted

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"
Posted

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 :)

Posted

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?

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
×
×
  • Create New...