Jump to content
Sign in to follow this  
wittenberg

differentiate a button from a pressed button

Recommended Posts

wittenberg

hello

how i can code it that i want when the button is unpressed program should make a mousemove, click etc......

pixelsearch dont work

have someone a solution?

Posted Image

Share this post


Link to post
Share on other sites
KaFu

Share this post


Link to post
Share on other sites
wittenberg

Use AU3Info tool to obtain control info.

Check controls state with ControlCommand(), command = "IsEnabled", ""

ty im using it i will try it with ControlCommand() Edited by wittenberg

Share this post


Link to post
Share on other sites
wittenberg

ok i try this here

but it cant see if is checked

CODE
WinActivate("Checker v1.0.3")

WinWaitActive("Checker v1.0.3")

ControlFocus("Checker v1.0.3", "", "TButton3")

If(ControlCommand( "Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsChecked", "") == 1) Then

MsgBox(0, "", "one is checked")

ElseIf(ControlCommand( "Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsChecked", "") == 0) Then

MsgBox(0, "", "one is NOT checked")

Else

MsgBox(0,"",ControlCommand( "Checker v1.0.3", "", "TButton3", "IsChecked", ""))

EndIf

have it with isenable

Edited by wittenberg

Share this post


Link to post
Share on other sites
wittenberg

how i could write it should wait for isenable = 1

for example software is running and isenable is = 0 then i activate my au3 file but it dont work then if the button switch to isenable = 1

CODE

$start = ControlCommand( "Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsEnabled", "")

$red = PixelSearch( 727, 57, 780, 65, 0xff0000 )

$black = PixelSearch( 727, 57, 780, 65, 0xffff00 )

$rred = PixelSearch(897, 106, 897, 106, 0x000000 )

while 1

if $start = true AND $red = True Then

MsgBox(0, "", "rot")

ElseIf $start = true AND $black = true Then

MsgBox(0, "", "schwarz")

EndIf

Wend

Edited by wittenberg

Share this post


Link to post
Share on other sites
KaFu

While 1
    $start = ControlCommand("Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsEnabled", "")
    $red = PixelSearch(727, 57, 780, 65, 0xff0000)
    $black = PixelSearch(727, 57, 780, 65, 0xffff00) ; < 0xffff00 = yellow
    $rred = PixelSearch(897, 106, 897, 106, 0x000000) ; < 0x000000 = black
    
    If $start = True And $red = True Then
        MsgBox(0, "", "rot")
    ElseIf $start = True And $black = True Then
        MsgBox(0, "", "schwarz")
    EndIf
    
WEnd

Share this post


Link to post
Share on other sites
wittenberg

While 1
    $start = ControlCommand("Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsEnabled", "")
    $red = PixelSearch(727, 57, 780, 65, 0xff0000)
    $black = PixelSearch(727, 57, 780, 65, 0xffff00) ; < 0xffff00 = yellow
    $rred = PixelSearch(897, 106, 897, 106, 0x000000) ; < 0x000000 = black
    
    If $start = True And $red = True Then
        MsgBox(0, "", "rot")
    ElseIf $start = True And $black = True Then
        MsgBox(0, "", "schwarz")
    EndIf
    
WEnd
thanks dude it works

can i make an if in a if? like in c++

Share this post


Link to post
Share on other sites
KaFu

Yep, not problem to nest statements.

$a = True
$b = True
$c = True
while 1
    $a = not $a
    $b = not $a
    $c = not $b
    if $a Then
        ConsoleWrite("a" & @crlf)
        if $c then
            ConsoleWrite("c" & @crlf)
        endif
    endif
    if $b Then
        ConsoleWrite("b" & @crlf)
        if $c then
            ConsoleWrite("c" & @crlf)
        endif
    endif
wend

Share this post


Link to post
Share on other sites
wittenberg

i tried out but dont works it only checks red and dont work if is black

$red = PixelSearch( 727, 57, 780, 65, 0xff0000 )
$black = PixelSearch( 727, 57, 780, 65, 0xffff00 )
$rred = PixelSearch(897, 106, 897, 106, 0x000000 )
    

while 1 
WinMove("Checker v1.0.3", "", 850, 50)
$start = ControlCommand( "Checker v1.0.3", "", "[CLASS:TButton; INSTANCE:3]", "IsEnabled", "")



if $start = true AND  $red = True Then
MouseClick("left",350,400,1)
sleep(1000)
MouseClick("left",190,430,1)
sleep(20000)
    if $start = true AND  $red = True Then
        MouseClick("left",350,400,2)
        sleep(1000)
        MouseClick("left",190,430,1)
        sleep(1000)
    ElseIf $start = true AND  $black = True Then
        MouseClick("left",887,104,1)
        EndIf
Sleep(1000)
MouseClick("left",887,104,1)

ElseIf $start = true AND $black= true Then
MouseClick("left",410,440,1)
Sleep(1000)
MouseClick("left",190,430,1)
sleep(20000)
    If $start = true AND $black = true Then
            MouseClick("left",410,440,2)
            Sleep(1000)
            MouseClick("left",190,430,1)
            sleep(1000)
        ElseIf $start = true AND $red = true
            MouseClick("left",887,104,1)
            EndIf
MouseClick("left",887,104,1)
EndIf


Wend
Edited by wittenberg

Share this post


Link to post
Share on other sites
KaFu

While 1
$black = PixelSearch(727, 57, 780, 65, 0xffff00) ; < 0xffff00 = yellow
$rred = PixelSearch(897, 106, 897, 106, 0x000000) ; < 0x000000 = black
Your color codes are wrong, use COP to determine the right values ^_^

and additionally I guess the PixelSearch() should be within the loop, or else the search will only be performed one time!

Edited by KaFu

Share this post


Link to post
Share on other sites
wittenberg

Your color codes are wrong, use COP to determine the right values ^_^

and additionally I guess the PixelSearch() should be within the loop, or else the search will only be performed one time!

no thats ok it should be

and rred dont need

ok i try pixelsearch within the loop

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.