Jump to content

Pixelgetcolor


Recommended Posts

Hello,

i made a simple script (which for me doesent look that simple) and im stuck.

Basically the script should check some pixel and send some keystrokes, all i want is:

to press Tab, send the keystokes untill pixel changes the color, when the color has changed to start over again from Tab.

Here is the code i managed to put together from Autoit help:

Global $Paused
HotKeySet( "{F7}", "_TogglePause" )

Func _TogglePause()
$Paused = Not $Paused
While Not $Paused
Sleep( 250 )
ToolTip( 'Script is "Paused', 0, 0 )
WEnd
EndFunc
    While 1
            If $Paused Then
    Send('{TAB down}')
    Sleep(1000)
    Send('{TAB up}')
    Sleep(1000)
    $test = PixelGetColor(439, 49)
    If $test == 0xF59053 Then
        Do
    Send('{2 down}')
    Sleep(3500)
    Send('{2 up}')
Until @error
Else
        EndIf
        EndIf
        wend

it does what it supossed to do but only once and if i press F7 to pause it it doesent start again when i press F7, i think is something about EndIF.

Thanks in advance, have a nice day.

Edited by MrBlack
Link to comment
Share on other sites

I changed your Script a bit:

Global $Paused
HotKeySet( "{F7}", "_TogglePause" )

While 1
    If $Paused Then
        ToolTip( '', 0, 0 )
        Send('{TAB down}')
        Sleep(1000)
        Send('{TAB up}')
        Sleep(1000)
        $test = PixelGetColor(439, 49)
        If $test == 0xF59053 Then
            Do
                Send('{2 down}')
                Sleep(3500)
                Send('{2 up}')
            Until @error   ;<<<<<<<<<<<<<<<<<<<<<<
        EndIf
    Else
        ToolTip( 'Script is "Paused', 0, 0 )
    EndIf
Wend

Func _TogglePause()
    $Paused = Not $Paused
EndFunc

Please have a look at the line marded with the "<<<<<<". Where should this @error come from?

Maybe you should think again about your condition checks...

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

I changed your Script a bit:

Global $Paused
HotKeySet( "{F7}", "_TogglePause" )

While 1
    If $Paused Then
        ToolTip( '', 0, 0 )
        Send('{TAB down}')
        Sleep(1000)
        Send('{TAB up}')
        Sleep(1000)
        $test = PixelGetColor(439, 49)
        If $test == 0xF59053 Then
            Do
                Send('{2 down}')
                Sleep(3500)
                Send('{2 up}')
            Until @error   ;<<<<<<<<<<<<<<<<<<<<<<
        EndIf
    Else
        ToolTip( 'Script is "Paused', 0, 0 )
    EndIf
Wend

Func _TogglePause()
    $Paused = Not $Paused
EndFunc

Please have a look at the line marded with the "<<<<<<". Where should this @error come from?

Maybe you should think again about your condition checks...

Can u give me a hint about how to set that "Until" the color is other than the one i selected, and after that to start from begining with Tab down...? Edited by MrBlack
Link to comment
Share on other sites

I made another try:

Global $Paused
HotKeySet( "{F7}", "_TogglePause" )

Func _TogglePause()
$Paused = Not $Paused
While Not $Paused
Sleep( 250 )
ToolTip( 'Script is "Paused', 0, 0 )
WEnd
ToolTip( "" )
EndFunc
While 1
    Send('{TAB down}')
    Sleep(1000)
    Send('{TAB up}')
    Sleep(500)
    ;$hp = "0xF59053"
    If PixelGetColor(439, 49) == "0xF59053" Then
        Do
        Send('{2 down}')
        Sleep(1000)
        Send('{2 up}')
        Sleep(3500)

    Until PixelGetColor(439, 49) <> "0xF59053"
        Sleep(200)
        EndIf

    WEnd

Now it loops only the send Tab part.

What im doing wrong?

Is possible that PixelGetColor not to work?

Edited by MrBlack
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...