Sign in to follow this  
Followers 0
Wooltown

Detect difference between Ctrl+Tab and Ctrl+Tab+Tab

12 posts in this topic

How can I detect the difference between when I press Ctrl+Tab and Ctrl+Tab+Tab.

I wish to have different events depending on the combination of keys I press.

Share this post


Link to post
Share on other sites



How can I detect the difference between when I press Ctrl+Tab and Ctrl+Tab+Tab.

I wish to have different events depending on the combination of keys I press.

Can you elaborate a bit more? Is this for an AutoIt GUI? HotKey? ...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Wow that was a fast answer !!

Yes, I have a GUI with several Tabs.

If I press Ctrl+Tab, it will change from current to previous Tab.

If I hold down Ctrl and Press Tab numerous of times, it will circle through all Tabs.

Share this post


Link to post
Share on other sites

Wow that was a fast answer !!

Yes, I have a GUI with several Tabs.

If I press Ctrl+Tab, it will change from current to previous Tab.

If I hold down Ctrl and Press Tab numerous of times, it will circle through all Tabs.

That's how I roll ;):D

Have you tried GUISetAccelerators() yet?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Yes, I am using it in my code.

But I don't see how it can detect the difference ?

I will make a go and see if I can get it to work.

Share this post


Link to post
Share on other sites

Short excerpt from my code

Local $l_AccelKeys[2][2] = [["^{TAB}", $l_ChangeTab],["^{TAB}{TAB}", $l_ChangeTab2]]
GUISetAccelerators($l_AccelKeys)

If I put ["^{TAB}", $l_ChangeTab] first it will always use $l_ChangeTab

If I put ["^{TAB}{TAB}", $l_ChangeTab2] first it will always use $l_ChangeTab2

SmOke_N - Do you have any suggestions how I should do to make it work?

Share this post


Link to post
Share on other sites

Short excerpt from my code

Local $l_AccelKeys[2][2] = [["^{TAB}", $l_ChangeTab],["^{TAB}{TAB}", $l_ChangeTab2]]
GUISetAccelerators($l_AccelKeys)

If I put ["^{TAB}", $l_ChangeTab] first it will always use $l_ChangeTab

If I put ["^{TAB}{TAB}", $l_ChangeTab2] first it will always use $l_ChangeTab2

SmOke_N - Do you have any suggestions how I should do to make it work?

Wow... I can't seem to get it to work either.

The only other suggestion is maybe trapping the keys with something like HotKeySet() + a WM_COMMAND registered message.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

One idea I had was to check if Ctrl was continously pressed, checked what _IsPressed does.

Googled about the DLL that is called, tested what "GetAsyncKeyState" returned, but no success.

Is there a possibility to check if a key has been continously pressed ?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

One idea I had was to check if Ctrl was continously pressed, checked what _IsPressed does.

Googled about the DLL that is called, tested what "GetAsyncKeyState" returned, but no success.

Is there a possibility to check if a key has been continously pressed ?

What about something like this?

#include <GuiConstantsEx.au3>
#include <misc.au3>
#include <GuiTab.au3>

$gui = GUICreate("test")
$Tabs = GUICtrlCreateTab(5, 5, 200)
$Tab1 = GUICtrlCreateTabItem("TAB`1")
$Tab2 = GUICtrlCreateTabItem("TAB`2")
$Tab3 = GUICtrlCreateTabItem("TAB`3")
GUICtrlCreateTabItem("")
$accTabChange = GUICtrlCreateDummy()
Local $l_AccelKeys[1][2] = [["^{TAB}", $accTabChange]]
GUISetAccelerators($l_AccelKeys)
$iTabCount = _GUICtrlTab_GetItemCount($Tabs) - 1

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $accTabChange
            While _IsPressed("09"); TAB key is down
                $iCurrentTab = _GUICtrlTab_GetCurSel($Tabs)
                If $iCurrentTab <> $iTabCount Then
                    _GUICtrlTab_SetCurFocus($Tabs, $iCurrentTab + 1)
                Else
                    _GUICtrlTab_SetCurFocus($Tabs, 0)
                EndIf
                Sleep(200);a little pause so the cycling is slowed down
            WEnd
    EndSwitch
WEnd

If you hold down CTRL & TAB it will continuously cycle through the tabs, if you hold down CTRL & press TAB once, it will move to next tab and stop.

Edited by ResNullius

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

OK, but if I press Ctrl+Tab once, I want to go back to the last used tab.

Edited by Wooltown

Share this post


Link to post
Share on other sites

OK, but if I press Ctrl+Tab once, I want to go back to the last used tab.

Is this closer?

#include <GuiConstantsEx.au3>
#include <misc.au3>
#include <GuiTab.au3>

$gui = GUICreate("test")
$Tabs = GUICtrlCreateTab(5, 5, 200)
$Tab1 = GUICtrlCreateTabItem("TAB`1")
$Tab2 = GUICtrlCreateTabItem("TAB`2")
$Tab3 = GUICtrlCreateTabItem("TAB`3")
GUICtrlCreateTabItem("")
$accTabChange = GUICtrlCreateDummy()

Local $l_AccelKeys[1][2] = [["^{TAB}", $accTabChange]]
GUISetAccelerators($l_AccelKeys)

GUISetState()

$iTabCount = _GUICtrlTab_GetItemCount($Tabs) - 1
$iLastUsedTab = _GUICtrlTab_GetCurSel($Tabs)

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $accTabChange
            $iTabPresses = 0
            $iCurrentTab = _GUICtrlTab_GetCurSel($Tabs)
            While _IsPressed("11"); CTRL key is held down
                If _IsPressed("09") Then; TAB key is pressed
                    While _IsPressed("09"); TAB key is held down
                    WEnd
                    $iTabPresses += 1
                    ConsoleWrite("TAB Presses: " & $iTabPresses & @CRLF & @CRLF)
                EndIf
            WEnd
            
            Switch $iTabPresses
                Case 1
                    _GUICtrlTab_SetCurFocus($Tabs, $iLastUsedTab)
                    
                Case 2
                    $iLastUsedTab = $iCurrentTab
                    If $iCurrentTab <> $iTabCount Then
                        _GUICtrlTab_SetCurFocus($Tabs, $iCurrentTab + 1)
                    Else
                        _GUICtrlTab_SetCurFocus($Tabs, 0)
                    EndIf
            EndSwitch
            
            $iCurrentTab = _GUICtrlTab_GetCurSel($Tabs)
            
    EndSwitch

WEnd

Share this post


Link to post
Share on other sites

Unfortunately not, look in SciTe how it works when you have several files open, Ctrl+Tab, back and forth of the two latest files, Hold Down Ctrl and press Tab some times and you will change between all files.

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