Jump to content

Switching tabs using Autoit

Recommended Posts


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 ?


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"


While 1
    If WinExists($WindowTitle, $WindowText) Then ExitLoop
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:


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)


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...