Jump to content

Recommended Posts

Posted

Hello community!

I need to right click on address control.

Control info -->

>>>> Control <<<<
Class:    ToolbarWindow32
Instance:    3
ClassnameNN:    ToolbarWindow323
Name:    
Advanced (Class):    [CLASS:ToolbarWindow32; INSTANCE:3]
ID:    1001
Text:    Adres: C:\AutoIt SKRYPTY\raporty
Position:    72, 5
Size:    322, 22
ControlClick Coords:    175, 10
Style:    0x5600B84D
ExStyle:    0x00000000
Handle:    0x0000000000061DEC

The problem is, instance number and ID are dynamic.

Script below is working -->

ControlClick("Zapisywanie jako", "", "[CLASS:ToolbarWindow32; TEXT:Adres: C:\AutoIt SKRYPTY\raporty]", "right")

BUT

Text isn't constant neither. Only beginning of the text ("Adres:") is always the same. How to deal with it?

Searched the forum but didn't find an answer...

Posted

ok, I have found workaround in this topic -->

Now my code looks like below (and it's working) -->

$hKontrolka = _ControlGetHandleByText("Zapisywanie jako", "", "ToolbarWindow32", ".*Adres")

    ControlClick("Zapisywanie jako", "", $hKontrolka, "right")

Func _ControlGetHandleByText($vWinTitle, $vWinText, $sCtrlClass, $sTextRegExp)
    Local $hWin, $hCtrl, $sCtrlText, $i = 0

    $hWin = WinGetHandle($vWinTitle, $vWinText)
    If @error Then Return SetError(1, 0, "") ; Window not found

    If Not IsString($sCtrlClass) Then Return SetError(2, 0, "") ; Invalid class string

    While 1
        $i += 1

        $hCtrl = ControlGetHandle($hWin, "", "[CLASS:" & $sCtrlClass & "; INSTANCE:" & $i & "]")
        If @error Then Return SetError(3, 0, "") ; Control not found

        If StringRegExp(ControlGetText($hWin, "", $hCtrl), $sTextRegExp, 0) Then Return $hCtrl ; Match found
    WEnd
EndFunc   ;==>_ControlGetHandleByText

A pity we have no option in autoit to use "REGEXPTEXT:" in control click...

If you have any ideas how to achieve the same result like above in a simpler way, please don't hesitate to post it here.

Regards

Beeria

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...