Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Assign a variable value to control?
#1
I am still working with the basics of Quick Macros.
What I am trying to do is assign the variable value to a control.
I used "Accessible Object Actions" dialog to find and allocate the control, it is a text box in a web page.

Code:
Copy      Help
int w=wait(3 WV win("New Tab - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "STATICTEXT" "Search Google or type URL" "" 0x3001 3)
a.Select(3)

str s="Some value"

a.Value=s

I am receiving a error
Error in Macro1: syntax.

I tried also
Code:
Copy      Help
a.SetValue(s)
I get error

Any help :?:
#2
Chrome does not support setting control text in this way. From web browsers, only Internet Explorer supports.
Need to select/focus the control and send keys with key() or paste with paste().

Normally this code could be used, but the Google search field does not respond to Select.
Macro Macro2778
Code:
Copy      Help
int w=wait(3 WV win("New Tab - Google Chrome" "Chrome_WidgetWin_1"))
act w
Acc a.Find(w "STATICTEXT" "Search Google or type URL" "" 0x3001 3)
a.Select(1)
str s="Some value"
key (s)
;or
;paste s

Even Tab key does not select that field.

Then try to enter text in the address bar.
Macro Macro2779
Code:
Copy      Help
int w=win("New Tab - Google Chrome" "Chrome_WidgetWin_1")
act w
Acc a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1[]state=0x100000 0x20000040" 0x1005)
a.SetValue("Some value") ;;works but does not start searching; then I tried DoDefaultAction and Enter, and it worked; also tried Select, but Chrome says 'not implemented'
a.DoDefaultAction
key Y

or

Macro Macro2780
Code:
Copy      Help
int w=win("New Tab - Google Chrome" "Chrome_WidgetWin_1")
act w
key Cl ;;focus address bar
key "Some value" Y
#3
Thank you Gintaras. You give me a lot of ideas.

May I ask for extra bonus?

How to concatenate text? I mean:
Code:
Copy      Help
str s="value 01"
str a="value 02"

str e= "How to concatenate text like this: " & s & a
#4
str e= F"How to concatenate text like this: {s}{a}"


Forum Jump:


Users browsing this thread: 1 Guest(s)