Window with multiple tabs

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Rory
Pro Scripter
Posts: 50
Joined: Thu Mar 23, 2006 2:50 pm
Location: Wisconsin

Window with multiple tabs

Post by Rory » Fri Sep 01, 2006 10:08 pm

I have a window with multiple tabs or sheets. How can I set focus to each tab or sheet within a window?
I know that if I use the "Ctrl Tab" it will cycle through the different tabs, but I would like to be sure that a specific tab has the focus before continuing with script execution.

Rory

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 02, 2006 12:19 am

Use the keys to move to a "Home" tab.
Then use Press>Tab*n where "n" is the number of tabs to move forward.

You may also be able to use Image Recognition to make sure you are in correct location, but that will be slower and more complex.
Last edited by Bob Hansen on Sun Sep 03, 2006 6:49 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by pgriffin » Sun Sep 03, 2006 3:18 pm

Also, if the tabs contain different text or controls, you might try to read the text fields or some control from the tab to try to verify if you are on the correct tab.

and I agree with Bob about the ImageRecognitionLibrary....you should learn to use it. this could also be a great spot for that tool.

Rory
Pro Scripter
Posts: 50
Joined: Thu Mar 23, 2006 2:50 pm
Location: Wisconsin

Post by Rory » Tue Sep 05, 2006 4:55 pm

What is the "Image Recognition Library"?

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

Post by pgriffin » Tue Sep 05, 2006 5:10 pm

Look at the Downloads menu here on MJTNET and select Libraries and Plug ins. Download and install it, then we can help you with using it.

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

Post by Marcus Tettmar » Tue Sep 05, 2006 5:18 pm

Here's how you can use the Win32 API to determine which tab is selected. Before running this script open display properties (right click on desktop and select properties) and select a tab:

Code: Select all

//Initialise constants
Let>TCM_GETCURSEL=4875

//Get the handle of the Display Properties Window
GetWindowHandle>Display Properties,hwnd

//Find the handle of the SysTabControl32 (Tab Control) object 
LibFunc>User32,FindWindowExA,tabctrl,hwnd,0,SysTabControl32,

//Send the TCM_GETCURSEL message to retrieve the selected tab index
LibFunc>user32,SendMessageA,tabindex,tabctrl,TCM_GETCURSEL,0,0

//Display the result
MessageModal>Selected Tab: %tabindex%
The tab control of the display properties window is of class "SysTabControl32". Some tab controls have a different class name but should work the same way. To determine the class name use the View System Windows tool (Tools/View System Windows from Macro Scheduler main menu).

To change the tab it is safest to send CTRL-TAB keystrokes. E.g. to select the third tab after opening the form:

SetFocus>Display Properties
Press CTRL
Press Tab * 2
Release CTRL

That sends CTRL-TAB twice so selects the third tab assuming the first (index zero) is currently selected.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Sat Mar 01, 2008 6:43 pm

Is there any other way to select a Tab besides CTRL TAB?

I have this set of tabs that is not accesable until one of them is clicked on.
So if I set focus to the window with tabs and press CTRL TAB nothing happends. But if I manualy click one of the tabs CTRL TAB works.

Thanks!

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

Post by Marcus Tettmar » Sat Mar 01, 2008 6:47 pm

The simplest solution would be image recognition. Capture part of the tab with the image capture tool then use FindImagePos to find its screen position and click on it.

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