Compare commits
11 Commits
d7bf2bb1b6
...
main
Author | SHA1 | Date | |
---|---|---|---|
661ee354e9 | |||
c5c5b53ddd | |||
a11ec34202 | |||
446bd36b91 | |||
778b793b34 | |||
bb3a3a81f3 | |||
b37052f3ea | |||
6acdfcd904 | |||
4a887dd1e2 | |||
0bb28b6f9a | |||
b35c16cdeb |
87
main.ahk
87
main.ahk
@ -1,4 +1,7 @@
|
|||||||
DownloadYoutubeVideo(dataType)
|
; Replace a common TODO type
|
||||||
|
::TOOD::TODO
|
||||||
|
|
||||||
|
DownloadYoutubeVideo(dataType)
|
||||||
{
|
{
|
||||||
; Note: This callback is usually fired twice when copying for some reason
|
; Note: This callback is usually fired twice when copying for some reason
|
||||||
; so we use "RunWait" below to make sure we only launch youtube-dl once.
|
; so we use "RunWait" below to make sure we only launch youtube-dl once.
|
||||||
@ -16,13 +19,35 @@
|
|||||||
}
|
}
|
||||||
OnClipboardChange DownloadYoutubeVideo
|
OnClipboardChange DownloadYoutubeVideo
|
||||||
|
|
||||||
|
; Focus the web browser if there is one open.
|
||||||
|
^!+#b:: ; Capslock+b to open a browser
|
||||||
|
{
|
||||||
|
browserID := WinExist("ahk_exe firefox.exe")
|
||||||
|
|
||||||
|
if (browserID) {
|
||||||
|
WinActivate(browserID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Focus VS Code if there is one open.
|
||||||
|
; This may not work properly if there are more than one instances of VS Code running.
|
||||||
|
^!+#v:: ; Capslock+v to open a browser
|
||||||
|
{
|
||||||
|
vscodeID := WinExist("ahk_exe code.exe")
|
||||||
|
|
||||||
|
if (vscodeID) {
|
||||||
|
WinActivate(vscodeID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
; Open a terminal over the currently focused VS Code window.
|
; Open a terminal over the currently focused VS Code window.
|
||||||
; If there is an open Windows Terminal, use that, otherwise create a new one.
|
; If there is an open Windows Terminal, use that, otherwise create a new one.
|
||||||
; Pressing the hotkey again goes back to the previously focused window.
|
; Pressing the hotkey again goes back to the previously focused window.
|
||||||
|
|
||||||
prevWindow := 0
|
prevWindow := 0
|
||||||
CapsLock & t:: ; Capslock+t to open a terminal
|
^!+#t:: ; Capslock+t to open a terminal
|
||||||
{
|
{
|
||||||
global prevWindow
|
global prevWindow
|
||||||
|
|
||||||
@ -47,31 +72,46 @@ CapsLock & t:: ; Capslock+t to open a terminal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Focus Discord if there is one open.
|
||||||
|
^!+#d:: ; Capslock+d to open a browser
|
||||||
|
{
|
||||||
|
discordID := WinExist("Discord")
|
||||||
|
|
||||||
|
if (discordID) {
|
||||||
|
WinActivate(discordID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
; Arrange windows into my preferred location, based on what monitors are connected.
|
; Arrange windows into my preferred location, based on what monitors are connected.
|
||||||
monitorConfigurations := Map(
|
monitorConfigurations := Map(
|
||||||
; Desk means the monitor at my desk is plugged in.
|
; Desk means the monitor at my desk is plugged in.
|
||||||
"desk", Map(
|
"desk", Map(
|
||||||
"Workrave", [3748, 2056, 94, 56],
|
"Workrave", [0, 2056, 94, 56],
|
||||||
"Discord", [-7, 0, 900, 750],
|
"Discord", [-7, 0, 900, 750],
|
||||||
"Signal", [-7, 742, 900, 750],
|
"Signal", [-7, 742, 900, 750],
|
||||||
"Visual Studio Code", [886, 0, 2954, 2110],
|
"Visual Studio Code", [886, 0, 2954, 2110],
|
||||||
|
"ahk_exe WindowsTerminal.exe", [886, 0, 2954, 2110],
|
||||||
"Mozilla Firefox", [881, 0, 2963, 2117],
|
"Mozilla Firefox", [881, 0, 2963, 2117],
|
||||||
"TickTick", [712, 2892, 942, 821],
|
"TickTick", [-7, 1484, 900, 635]
|
||||||
"Atrium", [1654, 2160, 1620, 1552]
|
|
||||||
),
|
),
|
||||||
; Standalone means there are no other monitors plugged in.
|
; Standalone means there are no other monitors plugged in.
|
||||||
"standalone", Map(
|
"standalone", Map(
|
||||||
"Workrave", [2468, 1498, 94, 56],
|
"Workrave", [0, 1498, 94, 56],
|
||||||
"Discord", [-7, 0, 900, 750],
|
"Discord", [-7, 0, 900, 750],
|
||||||
"Signal", [-7, 742, 900, 750],
|
"Signal", [-7, 742, 900, 750],
|
||||||
"Visual Studio Code", [472, 0, 2085, 1550],
|
"Visual Studio Code", [472, 0, 2085, 1550],
|
||||||
|
"ahk_exe WindowsTerminal.exe", [472, 0, 2085, 1550],
|
||||||
"Mozilla Firefox", [467, 0, 2099, 1557],
|
"Mozilla Firefox", [467, 0, 2099, 1557],
|
||||||
"TickTick", [0, 731, 942, 821],
|
"TickTick", [0, 731, 942, 821],
|
||||||
"Atrium", [983, 0, 1577, 1552]
|
"Atrium", [983, 0, 1577, 1552],
|
||||||
|
"Plex", [342, 85, 1970, 1300]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
IdentifyMonitorConfiguration() {
|
IdentifyMonitorConfiguration() {
|
||||||
|
; TODO: Improve monitor matching by using the monitor guid.
|
||||||
|
; See https://www.autohotkey.com/boards/viewtopic.php?t=116104
|
||||||
|
|
||||||
count := MonitorGetCount()
|
count := MonitorGetCount()
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
return "standalone"
|
return "standalone"
|
||||||
@ -86,7 +126,7 @@ IdentifyMonitorConfiguration() {
|
|||||||
|
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
ArrangeWindowsInMonitor(monitorIndex, windowConfigs) {
|
ArrangeWindowsInMonitor(windowConfigs) {
|
||||||
for win, params in windowConfigs {
|
for win, params in windowConfigs {
|
||||||
if (WinExist(win)) {
|
if (WinExist(win)) {
|
||||||
WinMove(params[1], params[2], params[3], params[4])
|
WinMove(params[1], params[2], params[3], params[4])
|
||||||
@ -101,8 +141,35 @@ ArrangeWindows(wParam, lParam, msg, hwnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
monitorConfig := monitorConfigurations[monitorConfigName]
|
monitorConfig := monitorConfigurations[monitorConfigName]
|
||||||
ArrangeWindowsInMonitor(A_Index, monitorConfig)
|
ArrangeWindowsInMonitor(monitorConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Listen for the monitor change event
|
||||||
OnMessage(0x007E, ArrangeWindows)
|
OnMessage(0x007E, ArrangeWindows)
|
||||||
|
|
||||||
ArrangeWindows(0, 0, 0, 0)
|
^!+#a:: ; Capslock+a to arrange windows
|
||||||
|
{
|
||||||
|
keyArr := []
|
||||||
|
For Key In monitorConfigurations
|
||||||
|
keyArr.Push(Key)
|
||||||
|
|
||||||
|
selectionGui := Gui()
|
||||||
|
selectionGui.AddText(, "Please select a window layout:")
|
||||||
|
selectionGui.AddDropDownList("vLayoutChoice Choose1", keyArr)
|
||||||
|
selectionGui.AddButton("", "Cancel").OnEvent("Click", Cancel)
|
||||||
|
selectionGui.AddButton("Default X+", "Submit").OnEvent("Click", Submit) ; Place next previous button.
|
||||||
|
selectionGui.Show()
|
||||||
|
WinWaitClose(selectionGui.Hwnd)
|
||||||
|
|
||||||
|
Cancel(*)
|
||||||
|
{
|
||||||
|
WinClose(selectionGui.Hwnd)
|
||||||
|
}
|
||||||
|
|
||||||
|
Submit(*)
|
||||||
|
{
|
||||||
|
Saved := selectionGui.Submit(true)
|
||||||
|
monitorConfig := monitorConfigurations[Saved.LayoutChoice]
|
||||||
|
ArrangeWindowsInMonitor(monitorConfig)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user