aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tt.layout.ahk35
1 files changed, 28 insertions, 7 deletions
diff --git a/tt.layout.ahk b/tt.layout.ahk
index 54821db..824f3fa 100644
--- a/tt.layout.ahk
+++ b/tt.layout.ahk
@@ -3,7 +3,19 @@
;; -> body
LWin & Tab::
-PostMessage, 0x50, 2, 0,, A ; WM_INPUTLANGCHANGEREQUEST
+if (GetKeyState("Shift"))
+ new := altlayout
+else
+{
+ new := activelayouts[1]
+ current := Layout()
+ for k, v in activelayouts
+ {
+ if (v = current)
+ new := activelayouts[k+1]
+ }
+}
+DllCall("SendMessage", "UInt", WinActive("A"), "UInt", 80, "UInt", 1, "UInt", new)
Sleep, 100
ShowLayout() ; display new layout in tray icon
return
@@ -13,30 +25,39 @@ return
;; -> init
layouts := { ru: DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1)
- , sv: DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1) }
+ , sv: DllCall("LoadKeyboardLayout", "Str", "0000041D", "Int", 1)
+ , us: DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1) }
+activelayouts := [layouts.us, layouts.ru]
+altlayout := layouts.sv
+
ShowLayout()
;; -> library
-ShowLayout(hwnd := "")
-{
- global layouts
+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
+}
+
+ShowLayout(hwnd := "")
+{
+ global layouts
+ layout := Layout()
for k, v in layouts
{
if (layout = v)
{
if (FileExist(k ".ico"))
- Menu, Tray, Icon, %k%.ico
+ Menu, Tray, Icon, %k%.ico
break
}
}
- SetFormat, Integer, %f%
}
;; Update layout display on window change -------------------------------------