GlowTube Posted March 17, 2010 Posted March 17, 2010 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.
vimala Posted March 18, 2010 Posted March 18, 2010 On 3/17/2010 at 10:49 PM, 'GlowTube said: 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'slike 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 itemslike 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 areall located in various tabs, not on the window proper.This forum is massive, but I've tried to search for goodexamples of using ControlClick in my situation. I'm surethe answer relates to which class I should be using - theclass for the main window, the class for the tab window,or the class for the control's window (or similar). Justguessing. Or maybe there's another API I should be tryingrather than ControlClick?The class names are large and appear autogenerated:WindowsForms10.BUTTON.app.0.378734aThanks for any help. Pointing me towards an example wouldbe 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
GlowTube Posted March 18, 2010 Author Posted March 18, 2010 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?
zfisherdrums Posted March 24, 2010 Posted March 24, 2010 (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 March 24, 2010 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
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