Sign in to follow this  
Followers 0
GlowTube

Automating Tab controls in C# ?

4 posts in this topic

I'm an old programmer but a total newbie in AutoIt.

Very impressed with it so far, though.

On to my question:

I'm trying to automate a Winapp a colleague wrote in C#,

running it on Windows XP SP3. I have been successful in

talking to the window using Send(), and also using MouseMove()

and MouseClick(). But I'd really like to use messages to

the controls themselves rather than using all those

absolute mouse coordinates.

So far I've been totally unsuccessful with calls to API's

like ControlFocus(), ControlClick(), and ControlEnable().

My syntax is correct, but nothing happens to the app.

I've used the AutoIt Window Info tool to grab data items

like classes, names, and control ID's, but so far no go.

I've tried to address buttons, text boxes, and check boxes.

Nada.

To add complexity, the controls I'm trying to access are

all located in various tabs, not on the window proper.

This forum is massive, but I've tried to search for good

examples of using ControlClick in my situation. I'm sure

the answer relates to which class I should be using - the

class for the main window, the class for the tab window,

or the class for the control's window (or similar). Just

guessing. Or maybe there's another API I should be trying

rather than ControlClick?

The class names are large and appear autogenerated:

WindowsForms10.BUTTON.app.0.378734a

Thanks for any help. Pointing me towards an example would

be super.

Share this post


Link to post
Share on other sites



I'm an old programmer but a total newbie in AutoIt.

Very impressed with it so far, though.

On to my question:

I'm trying to automate a Winapp a colleague wrote in C#,

running it on Windows XP SP3. I have been successful in

talking to the window using Send(), and also using MouseMove()

and MouseClick(). But I'd really like to use messages to

the controls themselves rather than using all those

absolute mouse coordinates.

So far I've been totally unsuccessful with calls to API's

like ControlFocus(), ControlClick(), and ControlEnable().

My syntax is correct, but nothing happens to the app.

I've used the AutoIt Window Info tool to grab data items

like classes, names, and control ID's, but so far no go.

I've tried to address buttons, text boxes, and check boxes.

Nada.

To add complexity, the controls I'm trying to access are

all located in various tabs, not on the window proper.

This forum is massive, but I've tried to search for good

examples of using ControlClick in my situation. I'm sure

the answer relates to which class I should be using - the

class for the main window, the class for the tab window,

or the class for the control's window (or similar). Just

guessing. Or maybe there's another API I should be trying

rather than ControlClick?

The class names are large and appear autogenerated:

WindowsForms10.BUTTON.app.0.378734a

Thanks for any help. Pointing me towards an example would

be super.

Hello,

Why don't you use _GuiCtrlTabClick(),First Focus the tab using Control focus(),get the Class Name using ControlGetFocus(),Using ControlGethandle() get Handle of Controls,Include header for using _GuiCtrls ,See Autoit Help file

Bye

Share this post


Link to post
Share on other sites

Thanks for the response. I'd like to set the focus to a button that is resident on the first page of a multi-tab control. Here's what I tried:

Local $a
Run ("C:\Programs\xyz\xyz.exe", "")
WinWaitActive("The Program")
$a = ControlFocus ("[NAME:tabPage_Startup]", "", "[CLASS:Button; TEXT:A Large Button]")
if $a <> 1 Then 
MsgBox(0, "Result", "The call failed.")
else
MsgBox(0, "Result", "Success.")
EndIf
Exit

The code above does not work, and always fails. Also note that I can manually set the focus to the button in question by sending the window two {TAB} characters, so the control is indeed reachable.

What am I doing wrong?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hello, GlowTube!

Just a thought:

$a = ControlFocus ("[NAME:tabPage_Startup]", "", "[CLASS:Button; TEXT:A Large Button]")

The line above is interesting to me, inasmuch as it specifies a window search using a .NET name. I would interested to know if you had any success confirming this method of targeting the app.

As a test, what happens when you run this:

WinMove( "[NAME:tabPage_Startup]", "", 1, 1 )

Would this code move the app's window to position 1,1? If so, you've taught me something and I am grateful. If not, perhaps this is the root cause for ControlClick's failure.

Zach...

Edited by zfisherdrums

Share this post


Link to post
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
Sign in to follow this  
Followers 0