AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Switching tabs programmatically?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
badmojo



Joined: 11 Nov 2005
Posts: 150

PostPosted: Thu Nov 22, 2007 5:04 am    Post subject: Switching tabs programmatically? Reply with quote

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..

Code:
#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
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Thu Nov 22, 2007 8:23 am    Post subject: Reply with quote

I tried with the SendMessage example from the help file:
Code:

#IfWinActive,AutoHotkey Help
F2::
SendMessage, 0x1304,,, SysTabControl321, A  ; get total tabs
TabCount = %ErrorLevel%
ControlGet, WhichTab, Tab, , SysTabControl321, A   ; get current tab

If WhichTab = %TabCount%            ; if current tab equals total tab
  SendMessage, 0x1330, 0,, SysTabControl321, A
Else
  SendMessage, 0x1330, %WhichTab%,, SysTabControl321, A
TrayTip, %appname%, TabCount = %TabCount%`nWhichTab = %WhichTab%
return
#IfWinActive

I tested with the help file for AHK, changes in red.
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
badmojo



Joined: 11 Nov 2005
Posts: 150

PostPosted: Fri Nov 23, 2007 3:52 am    Post subject: Reply with quote

thanks tonne, it works! but being a dummy, can i know why it works? Smile
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Fri Nov 23, 2007 6:06 am    Post subject: Reply with quote

The ", A" part is actually not necessary since #IfWinActive sets the Last Found Window.

To know why
Code:
If WhichTab = %TabCount%
works where
Code:
If WhichTab = TabCount
does not, read FAQ: When exactly are variable names enclosed in percent signs?.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group