How can I get a current button/object caption?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Alexey
Newbie
Posts: 1
Joined: Sat Apr 22, 2006 3:12 pm

How can I get a current button/object caption?

Post by Alexey » Sat Apr 22, 2006 3:15 pm

I loop through buttons on a form using Press Tab.
How can I get a current button caption?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Apr 24, 2006 1:47 pm

First you need to open the screen manually, then open ViewSystemWindows in MacroScheduler. This app shows everything running on your system (basically). Look for the Window Title with which you are working, then look for the items directly beneath the window title. You should see Button, ComboBox, etc...The captions will be listed next to them.

Now for an example. If I want to read (or change) the caption of the 3rd button in the list, it might look like this.

GetControlText>TheWindowTitle,Button,3,MyCaption3

or

SetControlText>TheWindowTitle,Button,3,My 3rd Button

You can use SetControlText to differentiate between identically named buttons within a session. Some programmers are sloppy enough to put multiple OK's or ADD etc....within a single screen. By renaming them you can easily use PushButton> and it will apply to the unique name you apply instead of getting confused about which "OK" you would like to push.

Is this clear as mud?

I use these quite extensively. Please ask again if I need to send some sample code or better explain View System windows.

Skunkworks

pareshbhurke
Newbie
Posts: 7
Joined: Wed Jun 07, 2006 1:41 pm
Location: india
Contact:

Doubt

Post by pareshbhurke » Wed Jun 07, 2006 2:04 pm

Hi there,
I tried the steps you mentioned. I want to update a textbox of the windows application developed using .NET.

In "View Systems Windows" I got textbox description as "3934552 - WindowsForms10.EDIT.app3 "Build 229""
I want to replace text box text "Build 229" with something using SetControlText command. Window title is "Build All"

Can you help me forming the command for the same? :?:

thanks in advance.

Paresh
the rare 1

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 08, 2006 7:23 am

Based on the information you have extracted from View System Windows you should use:

SetWindowText>Build All,WindowsForms10.EDIT.app3,1,NewText

This sets the FIRST instance of a WindowsForms10.EDIT.app3 object. If there is more than one of these classes on the window then you'd need to change the instance number (third parameter).

So if you see more than one instance of WindowsForms10.EDIT.app3 in the tree beneath the "Build All" window in View System Windows you need to determine the instance number. Sometimes the instances are created in reverse so you may need to count UP rather than down. Either way a bit of trial and error is often needed here.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts