Sign in to follow this  
Followers 0
NTKBO

ControlClick on non-standard buttons

6 posts in this topic

My script is simply to click one of three buttons on presentation software at a specific time.

(Software is EasyWorship, so I don't expect anyone would be able to test.)

The GUI allows users to select 1 of three buttons to click, and optionally a second. (These scripted as grouped radio controls)

The three buttons are:

"Go Live" (Sends file from Que to second screen)

[CLASS:TsdSpeedButton; INSTANCE:8]

"Logo" (Toggles second screen between a Logo and live output)

[CLASS:TsdSpeedButton; INSTANCE:6]

"Live" (Initiates EasyWorship control of second screen)

[CLASS:TsdSpeedButton; INSTANCE:3]

These buttons do not seem to behave as normal buttons. The Id's change each time it's run.

The time check is an AdlibRegister

When I try it, it WILL click 'Go Live', but not 'Logo', nor 'Live'

I tested the logic flow with message boxes, and the logic seems good.

This is my code for clicking the happy buttons:

Func _PlayAlarm()
    AdlibUnRegister("_CheckAlarm")
    ; 1=Hour 2=Min 3=Sec 4=ButtonRadio 5=SecondEnable 6=SecondRadio 7=CloseEnd 8=OnTop

    MsgBox(1,"aCurrent 4",$aCurrent[4])
    Switch $aCurrent[4]
        Case 1
            WinActivate ($EW)
            ControlClick($EW, "", "TsdSpeedButton8")
        Case 2
            WinActivate ($EW)
            ControlClick($EW, "", "TsdSpeedButton6")
        Case 3
            WinActivate ($EW)
            ControlClick($EW, "", "TsdSpeedButton3")
            ;WinMenuSelectItem ($EW,"Live","Show Live Output")
    EndSwitch
    If GUICtrlRead($Checkbox1) = 1 Then
        Switch $aCurrent[6]
            Case 1
                WinActivate ($EW)
                ControlClick($EW, "Go Live", "TsdSpeedButton8")
            Case 2
                WinActivate ($EW)
                ControlClick($EW, "Logo", "TsdSpeedButton6")
            Case 3
                WinActivate ($EW)
                ControlClick($EW, "Live", "TsdSpeedButton3")
        EndSwitch
    EndIf
    If GUICtrlRead($Checkbox2) = 1 Then
        _WriteIni()
        Exit
    EndIf
EndFunc   ;==>_PlayAlarm

Any help would be appreciated! (Can you see the desperation embedded in the coding? )

Full script is attached.

EasyW Timer.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

First of all, checking the state of a checkbox should look like :

Func _getCheckboxState($controlID)
    Return BitAND(GUICtrlRead($controlID),$GUI_CHECKED)
EndFunc   ;==>_getCheckboxState

Then

]WinActivate($EW)
can be set before the switch, because you want ro activate in every case, right?

ControlClick should work even without activating the window.

Try using the text in ControlClick an the class and maybe let the ControlId empty

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Then

]WinActivate($EW)
can be set before the switch, because you want ro activate in every case, right?

ControlClick should work even without activating the window.

Try using the text in ControlClick an the class and maybe let the ControlId empty

Mega

I think my brain is fried!

The multiple activations were the mark of desperatly trying to make sure the clicks go to the correct window.

Are you saying to place the Class as the "text" sent to ControlClick?

As an example:

ControlClick ( "title", "text", controlID)

ControlClick($EW, "[CLASS:TsdSpeedButton; INSTANCE:8]", "")

($EW= hWndID for EasyWorship)

I thought Class was a controlID based on the help file. More than likely, my mind just didn't properly wrap around your advice.

Share this post


Link to post
Share on other sites

Hi,

try different examples

ControlClick with

ControlClick($EW, "Live", "")
ControlClick($EW, "", "[CLASS:TsdSpeedButton; INSTANCE:8]")

and so on.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

try different examples

ControlClick with

ControlClick($EW, "Live", "")
ControlClick($EW, "", "[CLASS:TsdSpeedButton; INSTANCE:8]")

and so on.

Mega

Thank you so much for your help! The 'Go Live' button seems to work with the command below.

Trying to Click the 'Logo' button (no success) . The Commented out lines were ALL tried to no avail.

Can anyone think of what I may have missed? (Is there a way to for the script to get the Control ID on the fly?)

