Jump to content

ControlCommand blocks


Keith
 Share

Recommended Posts

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

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

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

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

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

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

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

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.

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

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...