Sign in to follow this  
Followers 0
snakebyte

Switching tabs using Autoit

4 posts in this topic

Hi,

I"m using AutoIt3 window spy and it is showing ClassNN of the tab control I'm working on as SysTabControl312.

There are three tabs in this control. The dialog box containing this tab control remembers the last active tab. Using script I want to switch to the second tab. I can send keys (Ctrl + tab) to switch tabs but I when open the dialog I do not know which tab is active. Is there a way to find the active tab? Or is there a way to switch to a particular tab pane ?

I can use mouse click to click relatively on the second tab coordinates, but I'm looking for a more elegant solution. Has any one tried doing this with dllcall - SendMessage ?

Thanks

Share this post


Link to post
Share on other sites



Assuming that you know some unique text on the tab of interest, you can replace "Screen Saver" in the code below with that text.

ControlCommand is better - but in my tests - it will not loop thru all of the tabs. In other words, if you are already to the right of the tab of interest using ControlCommand and TabRight will stop on the right most tab... using Send("^{TAB}") should cyle thru all of the tabs.

AutoItSetOption("SendKeyDelay", 1) ;(milliseconds)
AutoItSetOption("WinWaitDelay", 1) ;(milliseconds)

$WindowTitle = "Display Properties"
$WindowText = "Screen Saver"

WinWait($WindowTitle)

While 1
    If WinExists($WindowTitle, $WindowText) Then ExitLoop
    WinActivate($WindowTitle)
    WinWaitActive($WindowTitle)
    Send("^{TAB}")
    Sleep(20)
WEnd
That code is good when you have several tabs or tabs that can change order... since you only have 3 tabs, then you could just use:

WinWait("title")

If WinExists("title","unique text from left most tab") then ControlCommand and TabRight

If WinExists("title","unique text from right most tab") then ControlCommand and TabLeft

You should now be on the center tab...

...but you could check that with ControlCommand and CurrentTab

(like Larry said)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks, this is what I was looking for.

Share this post


Link to post
Share on other sites

Thanks, this is what I was looking for.

You are welcome and welcome to the AutoIt forums.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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