Skip to content

Commit 49cca01

Browse files
committedJun 2, 2018
add script, styles, readme
1 parent 7cb3c24 commit 49cca01

7 files changed

+242
-2
lines changed
 

‎README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# chrome-ctrl-tab
2-
The way of switching tabs in Chrome browser in the order they were visited before by Ctrl+Tab hotkey.
1+
## Chrome Ctrl+Tab tabs switching for Windows
2+
3+
Unfortunately, there is no easy way to switch between chrome browser tabs in the order they were visited before, also using handy **`Ctrl+Tab`** hotkey. Also, showing the list of all opened tabs in the popup window with ability to navigate them using arrows. Just like we can do that with opened windows in the operation system.
4+
There is a tricky way to do it in Windows using [Quick Tabs](https://chrome.google.com/webstore/detail/quick-tabs/jnjfeinjfmenlddahdjdmgpbokiacbbb) extension and [AutoHotkey](https://autohotkey.com/) automation tool. Let's start!
5+
6+
**1.** Install [Quick Tabs](https://chrome.google.com/webstore/detail/quick-tabs/jnjfeinjfmenlddahdjdmgpbokiacbbb) extension for chrome browser and enable it. You can also find its source code on [github](https://github.com/babyman/quick-tabs-chrome-extension).
7+
8+
**2.** Configure Quick Tabs extension from its options page the next way (chrome-extension://jnjfeinjfmenlddahdjdmgpbokiacbbb/options.html):
9+
10+
- check all display options except badge tab count
11+
12+
![Popup Screenshot](images/quick-tabs-display-options.jpg?raw=true)
13+
14+
- set custom CSS from [style.css](style.css)
15+
16+
![Popup Screenshot](images/quick-tabs-custom-css.jpg?raw=true)
17+
18+
- finally apply changes
19+
20+
**3.** Configure chrome keyboard shortcuts for the extension (chrome://extensions/shortcuts). Chrome does not allow to set `Ctrl+Tab` as a hotkey, so we set `Ctrl+Shift+S` for activating teh extension. Also `Ctrl+↓` for previous tab and `Ctrl+↑` for the next one:
21+
22+
![Popup Screenshot](images/keyboard-shortcuts.jpg?raw=true)
23+
24+
**4.** Install [AutoHotkey](https://autohotkey.com/download/) tool, if you don't have it installed, and run the script [chrome-ctrl+tab.ahk](chrome-ctrl+tab.ahk). Just start the program with path to the script:
25+
26+
`...\AutoHotkey[A32|U32|U64].exe chrome-ctrl+tab.ahk`
27+
28+
It is required to intercept `Ctrl+Tab` hotkey for chrome window and send `Ctrl+Shift+S` instead. Also all the arrows keyboard navigation is scripted there.
29+
30+
-----
31+
32+
As a result you will see something like that when press `Ctrl+Tab` in active chrome window:
33+
34+
![Popup Screenshot](images/example.jpg?raw=true)
35+
36+
Arrows navigation, `Esc`, both `Ctrl+Tab` and `Ctrl+Shift+Tab` are working the way you expected.
37+
38+
If you don't want always start AutoHotkey manually, you can create shortcut with for `...\AutoHotkey[A32|U32|U64].exe chrome-ctrl+tab.ahk` target, add it to startup system folder, forget about it and enjoy.

‎chrome-ctrl+tab.ahk

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#NoEnv ;
2+
SetBatchLines, -1 ; Script will never sleep
3+
ListLines Off ; Omits subsequently-executed lines from the history
4+
#KeyHistory 0 ; Disable key history
5+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability
6+
SetTitleMatchMode 2 ;
7+
SetTitleMatchMode Fast ;
8+
SetKeyDelay, -1, -1 ;
9+
10+
#SingleInstance force ; Skips the dialog box and replaces the old instance automatically
11+
#NoTrayIcon ; Hide the tray icon
12+
#MaxMem 1 ; Maximum memory per variable - 1MB
13+
14+
SetKeyDelay, -1, -1 ; No delay at all will occur after each keystroke sent by Send and ControlSend
15+
SetWinDelay, 0 ; Changed to 0 upon recommendation of documentation
16+
17+
18+
WindowTitle := "Google Chrome"
19+
DeveloperToolsWindowTitle := "Developer Tools"
20+
TicksToOpenPopup := 300
21+
OpenedTickCount := 0
22+
NeedToMovePrev := false
23+
24+
25+
HasPopupWindowSize()
26+
{
27+
Width := 0
28+
WinGetPos, , , Width, , A
29+
return Width between 430 and 440
30+
}
31+
32+
33+
#IfWinActive ahk_exe Chrome.exe
34+
35+
; Ctrl+Tab
36+
^Tab::
37+
{
38+
NeedToMovePrev := false
39+
40+
IfWinActive % WindowTitle
41+
{
42+
Send ^+{s}
43+
OpenedTickCount := A_TickCount
44+
}
45+
else
46+
{
47+
Send ^{Down}
48+
}
49+
50+
return
51+
}
52+
53+
54+
; Ctrl+Shift+Tab
55+
^+Tab::
56+
{
57+
IfWinActive % WindowTitle
58+
{
59+
Send ^+{s}
60+
NeedToMovePrev := true
61+
OpenedTickCount := A_TickCount
62+
}
63+
else
64+
{
65+
NeedToMovePrev := false
66+
Send ^{Up}
67+
}
68+
69+
return
70+
}
71+
72+
73+
; Ctrl keyup
74+
~Ctrl Up::
75+
{
76+
TicksToSleep := TicksToOpenPopup + OpenedTickCount - A_TickCount
77+
78+
if (TicksToSleep > 0)
79+
{
80+
Sleep TicksToSleep
81+
}
82+
83+
if WinActive("ahk_class Chrome_WidgetWin_1") and !WinActive(WindowTitle) and !WinActive(DeveloperToolsWindowTitle) and HasPopupWindowSize()
84+
{
85+
if NeedToMovePrev
86+
{
87+
Send ^{Up}
88+
Sleep 50
89+
}
90+
91+
Send {Enter}
92+
}
93+
94+
return
95+
}
96+
97+
#IfWinActive
98+
99+
100+
#If WinActive("ahk_exe Chrome.exe") and WinActive("ahk_class Chrome_WidgetWin_1") and !WinActive(WindowTitle) and !WinActive(DeveloperToolsWindowTitle) and HasPopupWindowSize()
101+
102+
; Ctrl+Right, Ctrl+Shift+Right, Ctrl+Shift+Down
103+
^Right::
104+
^+Right::
105+
^+Down::
106+
{
107+
NeedToMovePrev := false
108+
Send ^{Down}
109+
return
110+
}
111+
112+
113+
; Ctrl+Left, Ctrl+Shift+Left, Ctrl+Shift+Up
114+
^Left::
115+
^+Left::
116+
^+Up::
117+
{
118+
NeedToMovePrev := false
119+
Send ^{Up}
120+
return
121+
}
122+
123+
; Ctrl+Esc
124+
^Esc::
125+
{
126+
Send {Esc}
127+
return
128+
}
129+
130+
#If

‎images/example.jpg

25.9 KB
Loading

‎images/keyboard-shortcuts.jpg

17.7 KB
Loading

‎images/quick-tabs-custom-css.jpg

35.7 KB
Loading

‎images/quick-tabs-display-options.jpg

10.3 KB
Loading

‎style.css

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
body {
2+
width: 420px;
3+
user-select: none;
4+
background-color: #fff;
5+
font-family: "Segoe UI", "Helvetica Neue", Helvetica, sans-serif;
6+
}
7+
8+
.tools, #tools,
9+
.qs_wrapper, #searchbox,
10+
div.open:hover div.close,
11+
div.withfocus.open div.close {
12+
display: none;
13+
}
14+
15+
16+
.item {
17+
padding: 3px 0;
18+
cursor: default;
19+
transition: all .1s linear;
20+
border-bottom: 1px solid #f2f2f2;
21+
}
22+
23+
.item:last-child {
24+
border-bottom: none;
25+
}
26+
27+
div.title {
28+
color: #000;
29+
background-color: transparent;
30+
}
31+
32+
div.url {
33+
color: #c0c0c0;
34+
background-color: transparent;
35+
}
36+
37+
div.tabimage img {
38+
padding: 0;
39+
margin: 7px 10px 0 10px;
40+
background-color: transparent;
41+
}
42+
43+
44+
.withfocus {
45+
background-color: #e0e0e0;
46+
}
47+
48+
.withfocus div.title {
49+
color: #000;
50+
background-color: transparent;
51+
}
52+
53+
.withfocus div.url {
54+
color: #a0a0a0;
55+
background-color: transparent;
56+
}
57+
58+
59+
.item:hover {
60+
background-color: #f0f0f0;
61+
}
62+
63+
.item:hover div.title {
64+
color: #000;
65+
background-color: transparent;
66+
}
67+
68+
.item:hover div.url {
69+
color: #c0c0c0;
70+
background-color: transparent;
71+
}
72+
73+
74+
.piu-piu-piu { }

0 commit comments

Comments
 (0)
Please sign in to comment.