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
Window with multiple tabs
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
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.
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!
Bob
A humble man and PROUD of it!
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.
and I agree with Bob about the ImageRecognitionLibrary....you should learn to use it. this could also be a great spot for that tool.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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:
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.
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%
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact: