Keith Posted January 6, 2009 Share Posted January 6, 2009 I needed a quick way to automate running a GUI and ran across AutoIt so I tried it out and it seems to be what I need. I was able to write a script that does most everything so far, but I ran into a problem with one part of the GUI operation where I need to select from a combobox. The select works because it pops up a confirmation dialog, but the script is still blocked on the ControlCommand call, so I cannot send a response to the confirmation dialog and the whole thing hangs. Here's a snippet of the offending call: ; Stop recording ConsoleWrite("select") ControlCommand("DATAQ Instruments Hardware Manager", "", "[CLASS:TComboBox; INSTANCE:1]", "SelectString", "Stop Recording to SD Memory") ConsoleWrite("done") WinWaitActive("", "Do you want to Stop Recording to SD Memory?", 2) Send("y") I see the "select" but not the "done" until I manually click on one of the confirmation dialog buttons. Any idea why ControlCommand is getting blocked? How do I work around this problem? Thanks, Keith. Link to comment Share on other sites More sharing options...
youknowwho4eva Posted January 6, 2009 Share Posted January 6, 2009 appears to me you have it a lil backwards. Here is the example from the help file. Run("notepad.exe") ControlCommand("[CLASS:Notepad]", "", "Edit1", "GetLineCount", "") The third element should be the control id. Giggity Link to comment Share on other sites More sharing options...
Keith Posted January 6, 2009 Author Share Posted January 6, 2009 I don't see how I have it backwards. "DATAQ Instruments Hardware Manager" is the window title and "[CLASS:TComboBox; INSTANCE:1]" is the control ID. Am I missing something? Link to comment Share on other sites More sharing options...
youknowwho4eva Posted January 6, 2009 Share Posted January 6, 2009 Your right. I haven't used control functions in a while. can you put up a screenshot of the window info? Giggity Link to comment Share on other sites More sharing options...
Keith Posted January 6, 2009 Author Share Posted January 6, 2009 Here's what I get for the confirmation pop-up. Note it does not have a title. Thanks for your help. Link to comment Share on other sites More sharing options...
FireFox Posted January 6, 2009 Share Posted January 6, 2009 (edited) @Keith For control functions you should make screenshot of control tab ControlCommand("title",'',"[CLASS:TComboBox; INSTANCE:1]", ....) Cheers, FireFox. Edited January 6, 2009 by FireFox Link to comment Share on other sites More sharing options...
Keith Posted January 6, 2009 Author Share Posted January 6, 2009 (edited) Here's the control tab. Crap -- I can't attach another jpg! Says I don't have enough space. Edited January 6, 2009 by Keith Link to comment Share on other sites More sharing options...
FireFox Posted January 6, 2009 Share Posted January 6, 2009 @Keithgo to your profile > my controls and delete all your attachment files,go to http://imageshack.us/ and upload your picturethen display link here for picture Cheers, FireFox. Link to comment Share on other sites More sharing options...
bo8ster Posted January 6, 2009 Share Posted January 6, 2009 I don't see how I have it backwards. "DATAQ Instruments Hardware Manager" is the window title and "[CLASS:TComboBox; INSTANCE:1]" is the control ID. Am I missing something?A quicker way is just to copy and paste in the contents of the info window. Like this - I use the Summary Tab >>>> Window <<<< Title: AutoIt Forums -> Replying in ControlCommand blocks - Mozilla Firefox Class: MozillaUIWindowClass Position: 1916, -4 Size: 1688, 1058 Style: 0x15CF0000 ExStyle: 0x00000100 Handle: 0x00010698 >>>> Control <<<< Class: MozillaWindowClass Instance: 5 ClassnameNN: MozillaWindowClass5 Advanced (Class): [CLASS:MozillaWindowClass; INSTANCE:5] ID: Text: Position: 0, 114 Size: 1663, 888 ControlClick Coords: 666, 46 Style: 0x56000000 ExStyle: 0x00000000 Handle: 0x001006D0 Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
Keith Posted January 7, 2009 Author Share Posted January 7, 2009 Ah -- much easier! Here it is: >>>> Window <<<< Title: Class: #32770 Position: 515, 471 Size: 257, 107 Style: 0x94C801C5 ExStyle: 0x00010101 Handle: 0x009D03CE >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 6 Text: &Yes Position: 47, 41 Size: 75, 23 ControlClick Coords: 74, 10 Style: 0x50030001 ExStyle: 0x00000004 Handle: 0x004303F2 >>>> Mouse <<<< Position: 639, 551 Cursor ID: 2 Color: 0x000000 >>>> StatusBar <<<< >>>> Visible Text <<<< &Yes &No Do you want to Stop Recording to SD Memory? >>>> Hidden Text <<<< Link to comment Share on other sites More sharing options...
bo8ster Posted January 7, 2009 Share Posted January 7, 2009 Control IDs change, they are dynamic. Do something like this ControlCommand("", "", "CLASS:Button; INSTANCE:1; TEXT:&YES]" ....) or ControlCommand("", "", "Button1" ....). As there is not a windows title it might be hard to get the right window. Try to get a handle to the window first then you can do WinWaitActive("Window Name"); Wait for the aplication become active Const $winHandle = WinGetHandle("Window Name", ""); $handle = ControlGetHandle($winHandle, "", "[CLASS:Button; INSTANCE:1; TEXT:&YES]") ControlCommand($handle, "", "" ...) Hope that is not too complicated. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
Keith Posted January 7, 2009 Author Share Posted January 7, 2009 But I'm not even getting that far. The first ControlCommand that causes the confirmation popup is blocking. My script doesn't get back control until I manually click on one of the confirmation buttons. There's something funny about this popup because it seems to be blocking autoit. What would cause this behavior? Link to comment Share on other sites More sharing options...
bo8ster Posted January 7, 2009 Share Posted January 7, 2009 what command are you trying to send and what control do u want to send it to? Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
Keith Posted January 7, 2009 Author Share Posted January 7, 2009 OK, I'm obviously not communicating well here, so let me try again. Here's my code snippet: ----- ; Stop recording ConsoleWrite("select") ControlCommand("DATAQ Instruments Hardware Manager", "", "[CLASS:TComboBox; INSTANCE:1]", "SelectString", "Stop Recording to SD Memory") ConsoleWrite("done") WinWaitActive("", "Do you want to Stop Recording to SD Memory?", 2) Send("y") ----- As you can see, I'm sending a command to the main window's combobox control and selecting the stop recording. This part of the script works because a confirmation box from the app pops up. But my script does not get back control (I never see "done"). The script is still blocked in ControlCommand! So nothing I do later in the script will be able to acknowledge the confirmation popup and make it go away, rendering my little automation script useless. Link to comment Share on other sites More sharing options...
LarryDalooza Posted January 7, 2009 Share Posted January 7, 2009 ControlCommand uses SendMessage API... perhaps SendMessageTimeout isn't being used... I don't know ... I do not think that TComboBox is a standard control... thus ControlCommand is an improper command to use. You should try using ControlSend() into the control to navigate it. I think... meanwhile, I would drop a line in the Developer area or TRAC (bug area) about the possibility that ControlCommand uses SendMessage and not SendMessageTimeout. Lar. AutoIt has helped make me wealthy 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