mirror of
https://github.com/rbreaves/kinto.git
synced 2025-08-05 18:38:26 +02:00
- Completed Windows autoset keyboard feature
This commit is contained in:
2
setup.py
2
setup.py
@@ -37,6 +37,8 @@ def windows_setup():
|
|||||||
if(stvscode):
|
if(stvscode):
|
||||||
os.system('perl -pi -e "s/(; )(.*)(; ST2CODE)/$2$3/g" ./windows/kinto-new.ahk')
|
os.system('perl -pi -e "s/(; )(.*)(; ST2CODE)/$2$3/g" ./windows/kinto-new.ahk')
|
||||||
os.system('copy /Y ' + path + '\\windows\\kinto-start.vbs "%userprofile%\\.kinto\\kinto-start.vbs"')
|
os.system('copy /Y ' + path + '\\windows\\kinto-start.vbs "%userprofile%\\.kinto\\kinto-start.vbs"')
|
||||||
|
os.system('copy /Y ' + path + '\\windows\\usb.vbs "%userprofile%\\.kinto\\usb.vbs"')
|
||||||
|
os.system('copy /Y ' + path + '\\windows\\usb.vbs "%userprofile%\\.kinto\\detectUSB.vbs"')
|
||||||
os.system('mklink "%userprofile%\\Start Menu\\Programs\\Startup\\kinto-start.vbs" "%userprofile%\\.kinto\\kinto-start.vbs"')
|
os.system('mklink "%userprofile%\\Start Menu\\Programs\\Startup\\kinto-start.vbs" "%userprofile%\\.kinto\\kinto-start.vbs"')
|
||||||
os.system('cp '+ path + '\\windows\\NoShell.vbs "%userprofile%\\.kinto\\NoShell.vbs"')
|
os.system('cp '+ path + '\\windows\\NoShell.vbs "%userprofile%\\.kinto\\NoShell.vbs"')
|
||||||
os.system('cp '+ path + '\\windows\\toggle_kb.bat "%userprofile%\\.kinto\\toggle_kb.bat"')
|
os.system('cp '+ path + '\\windows\\toggle_kb.bat "%userprofile%\\.kinto\\toggle_kb.bat"')
|
||||||
|
@@ -1,19 +1,39 @@
|
|||||||
#SingleInstance, force
|
#SingleInstance, force
|
||||||
|
#NoTrayIcon
|
||||||
OnMessage(0x219, "notify_change")
|
OnMessage(0x219, "notify_change")
|
||||||
Return
|
Return
|
||||||
|
|
||||||
lastnotify := 0
|
lastkb = ""
|
||||||
|
|
||||||
|
DllCall("AllocConsole")
|
||||||
|
WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
|
||||||
|
|
||||||
notify_change(wParam, lParam, msg, hwnd)
|
notify_change(wParam, lParam, msg, hwnd)
|
||||||
{
|
{
|
||||||
global lastnotify
|
global lastkb
|
||||||
T = %A_Now%
|
; kbtype = % ComObjCreate("WScript.Shell").Exec("cscript /nologo usb.vbs").StdOut.ReadAll()
|
||||||
T -= 19700101000000,seconds
|
DetectHiddenWindows On
|
||||||
Tdiff := T
|
Run %ComSpec%,, Hide, pid
|
||||||
Tdiff -= lastnotify
|
WinWait ahk_pid %pid%
|
||||||
if Tdiff > 5
|
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%
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,9 @@
|
|||||||
#NoEnv
|
#NoEnv
|
||||||
#Persistent
|
#Persistent
|
||||||
|
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
Run, %A_ScriptDir%\detectUSB.ahk
|
||||||
|
|
||||||
I_Icon = %A_ScriptDir%\assets\kinto-white.ico
|
I_Icon = %A_ScriptDir%\assets\kinto-white.ico
|
||||||
IfExist, %I_Icon%
|
IfExist, %I_Icon%
|
||||||
Menu, Tray, Icon, %I_Icon%
|
Menu, Tray, Icon, %I_Icon%
|
||||||
@@ -44,9 +47,50 @@ tray_suspend(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Exit() {
|
Exit() {
|
||||||
|
IfWinExist, detectUSB.ahk
|
||||||
|
WinClose
|
||||||
|
|
||||||
ExitApp
|
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
|
SetTitleMatchMode, 2
|
||||||
|
|
||||||
GroupAdd, terminals, ahk_exe ubuntu.exe
|
GroupAdd, terminals, ahk_exe ubuntu.exe
|
||||||
|
71
windows/usb.vbs
Normal file
71
windows/usb.vbs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
Option Explicit
|
||||||
|
Dim oWMISrv, collDvcs, iUSBDvc , iDvc, sDvcID, sPID, sVID
|
||||||
|
|
||||||
|
' add item to array
|
||||||
|
Function AddItem(arr, val)
|
||||||
|
ReDim Preserve arr(UBound(arr) + 1)
|
||||||
|
arr(UBound(arr)) = val
|
||||||
|
AddItem = arr
|
||||||
|
End Function
|
||||||
|
|
||||||
|
' returns an array of the unique items in for-each-able collection fex
|
||||||
|
Function uniqFE(fex)
|
||||||
|
Dim dicTemp : Set dicTemp = CreateObject("Scripting.Dictionary")
|
||||||
|
Dim xItem
|
||||||
|
For Each xItem In fex
|
||||||
|
dicTemp(xItem) = 0
|
||||||
|
Next
|
||||||
|
uniqFE = dicTemp.Keys()
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Function ReplaceX(ByVal sValue, ByVal sPattern, ByVal sNValue)
|
||||||
|
Dim oReg : Set oReg = New RegExp
|
||||||
|
oReg.Pattern = sPattern
|
||||||
|
ReplaceX = oReg.Replace(sValue, sNValue)
|
||||||
|
Set oReg = Nothing
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Set oWMISrv = GetObject("winmgmts:\\.\root\cimv2")
|
||||||
|
Set collDvcs = oWMISrv.ExecQuery("Select * From Win32_PnPEntity WHERE Service='kbdhid'")
|
||||||
|
|
||||||
|
Dim deviceVID : deviceVID=Array()
|
||||||
|
Dim devicePID : devicePID=Array()
|
||||||
|
Dim deviceDesc : deviceDesc=Array()
|
||||||
|
Dim counter: counter=0
|
||||||
|
|
||||||
|
For Each iUSBDvc In collDvcs
|
||||||
|
sVID = ReplaceX(iUSBDvc.DeviceID, ".*VID_(.{4}).*", "$1")
|
||||||
|
sPID = ReplaceX(iUSBDvc.DeviceID, ".*PID_(.{4}).*", "$1")
|
||||||
|
deviceVID = AddItem(deviceVID, sVID)
|
||||||
|
devicePID = AddItem(devicePID, sPID)
|
||||||
|
deviceDesc = AddItem(deviceDesc, iUSBDvc.Description)
|
||||||
|
counter = counter + 1
|
||||||
|
' Wscript.Echo "Name : "& iUSBDvc.Description &"VID_PID : "& sVID & sPID
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim uniqueVID: uniqueVID = uniqFE(deviceVID)
|
||||||
|
Dim vcount: vcount = UBound(uniqueVID) + 1
|
||||||
|
Dim nonApple: nonApple = 0
|
||||||
|
Dim i
|
||||||
|
|
||||||
|
If vcount = 1 Then
|
||||||
|
If StrComp(deviceVID(0), "05AC") = 0 Then
|
||||||
|
Wscript.Echo "Apple"
|
||||||
|
Else
|
||||||
|
Wscript.Echo "Windows"
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
For i = 0 To counter-1
|
||||||
|
If StrComp(deviceVID(i), "05AC") = -1 Then
|
||||||
|
nonApple = 1
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
If nonApple = 1 Then
|
||||||
|
Wscript.Echo "Windows"
|
||||||
|
Else
|
||||||
|
Wscript.Echo "Apple"
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
Set collDvcs = Nothing
|
||||||
|
Set oWMISrv = Nothing
|
Reference in New Issue
Block a user