#IfWinActive ahk_class #32770 F2:: SendMessage, 0x1304,,, SysTabControl321, ahk_class #32770 ; get total tabs TabCount = %ErrorLevel% ControlGet, WhichTab, Tab, , SysTabControl321 ; get current tab If WhichTab = TabCount ; if current tab equals total tab Control, TabLeft, , SysTabControl321 ; move left Else Control, TabRight, , SysTabControl321 ; move right ;TrayTip, %appname%, TabCount = %TabCount%`nWhichTab = %WhichTab% #IfWinActive
Switching tabs programmatically?
Started by
badmojo
, Nov 22 2007 05:04 AM
3 replies to this topic
i would like the F2 key to switch tabs in a program. also if the last tab is active, it should revert to the 1st tab or move in reverse. how is this possible? i provide the code below..
#1
-
Posted 22 November 2007 - 05:04 AM
I tried with the SendMessage example from the help file:
#IfWinActive,AutoHotkey Help F2:: SendMessage, 0x1304,,, SysTabControl321, [color=red]A[/color] ; get total tabs TabCount = %ErrorLevel% ControlGet, WhichTab, Tab, , SysTabControl321, [color=red]A[/color] ; get current tab If [color=red]WhichTab = %TabCount%[/color] ; if current tab equals total tab SendMessage, 0x1330, 0,, SysTabControl321, [color=red]A[/color] Else SendMessage, 0x1330, %WhichTab%,, SysTabControl321, [color=red]A[/color] TrayTip, %appname%, TabCount = %TabCount%`nWhichTab = %WhichTab% return #IfWinActiveI tested with the help file for AHK, changes in red.
#2
-
Posted 22 November 2007 - 08:23 AM
thanks tonne, it works! but being a dummy, can i know why it works?
#3
-
Posted 23 November 2007 - 03:52 AM
The ", A" part is actually not necessary since #IfWinActive sets the Last Found Window.
To know why
To know why
If WhichTab = %TabCount%works where
If WhichTab = TabCountdoes not, read FAQ: When exactly are variable names enclosed in percent signs?.
#4
-
Posted 23 November 2007 - 06:06 AM