Func _PlayAlarm()
    AdlibUnRegister("_CheckAlarm")
    WinActivate ($EW)
    Switch $aCurrent[4]
        Case 1
            $iBrowse = ControlClick($EW, "Go Live", "TsdSpeedButton8")
            MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF &"Click of 'Go Live' was" & $iBrowse,5)
        Case 2
            $i = ControlGetHandle ($EW, "Logo", "[CLASSNN:TsdSpeedButton6]" )
            ;$iBrowse = ControlClick($EW, "Logo", $i)
            ;$iBrowse = ControlClick($EW, "", $i)
            ;$iBrowse = ControlClick($EW, $i, "[CLASSNN:TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, $i, "[CLASS:TsdSpeedButton; INSTANCE:6]]")
            ;ClickFailed;$iBrowse = ControlClick($EW, $i, "[TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, $i, "TsdSpeedButton6")
            ;$iBrowse = ControlClick($EW, $i, "")
            ;$iBrowse = ControlClick($EW, "Logo", "[CLASSNN:TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, "Logo", "[CLASS:TsdSpeedButton; INSTANCE:6]")
            ;$iBrowse = ControlClick($EW, "Logo", "TsdSpeedButton6")
            ;ClickFailed;$iBrowse = ControlClick($EW, "Logo", "[TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, "", "[CLASSNN:TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, "", "[CLASS:TsdSpeedButton; INSTANCE:6]")
            ;$iBrowse = ControlClick($EW, "", "TsdSpeedButton6")
            ;ClickFailed;$iBrowse = ControlClick($EW, "", "[TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, "TsdSpeedButton6", "")
            ;$iBrowse = ControlClick($EW, "TsdSpeedButton6", $i)
            ;$iBrowse = ControlClick($EW, "TsdSpeedButton6", "[CLASSNN:TsdSpeedButton6]")
            ;$iBrowse = ControlClick($EW, "TsdSpeedButton6", "[CLASS:TsdSpeedButton; INSTANCE:6]")


            MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF & "Handle of 'Logo':" & $i & @CRLF & "Click of 'Logo' was" & $iBrowse)
        Case 3
            $iBrowse = ControlClick($EW, "Live", "")
            MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF & "Click of 'Live' was" & $iBrowse,5)
    EndSwitch
    If _getCheckboxState($Checkbox1) = 1 Then
        MsgBox(4096,"Debug Flow Box", "Secondary Button Enabled!",1)
        Switch $aCurrent[6]
            Case 1
                $iBrowse = ControlClick($EW, "Go Live", "")
                MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF & "Click of 'Go Live' was" & $iBrowse,5)
            Case 2
                $iBrowse = ControlClick($EW, "Logo", "")
                MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF & "Click of 'Logo' was" & $iBrowse,5)
            Case 3
                $iBrowse = ControlClick($EW, "Live", "")
                MsgBox(4096,"Debug Flow Box", "$aCurrent[4]=" & $aCurrent[4] & @CRLF & "Click of 'Live' was" & $iBrowse,5)
        EndSwitch
    EndIf
    If _getCheckboxState($Checkbox2) = 1 Then
        _WriteIni()
        Exit
    EndIf
EndFunc   ;==>_PlayAlarm
Func _getCheckboxState($controlID)
    Return BitAND(GUICtrlRead($controlID),$GUI_CHECKED)
EndFunc   ;==>_getCheckboxState

I'd pull my hair out if I had any left.

The Handle (returned as $i in the script) is the same hex handle 'Window Info Tool" reports for the 'Logo' button.

Edited by NTKBO

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry, but as I mentioned it is hard when you are not able to test it own your own. :)

Maybe this can help:

HotKeySet('{END}', '_ExitNow') ;END Button

While 1
    ToolTip(_CtrlGetClassNN_ByPos())
    Sleep(20)
WEnd

Func _CtrlGetClassNN_ByPos()
    Local $hWin = WinGetHandle(''), $sCreateArray = '', $sClassList = WinGetClassList($hWin)
    Local $sSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $sReturn = ''
   
    $OptMCM = Opt('MouseCoordMode', 2)
    Local $aMPos = MouseGetPos()
    Opt('MouseCoordMode', $OptMCM)
   
    For $iCount = UBound($sSplitClass) - 1 To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            Local $aCPos = ControlGetPos($hWin, '', $sSplitClass[$iCount] & $nCount)
            If @error Then ExitLoop
            If $aMPos[0] >= $aCPos[0] And $aMPos[0] <= ($aCPos[0] + $aCPos[2]) _
                And $aMPos[1] >= $aCPos[1] And $aMPos[1] <= ($aCPos[1] + $aCPos[3]) Then
                If $sSplitClass[$iCount] <> '' Then Return $sSplitClass[$iCount] & $nCount
            EndIf       
        WEnd
    Next
    Return $sReturn
EndFunc

Func _ExitNow()
    Exit 0
EndFunc

Or have a look under Controls in the helpfile. There are some combinations listed.

Edit: Or just try to ControlSend TAB and then Enter to the handle you've got now.

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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