Sign in to follow this  
Followers 0
MrBlack

Pixelgetcolor

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Hello Mr. Black,

your script may not leave the While ... Wend loop in your function.

It would be better to display the tooltip in the main loop.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hello Mr. Black,

your script may not leave the While ... Wend loop in your function.

It would be better to display the tooltip in the main loop.

can you be more specific, im not even average user in Autoit?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

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