- Completed Windows autoset keyboard feature

This commit is contained in:
Ben Reaves
2020-06-15 01:15:01 -05:00
parent 7f9ccabf77
commit 2b9598c84f
4 changed files with 147 additions and 10 deletions

View File

@@ -2,6 +2,9 @@
#NoEnv
#Persistent
DetectHiddenWindows, On
Run, %A_ScriptDir%\detectUSB.ahk
I_Icon = %A_ScriptDir%\assets\kinto-white.ico
IfExist, %I_Icon%
Menu, Tray, Icon, %I_Icon%
@@ -44,9 +47,50 @@ tray_suspend(){
}
Exit() {
IfWinExist, detectUSB.ahk
WinClose
ExitApp
}
OnMessage(0x219, "notify_change")
return
lastkb = ""
DllCall("AllocConsole")
WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
notify_change(wParam, lParam, msg, hwnd)
{
global lastkb
; kbtype = % ComObjCreate("WScript.Shell").Exec("cscript /nologo usb.vbs").StdOut.ReadAll()
DetectHiddenWindows On
Run %ComSpec%,, Hide, pid
WinWait ahk_pid %pid%
DllCall("AttachConsole", "UInt", pid)
WshShell := ComObjCreate("Wscript.Shell")
exec := WshShell.Exec("cscript /nologo usb.vbs")
kbtype := exec.StdOut.ReadAll()
DllCall("FreeConsole")
Process Close, %pid%
if lastkb != %kbtype%
{
if InStr(kbtype, "Apple")
{
; MsgBox, Apple
Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat mac, %A_ScriptDir%
}
else{
; MsgBox, Windows
Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat win, %A_ScriptDir%
}
; MsgBox % kbtype
}
lastkb = %kbtype%
}
SetTitleMatchMode, 2
GroupAdd, terminals, ahk_exe ubuntu.exe