aboutsummaryrefslogtreecommitdiff
path: root/tiny
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-12-15 02:49:21 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-12-15 02:49:21 +0100
commit9296af393bd277d7b191ad2ff9d8e64fb2030822 (patch)
tree9af514d4e8fca7c551adff80224bfc6d3b0097a3 /tiny
parent000e43e651157dbe2514f4844bda38e8e5821363 (diff)
downloadahk-master.tar.gz
Add tiny/cfg.ahkHEADmaster
I've grown a bit tired of maintaining such a large script...
Diffstat (limited to 'tiny')
-rw-r--r--tiny/cfg.ahk114
1 files changed, 114 insertions, 0 deletions
diff --git a/tiny/cfg.ahk b/tiny/cfg.ahk
new file mode 100644
index 0000000..12be889
--- /dev/null
+++ b/tiny/cfg.ahk
@@ -0,0 +1,114 @@
+#SingleInstance Force
+#Persistent
+
+;; Initialization.
+ShellApp := ComObjCreate("Shell.Application")
+us := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)
+jp := DllCall("LoadKeyboardLayout", "Str", "00000411", "Int", 1)
+;; ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1)
+;; sv := DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1)
+
+Menu, Tray, Tip, Cfg
+Menu, Tray, Icon, shell32.dll, 105
+
+GroupAdd, Explorer, ahk_class CabinetWClass
+GroupAdd, Explorer, ahk_class ExploreWClass
+GroupAdd, Desktop, ahk_class Progman
+GroupAdd, Desktop, ahk_class WorkerW
+
+Gui +LastFound
+DllCall("RegisterShellHookWindow", UInt, WinExist())
+msg := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
+OnMessage(msg, "FixZ")
+return
+
+;; Fix z-order after minimization.
+FixZ(wParam, lParam){
+ static HSHELL_GETMINRECT := 5
+ static HWND_BOTTOM := 1
+ static SWP_NOSIZE := 0x0001
+ static SWP_NOMOVE := 0x0002
+ static SWP_ASYNCWINDOWPOS := 0x4000
+ if(wParam = HSHELL_GETMINRECT and WinActive("A") = 0){
+ hwnd := NumGet(lParam + 0)
+ WinWaitNotActive, ahk_id 0 ; Wait until end of minimization.
+ Sleep, 20
+ DllCall("SetWindowPos", "UInt", hwnd, "UInt", HWND_BOTTOM
+ , "Int", 0, "Int", 0, "Int", 0, "Int", 0
+ , "UInt", SWP_NOSIZE | SWP_NOMOVE | SWP_ASYNCWINDOWPOS)
+ }
+}
+
+;; Window management hotkeys.
+#o::WinSet, AlwaysOnTop, Toggle, A
+#z::WinMinimize, A
+
+;; Command prompt hotkeys.
+#IfWinActive ahk_group Explorer
+^p::
+WinGet, hwnd, id, A
+for window in ShellApp.Windows
+ if (window.hwnd = hwnd)
+ window.Document.Application.ShellExecute("cmd"
+ , "/k cd /d """ window.Document.Folder.Self.path """")
+
+return
+#IfWinActive ahk_class ConsoleWindowClass
+!F4::WinClose, A
+#IfWinActive
+
+;; Volume hotkeys.
+RAlt & F6::SetVolume(GetKeyState("Shift") ? 2 : 1)
+RAlt & F5::SetVolume(GetKeyState("Shift") ? -2 : -1)
+SetVolume(n){
+ SoundGet, s
+ s := round(s) + n
+ if (s > 100)
+ s := 100
+ if (s < 0)
+ s := 0
+ SoundSet, %s%
+ ToolTip, %s%
+ SetTimer, RemoveToolTip, -100
+}
+RemoveToolTip:
+ToolTip
+return
+
+;; Toggle keyboard layout.
+^\::
+<^>!^SC00C::
+if(Layout() == us)
+ new := jp
+else
+ new := us
+DllCall("SendMessage", "UInt", WinActive("A"), "UInt", 80, "UInt", 1, "UInt", new)
+return
+Layout(){
+ f := A_FormatInteger
+ SetFormat, Integer, H
+ if (hwnd = "")
+ WinGet, hwnd, id, A
+ thread := DllCall("GetWindowThreadProcessId", "UInt",hwnd, "UInt",0)
+ layout := DllCall("user32.dll\GetKeyboardLayout", "UInt",thread, "UInt")
+ SetFormat, Integer, %f%
+ return layout
+}
+
+;; Extra keys.
+#If Layout() == us && !WinActive("ahk_exe VirtualBoxVM.exe")
+:z*?:aa::å
+:z*?:ae::ä
+:z*?:oe::ö
+:z*?:AA::Å
+:z*?:AE::Ä
+:z*?:OE::Ö
+:z*?:a``::à
+:z*?:e``::é
+:z*?:A``::À
+:z*?:E``::É
+>!a::SendInput, a
+>!e::SendInput, e
+>!+a::SendInput, A
+>!+e::SendInput, E
+#If \ No newline at end of file