Andrew Posted June 11, 2010 Share Posted June 11, 2010 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 More sharing options...
JohnOne Posted June 11, 2010 Share Posted June 11, 2010 you could try interacting with it using the text of the control if you can get that. 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 More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 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 More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 Sorry, my bad. Only half of the form has control text; the rest are blank. If I know the control text to part of the form, can I get the control id from it? Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2010 Share Posted June 11, 2010 (edited) 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. Edit: Forgot closing square bracket Edited June 11, 2010 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 More sharing options...
JohnOne Posted June 11, 2010 Share Posted June 11, 2010 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 More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 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. 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 More sharing options...
PsaltyDS Posted June 11, 2010 Share Posted June 11, 2010 Close. Once you get the window handle you don't have to mess with the title anymore: ControlSend($hWin, "", $hCombo, "r") 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 More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 Excellent! I will try it out next week and let you know! Thanks PsaltyDS Link to comment Share on other sites More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 (edited) 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 June 11, 2010 by Andrew Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2010 Share Posted June 11, 2010 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? 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 More sharing options...
Andrew Posted June 11, 2010 Author Share Posted June 11, 2010 Taking your "\" backslashes out took care of the problem. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now