How to read value of a windows control?

rpaexpress

#1

How do I read value of a windows control? I am working with Dynamics Navision software and want to read a sum value that is in the footer section of a window. I am able to identify the object selector but how do I read the value of the object and assign to a variable?

Thanks in advance.


#2

Hi @peke_robot,

You can do it 2 ways:

1st (if the application allows to copy the value): double-click on the UI control, copy the value using Ctrl-c, save to a variable using Clipboard action

2nd - use a UI selector with getText method in a custom action

Here is the sample custom action, you need to insert the variable name and the selector.

@CustomScriptAction(
    output = 'variable_name'
)

def customScript() {

    variable_name = RString.of($("object_selector").getText())

}

Can we get and set value through window control selector?
#3

Perfect - just the thing I was looking for!


#4

Hello,

I am having trouble passing the object_selector as input variable for the custom script. What is the appropriate format for the input in the 2nd example above?

When the object selector is hard coded into the script this works out fine.

Thanks!


#5

@peke_robot you need to use it the same way as in other recorder actions, with dollar sign and curly brackets.

@CustomScriptAction(
    input =  ['selector'],
    output = 'text'
)

def customScript() {

    text = RString.of($("${selector}").getText())

}


#6

Ah ok – naturally this way!! Thanks!!


#7

Thanks these worked out nicely.

Is there any way to do the reverse ie. use putText(), similarly as with web elements?


#8

There is, you can do it using method setText.
I actually just posted a sample script for that in another topic yesterday :slightly_smiling_face:


#9

Perfect - as this enables much more robust implementations in comparison to keyboard text entry.