mirror of
https://github.com/rbreaves/kinto.git
synced 2025-08-02 09:06:40 +02:00
- Completed Windows autoset keyboard feature
This commit is contained in:
@@ -1,19 +1,39 @@
|
||||
#SingleInstance, force
|
||||
#NoTrayIcon
|
||||
OnMessage(0x219, "notify_change")
|
||||
Return
|
||||
|
||||
lastnotify := 0
|
||||
lastkb = ""
|
||||
|
||||
DllCall("AllocConsole")
|
||||
WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
|
||||
|
||||
notify_change(wParam, lParam, msg, hwnd)
|
||||
{
|
||||
global lastnotify
|
||||
T = %A_Now%
|
||||
T -= 19700101000000,seconds
|
||||
Tdiff := T
|
||||
Tdiff -= lastnotify
|
||||
if Tdiff > 5
|
||||
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%
|
||||
{
|
||||
MsgBox % Tdiff
|
||||
|
||||
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
|
||||
}
|
||||
lastnotify := T
|
||||
}
|
||||
lastkb = %kbtype%
|
||||
}
|
||||
|
Reference in New Issue
Block a user