Jump to content

Replace controlID TEXT with variable


Recommended Posts

I use the function ControlClick with the controlID = TEXT. To simplify my script I want to replace the TEXT with a variable but the script returns 0 Failure.

Example:

$pos = 5

Dim $ButtonArray[6] = ["Graph", "Channel", "Summary", "Results", "Ref", "Info"]

$MyButton = $ButtonArray[$pos];select the 6th element of the array.

MsgBox(4096, "Array Value", $MyButton, 10); debugging

Sleep (2000)

$ButtonResult = ControlClick("MyApplication", "", "[CLASS:WindowsForms10.window.8.app.0.33c0d9d; TEXT:$MyButton]"); suppose to click on Info button.

MsgBox(4096, "CtrlClick Return Value", $ButtonResult, 10);debugging

Note: when I replace the variable with the actual text, it works. Is it a newbie syntax problem???

Thanks for your help!

Link to comment
Share on other sites

; Example 1
Opt("ExpandVarStrings", 1)

$pos = 5
Dim $ButtonArray[6] = ["Graph", "Channel", "Summary", "Results", "Ref", "Info"]
$MyButton = $ButtonArray[$pos];select the 6th element of the array.
MsgBox(4096, "Array Value", $MyButton, 10); debugging
Sleep (2000)
$ButtonResult = ControlClick("MyApplication", "", "[CLASS:WindowsForms10.window.8.app.0.33c0d9d; TEXT:$MyButton$]"); suppose to click on Info button.
MsgBox(4096, "CtrlClick Return Value", $ButtonResult, 10);debugging

; Example 2
$pos = 5
Dim $ButtonArray[6] = ["Graph", "Channel", "Summary", "Results", "Ref", "Info"]
$MyButton = $ButtonArray[$pos];select the 6th element of the array.
MsgBox(4096, "Array Value", $MyButton, 10); debugging
Sleep (2000)
$ButtonResult = ControlClick("MyApplication", "", "[CLASS:WindowsForms10.window.8.app.0.33c0d9d; TEXT:" & $MyButton & "]"); suppose to click on Info button.
MsgBox(4096, "CtrlClick Return Value", $ButtonResult, 10);debugging

Link to comment
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
 Share

  • Recently Browsing   0 members

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