Jump to content

Recommended Posts

Posted (edited)

I found a great function and I'm surprised that your library doesn't have a similar function. Why not? Sending keyboard presses (CTRL + C) is not convenient/suitable for everyone...

Func UIA_GetAeCurrentPropertyValue($oAe, $PropertyID)
    If Not IsObj($UIA_oUIAutomation) Then Return SetError(1)
    If Not IsObj($oAe) Then Return SetError(2)

    Local $tVal
    $oAe.GetCurrentPropertyValue($PropertyID, $tVal)
    If Not IsArray($tVal) Then Return $tVal
    Local $tStr = $tVal[0]
    For $i = 1 To UBound($tVal) - 1
        $tStr &= "; " & $tVal[$i]
    Next
    Return $tStr
EndFunc   ;==>UIA_GetAeCurrentPropertyValue

https://www.autoitscript.com/forum/topic/211768-automate-combobox-using-ui-automation/

Sorry for my English!!!

Edited by SEKOMD
Posted (edited)

There are many ways to set a value. More or less I added some wrappers and alias functions like

setvalue","settextvalue"
 "setvalue using keys"
 "setValue using clipboard"
 "getvalue"
 "sendkeys", "enterstring", "type", "typetext"

so no specific reason that certain ways are not there.

Edited by junkew
Posted
13 hours ago, junkew said:

"getvalue"

        Case "getValue"
            $obj2ActOn.setfocus()
            Send("^a")
            Sleep(50)
            Send("^c")
            $retValue = ClipGet()

only keyboard keys are used - this is not always convenient/reliable

when selecting text - for example, the input focus is lost..

  • 3 months later...
Posted (edited)

This is in the wrappers with propertyvalue, property and most likely when I wrote the library I had to deal with textboxes from java or other not fully iUIAutomation compatible textboxes and choosed to do it by keyboard commands and have another way to get to the propertys by a property command action.
 

Case "propertyvalue", "property"
            Local $i = _UIA_getPropertyIndex($p1)
            If Not @error <> 0 Then
                $retValue = _UIA_getPropertyValue($obj2ActOn, $UIA_propertiesSupportedArray[$i][1])
            Else
                $retValue = _UIA_getPropertyValue($obj2ActOn, $p1)
            EndIf

and implemented like

Func _UIA_getPropertyValue($UIA_oUIElement, $id)
    Local $tmpValue, $tmpStr, $iProperty

    If Not _UIA_IsElement($UIA_oUIElement) Then
        Return SetError($_UIASTATUS_GeneralError, $_UIASTATUS_GeneralError, "** NO PROPERTYVALUE DUE TO NONEXISTING OBJECT **")
    EndIf

    $UIA_oUIElement.GetCurrentPropertyValue($id, $tmpValue)
    $tmpStr = "" & $tmpValue
    If IsArray($tmpValue) Then
        $tmpStr = ""
        For $iProperty = 0 To UBound($tmpValue) - 1
            $tmpStr = $tmpStr & StringStripWS($tmpValue[$iProperty], $STR_STRIPLEADING + $STR_STRIPTRAILING)
            If $iProperty <> UBound($tmpValue) - 1 Then
                $tmpStr = $tmpStr & ";"
            EndIf
        Next
        Return $tmpStr
    EndIf
    Return SetError($_UIASTATUS_GeneralError, $_UIASTATUS_GeneralError, $tmpStr)
EndFunc   ;==>_UIA_getPropertyValue

And setting your keyboard focus back to begin or end could be done with keys like ctrl+home and ctrl+end. There are to many aspects in remotely controlling different applications and all kinds of different textboxes from different programming languages. Nowadays probably more and more html frontend applications but in 2010-2015 dealing with many windows UX technologies (Visual Basic, Java, Win32 forms, Delphi, HTML, QWidgets, ....)

Edited by junkew

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
×
×
  • Create New...