Jump to content

Ever changing ControlID


Recommended Posts

I am struggling with how to adjust my script for a periodically changing ControlID. Once instance of the app window I'm getting info from may have

"[CLASS:WindowsForms10.COMBOBOX.app.0.3a9f0c; INSTANCE:1]"

But a later instance may have:

"[CLASS:WindowsForms10.COMBOBOX.app.0.68373; INSTANCE:1]"

Is there a way to query the form to get the ControlID? I've been using the AutoIt Window Info Tool to get it but if there is a way to do it within the script then perhaps I could substitute it on the fly?

Thanks!

Link to comment
Share on other sites

Assuming you're referring to 'ControlGetText', do you have a working example that would demonstrate how this works? I tried the example in the Help file and, frankly, I just don't get it :-(

Run("notepad.exe")
$var = ControlGetText("[CLASS:Notepad]", "", "Edit1")

Not sure what I'm looking at (I'm still a newbie)

Sorry.

Link to comment
Share on other sites

How about something like this:

$hWin = WinGetHandle("YourWindowTitle", "")
$hCombo = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:1]")

See help file under "Controls" for other advanced specifications you can use.

:mellow:

Edit: Forgot closing square bracket

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Heres a quick example

$gui = GUICreate("GUI");make a gui
$okbutton = GUICtrlCreateButton("OK",10,10);put a button on it wit "OK" text
GUISetState();show the gui

Do
    Sleep(2000)
    ControlClick($gui,"OK","");click the button using the text as identifier
Until GUIGetMsg() = $okbutton

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

How about something like this:

$hWin = WinGetHandle("YourWindowTitle", "")
$hCombo = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:1]")

See help file under "Controls" for other advanced specifications you can use.

:mellow:

Edit: Forgot closing square bracket

So right now I have the following:

# Select 'Remote' from the Onsite/Remote pulldown menu
ControlSend("YourWindowTitle", "", "[CLASS:WindowsForms10.COMBOBOX.app.0.3a9f0c; INSTANCE:1]", "r")

I would change it to?

$hWin = WinGetHandle("YourWindowTitle", "")
$hCombo = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:1]")
ControlSend("YourWindowTitle", "", $hCombo, "r")
Link to comment
Share on other sites

Close. Once you get the window handle you don't have to mess with the title anymore:

ControlSend($hWin, "", $hCombo, "r")

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

PsaltyDS,

I modified my code but it didn't work (no errors but didn't update the form fields).

$hWin = WinGetHandle("Non Deliverable Task", "")
WinWait($hWin, "")
If Not WinActive($hWin, "") Then WinActivate($hWin, "")
WinWaitActive($hWin, "")
$hTitle = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.EDIT\.app\.0.\; INSTANCE:5]")
$hCombo1 = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:1]")
$hCombo4 = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:4]")
$hCombo6 = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:6]")
$hCombo8 = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:8]")
$hCombo7 = ControlGetHandle($hWin, "", "[REGEXPCLASS:WindowsForms10\.COMBOBOX\.app\.0.\; INSTANCE:7]")

# Enter Subject line text
ControlSetText($hWin, "", $hBenefits, "Bulletin Notification")
# Select 'Remote' from the Onsite/Remote pulldown menu
ControlSend($hWin, "", $hCombo1, "r")
# Select 'Bulletin Check' from the Subtask pulldown menu
ControlSend($hWin, "", $hCombo4, "s")
# Select 'Complete' from the Status pulldown menu
ControlSend($hWin, "", $hCombo6, "c")
# Select 'Problem Management' from the Category pulldown menu
ControlSend($hWin, "", $hCombo8, "p")
# Select 'Improve Availability' from the CSF Primary pulldown menu
ControlSend($hWin, "", $hCombo7, "i")

Ideas?

Edited by Andrew
Link to comment
Share on other sites

Check/display the handle returned by ControlGetHandle() to see if that's what failed.

Do you know of a common app we might have that would show this approx type of control for testing?

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...