mirror of
https://github.com/rbreaves/kinto.git
synced 2025-08-01 16:56:38 +02:00
Merge pull request #214 from rbreaves/dev
- Windows auto-keyboard detection, new icon status, Terminus support
This commit is contained in:
BIN
assets/kinto-black-invert.ico
Normal file
BIN
assets/kinto-black-invert.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
BIN
assets/kinto-color-black-invert.ico
Normal file
BIN
assets/kinto-color-black-invert.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
BIN
assets/kinto-color-invert-border.ico
Normal file
BIN
assets/kinto-color-invert-border.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 104 KiB |
BIN
assets/kinto-color-invert.ico
Normal file
BIN
assets/kinto-color-invert.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
BIN
assets/kinto-color-white-invert.ico
Normal file
BIN
assets/kinto-color-white-invert.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
BIN
assets/kinto-white-invert.ico
Normal file
BIN
assets/kinto-white-invert.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
344
keycheck.py
Executable file
344
keycheck.py
Executable file
@@ -0,0 +1,344 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# pip3 install pynput
|
||||
# pip3 install --no-deps pynput
|
||||
|
||||
# from pynput.keyboard import Key, Listener
|
||||
import sys, subprocess, time, os
|
||||
from subprocess import PIPE, Popen
|
||||
delay=3
|
||||
|
||||
def cmdline(command):
|
||||
process = Popen(
|
||||
args=command,
|
||||
stdout=PIPE,
|
||||
universal_newlines=True,
|
||||
shell=True
|
||||
)
|
||||
return process.communicate()[0]
|
||||
|
||||
class color:
|
||||
PURPLE = '\033[95m'
|
||||
CYAN = '\033[96m'
|
||||
DARKCYAN = '\033[36m'
|
||||
BLUE = '\033[94m'
|
||||
GREEN = '\033[92m'
|
||||
YELLOW = '\033[93m'
|
||||
RED = '\033[91m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
END = '\033[0m'
|
||||
|
||||
def countdown(secs):
|
||||
for i in range(0,secs):
|
||||
print(secs-i, end="\r", flush=True)
|
||||
time.sleep(1)
|
||||
|
||||
def on_press(key):
|
||||
print('{0} pressed'.format(key))
|
||||
|
||||
def on_release(key):
|
||||
# print('{0} release'.format(key))
|
||||
if key == Key.esc:
|
||||
# Stop listener
|
||||
return False
|
||||
|
||||
def yn_choice(message, default='y'):
|
||||
choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N'
|
||||
choice = input("%s (%s) " % (message, choices))
|
||||
values = ('y', 'yes', '') if choices == 'Y/n' else ('y', 'yes')
|
||||
return choice.strip().lower() in values
|
||||
|
||||
modifier_keys = {
|
||||
"primary":"",
|
||||
"secondary":"",
|
||||
"rprimary":"",
|
||||
"rsecondary":"",
|
||||
"capslock":"",
|
||||
"capswap":""
|
||||
}
|
||||
|
||||
def set_key(key):
|
||||
global modifier_keys
|
||||
print("\nWhich key would you like to set?\n")
|
||||
|
||||
while True:
|
||||
try:
|
||||
keytype = int(input(
|
||||
"1) Ctrl\n" +
|
||||
"2) Alt\n" +
|
||||
"3) Super/Win/Cmd/Chrome search key\n"))
|
||||
if keytype < 4 and keytype > 0:
|
||||
break
|
||||
except:
|
||||
print("That's not a valid option!")
|
||||
print("")
|
||||
if keytype == 1:
|
||||
modifier_keys[key] = "Ctrl"
|
||||
elif keytype == 2:
|
||||
modifier_keys[key] = "Alt"
|
||||
elif keytype == 3:
|
||||
modifier_keys[key] = "Cmd"
|
||||
|
||||
def set_cap():
|
||||
global modifier_keys
|
||||
print("\nWhich key would you like to swap?\n")
|
||||
|
||||
while True:
|
||||
try:
|
||||
keytype = int(input(
|
||||
"1) Ctrl (swap)\n" +
|
||||
"2) Ctrl (duplicate)\n" +
|
||||
"3) Esc (swap)\n"))
|
||||
if keytype < 4 and keytype > 0:
|
||||
break
|
||||
except:
|
||||
print("That's not a valid option!")
|
||||
print("")
|
||||
if keytype == 1:
|
||||
modifier_keys["capslock"] = "Ctrl-swap"
|
||||
elif keytype == 2:
|
||||
modifier_keys["capslock"] = "Ctrl-dup"
|
||||
elif keytype == 3:
|
||||
modifier_keys["capswap"] = "Escape"
|
||||
|
||||
def is_primary(key):
|
||||
global modifier_keys
|
||||
if not (str(key).replace("Key.", "").title() == "Enter" or str(key).replace("Key.", "").title() == "Escape"):
|
||||
print(str(key).replace("Key.", "").title() + " will be remapped to Ctrl, the Cmd ⌘ key position.")
|
||||
# countdown(3)
|
||||
modifier_keys["primary"] = str(key).replace("Key.", "").title()
|
||||
elif str(key).replace("Key.", "").title() == "Escape":
|
||||
modifier_keys["primary"] = "Escape"
|
||||
# countdown(3)
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_secondary(key):
|
||||
global modifier_keys
|
||||
if not (str(key).replace("Key.", "").title() == "Enter" or str(key).replace("Key.", "").title() == "Escape"):
|
||||
print(str(key).replace("Key.", "").title() + " will be remapped to Alt, the Option ⌥ key position.")
|
||||
# countdown(3)
|
||||
modifier_keys["secondary"] = str(key).replace("Key.", "").title()
|
||||
return False
|
||||
elif str(key).replace("Key.", "").title() == "Escape":
|
||||
modifier_keys["secondary"] = "Escape"
|
||||
# countdown(3)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def is_rprimary(key):
|
||||
global modifier_keys
|
||||
if not (str(key).replace("Key.", "").title() == "Enter" or str(key).replace("Key.", "").title() == "Escape"):
|
||||
print(str(key).replace("Key.", "").title() + " will be remapped to Ctrl, the Cmd ⌘ key position.")
|
||||
# countdown(3)
|
||||
modifier_keys["rprimary"] = str(key).replace("Key.", "").title()
|
||||
return False
|
||||
elif str(key).replace("Key.", "").title() == "Escape":
|
||||
modifier_keys["rprimary"] = "Escape"
|
||||
# countdown(3)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def is_rsecondary(key):
|
||||
global modifier_keys
|
||||
if not (str(key).replace("Key.", "").title() == "Enter" or str(key).replace("Key.", "").title() == "Escape"):
|
||||
print(str(key).replace("Key.", "").title() + " will be remapped to Alt, the Option ⌥ key position.")
|
||||
# countdown(3)
|
||||
modifier_keys["rsecondary"] = str(key).replace("Key.", "").title()
|
||||
return False
|
||||
elif str(key).replace("Key.", "").title() == "Escape":
|
||||
modifier_keys["rsecondary"] = "Escape"
|
||||
# countdown(3)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
print(color.UNDERLINE + color.YELLOW + "\n\nPlease ignore the FN key." + color.END + " FN cannot be remapped by software, some Thinkpads can swap it with Ctrl in the BIOS.\n")
|
||||
input("Press Enter to continue...\n\n")
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
counter = 0
|
||||
|
||||
while True:
|
||||
|
||||
print(color.UNDERLINE + color.YELLOW + "\n\nPress the 1st key Left of the spacebar" + color.END + " (Press Esc to set manaully)\n")
|
||||
print(" 👇")
|
||||
print(" □ □ ▣ ░░░░░░░\n")
|
||||
# listener = Listener(on_release=is_primary,suppress=True)
|
||||
# listener.start()
|
||||
|
||||
# with Listener(
|
||||
# on_release=is_primary,suppress=True) as listener:
|
||||
# try:
|
||||
# listener.join()
|
||||
# except MyException as e:
|
||||
# print('{0} was pressed'.format(e.args[0]))
|
||||
|
||||
modifier_keys["primary"] = cmdline("xbindkeys -k | awk 'END {print $NF}'").strip()
|
||||
print(modifier_keys["primary"] + " will be remapped to Ctrl, the Cmd ⌘ key position.")
|
||||
|
||||
if modifier_keys["primary"] != "Escape":
|
||||
choice = yn_choice("Is this correct?")
|
||||
if(choice):
|
||||
# print("Left Physical " + modifier_keys["primary"] + " = Ctrl/Cmd ⌘")
|
||||
# listener.stop()
|
||||
# input("Press Enter to continue...\n\n")
|
||||
break
|
||||
else:
|
||||
set_key("primary")
|
||||
print("Left Physical " + modifier_keys["primary"] + " = Ctrl/Cmd ⌘\n")
|
||||
# listener.stop()
|
||||
input("Press Enter to continue...\n\n")
|
||||
break
|
||||
counter += 1
|
||||
print(str(counter)+"\n")
|
||||
time.sleep(1)
|
||||
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
while True:
|
||||
print(color.UNDERLINE + color.YELLOW + "\n\nPress the 2nd key Left of the spacebar" + color.END + " (Press Esc to set manaully)\n")
|
||||
print(" 👇")
|
||||
print(" □ ▣ □ ░░░░░░░\n")
|
||||
|
||||
# with Listener(
|
||||
# on_release=is_secondary,suppress=True) as listener:
|
||||
# try:
|
||||
# listener.join()
|
||||
# except MyException as e:
|
||||
# print('{0} was pressed'.format(e.args[0]))
|
||||
modifier_keys["secondary"] = cmdline("xbindkeys -k | awk 'END {print $NF}'").strip()
|
||||
print(modifier_keys["secondary"] + " will be remapped to Alt, the Option ⌥ key position.")
|
||||
|
||||
if modifier_keys["secondary"] != "Escape":
|
||||
choice = yn_choice("Is this correct?")
|
||||
if(choice):
|
||||
# listener.stop()
|
||||
# print("Left Physical " + modifier_keys["secondary"] + " = Alt/Option ⌥")
|
||||
# input("Press Enter to continue...\n\n")
|
||||
break
|
||||
else:
|
||||
set_key("secondary")
|
||||
print("Left Physical " + modifier_keys["secondary"] + " = Alt/Option ⌥\n")
|
||||
# listener.stop()
|
||||
input("Press Enter to continue...\n\n")
|
||||
break
|
||||
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
while True:
|
||||
print(color.UNDERLINE + color.YELLOW + "\n\nPress the 1st key Right of the spacebar" + color.END + " (Press Esc to set manaully)\n")
|
||||
print(" 👇")
|
||||
print(" ░░░░░░░ ▣ □")
|
||||
|
||||
# with Listener(
|
||||
# on_release=is_rprimary,suppress=True) as listener:
|
||||
# try:
|
||||
# listener.join()
|
||||
# except MyException as e:
|
||||
# print('{0} was pressed'.format(e.args[0]))
|
||||
modifier_keys["rprimary"] = cmdline("xbindkeys -k | awk 'END {print $NF}'").strip()
|
||||
print(modifier_keys["rprimary"] + " will be remapped to Ctrl, the Cmd ⌘ key position.")
|
||||
|
||||
if modifier_keys["rprimary"] != "Escape":
|
||||
choice = yn_choice("Is this correct?")
|
||||
if(choice):
|
||||
# listener.stop()
|
||||
# print("Right Physical " + modifier_keys["rprimary"] + " = Ctrl/Cmd ⌘")
|
||||
# input("Press Enter to continue...\n\n")
|
||||
break
|
||||
else:
|
||||
set_key("rprimary")
|
||||
print("Right Physical " + modifier_keys["rprimary"] + " = Ctrl/Cmd ⌘\n")
|
||||
# listener.stop()
|
||||
input("Press Enter to continue...\n\n")
|
||||
break
|
||||
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
while True:
|
||||
print(color.UNDERLINE + color.YELLOW + "\n\nPress the 2nd key Right of the spacebar" + color.END + " (Press Esc to set manaully)\n")
|
||||
print(" 👇")
|
||||
print(" ░░░░░░░ □ ▣")
|
||||
|
||||
# with Listener(
|
||||
# on_release=is_rsecondary,suppress=True) as listener:
|
||||
# try:
|
||||
# listener.join()
|
||||
# except MyException as e:
|
||||
# print('{0} was pressed'.format(e.args[0]))
|
||||
modifier_keys["rsecondary"] = cmdline("xbindkeys -k | awk 'END {print $NF}'").strip()
|
||||
print(modifier_keys["rsecondary"] + " will be remapped to Alt, the Option ⌥ key position.")
|
||||
|
||||
if modifier_keys["rsecondary"] != "Escape":
|
||||
choice = yn_choice("Is this correct?")
|
||||
if(choice):
|
||||
# listener.stop()
|
||||
# print("Right Physical " + modifier_keys["rsecondary"] + " = Alt/Option ⌥")
|
||||
# modifier_keys["rsecondary"] = str(os.system("xbindkeys -k | awk 'END {print $NF}'"))
|
||||
break
|
||||
else:
|
||||
set_key("rsecondary")
|
||||
print("Right Physical " + modifier_keys["rsecondary"] + " = Alt/Option ⌥\n")
|
||||
# listener.stop()
|
||||
input("Press Enter to continue...\n\n")
|
||||
break
|
||||
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
if not (modifier_keys["secondary"] == "Ctrl" or modifier_keys["secondary"] == "Control_R"):
|
||||
print(color.UNDERLINE + color.YELLOW + "GUI Usage (Physical Ctrl key)\n"+ color.END)
|
||||
print("Ctrl key will be mapped to Super. (Search key on chromebooks)")
|
||||
print("👇")
|
||||
print(" ▣ □ □ ░░░░░░░\n")
|
||||
|
||||
print("Note: Super may still activate Ctrl based shortcuts\n")
|
||||
print("at times depending on application or system level shortcuts.\n")
|
||||
print("This will only be done to align shortcuts to their expected functionality.\n")
|
||||
|
||||
input("Press Enter to continue...\n\n")
|
||||
# print(chr(27) + "[2J")
|
||||
|
||||
print(color.UNDERLINE + color.YELLOW + "Terminal Usage" + color.END + "\n")
|
||||
print("Ctrl key will be the Ctrl key.")
|
||||
print("👇")
|
||||
print(" ▣ □ □ ░░░░░░░\n")
|
||||
print("The Cmd ⌘ key position during terminal usage will usually be Ctrl+Shift.")
|
||||
print(" 👇 ")
|
||||
print(" □ □ ▣ ░░░░░░░\n")
|
||||
input("Press Enter to continue...\n")
|
||||
else:
|
||||
print("Chromebook detected.")
|
||||
|
||||
print(color.UNDERLINE + color.YELLOW + "GUI Usage\n"+ color.END)
|
||||
print("Search key (capslock position) on chromebooks will be Super\n")
|
||||
|
||||
print("Note: Super may still activate Ctrl based shortcuts")
|
||||
print("at times depending on application or system level shortcuts.\n")
|
||||
print("Efforts have been made though to use the physical Ctrl key")
|
||||
print("when it makes sense to do so, and more often than standard")
|
||||
print("keyboards. How it feels to type is more important than technical")
|
||||
print("accuracy.\n")
|
||||
print("If you believe an improvement can be made or an error was made")
|
||||
print("please let me know on github or you can fork this project.\n")
|
||||
|
||||
input("Press Enter to continue...\n\n")
|
||||
|
||||
print(color.UNDERLINE + color.YELLOW + "Terminal Usage" + color.END + "\n")
|
||||
print(" □ capslock/search key = Alt")
|
||||
print(" shift")
|
||||
print(" ▣ □ ░░░░░░░")
|
||||
print("☝️\n")
|
||||
|
||||
input("Press Enter to continue...\n\n")
|
||||
|
||||
print(chr(27) + "[2J")
|
||||
|
||||
choice = yn_choice(color.UNDERLINE + color.YELLOW + "Do you want to swap Capslock with another key?" + color.END + "\n","n")
|
||||
if(choice):
|
||||
set_cap()
|
7
setup.py
7
setup.py
@@ -26,6 +26,11 @@ def windows_setup():
|
||||
# os.system("regedit " + path + "\\windows\\standard_ctrlalt_swap.reg")
|
||||
elif default == 3:
|
||||
os.system("regedit " + path + "\\windows\\remove_keyswap.reg")
|
||||
os.system("del /f .\\windows\\kinto-new.ahk")
|
||||
os.system("del \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\kinto.ahk\"")
|
||||
os.system("taskkill /IM autohotkey.exe")
|
||||
os.system('rd /s /q %userprofile%\\.kinto')
|
||||
os.system('del "%userprofile%\\AppData\\Roaming\\Microsoft\\Windows\\STARTM~1\\Programs\\Startup\\kinto-start.vbs"')
|
||||
stvscode = yn_choice(bcolors.CYELLOW2 + "Would you like to use Sublime Text 3 keymaps in VS Code?\n" + bcolors.ENDC)
|
||||
if default > 0 and default < 3:
|
||||
print("Will now install chocolatey and autohotkey with elevated privileges...")
|
||||
@@ -37,6 +42,8 @@ def windows_setup():
|
||||
if(stvscode):
|
||||
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\\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('cp '+ path + '\\windows\\NoShell.vbs "%userprofile%\\.kinto\\NoShell.vbs"')
|
||||
os.system('cp '+ path + '\\windows\\toggle_kb.bat "%userprofile%\\.kinto\\toggle_kb.bat"')
|
||||
|
3630
system-config/keyboard.ids
Normal file
3630
system-config/keyboard.ids
Normal file
File diff suppressed because it is too large
Load Diff
39
windows/detectUSB.ahk
Normal file
39
windows/detectUSB.ahk
Normal file
@@ -0,0 +1,39 @@
|
||||
#SingleInstance, force
|
||||
#NoTrayIcon
|
||||
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%
|
||||
}
|
@@ -2,9 +2,18 @@
|
||||
#NoEnv
|
||||
#Persistent
|
||||
|
||||
I_Icon = %A_ScriptDir%\assets\kinto-white.ico
|
||||
IfExist, %I_Icon%
|
||||
Menu, Tray, Icon, %I_Icon%
|
||||
DetectHiddenWindows, On
|
||||
Run, %A_ScriptDir%\detectUSB.ahk
|
||||
|
||||
; I_Icon = %A_ScriptDir%\assets\kinto-white.ico ; MacModifiers
|
||||
; IfExist, %I_Icon% ; MacModifiers
|
||||
; Menu, Tray, Icon, %I_Icon%,, 1 ; MacModifiers
|
||||
; Menu, Tray, Tip, Mac - Kinto ; MacModifiers
|
||||
|
||||
; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers
|
||||
; IfExist, %I_Icon% ; WinModifiers
|
||||
; Menu, Tray, Icon, %I_Icon%,, 1 ; WinModifiers
|
||||
; Menu, Tray, Tip, Windows - Kinto ; WinModifiers
|
||||
|
||||
; Set Tray menu
|
||||
; Menu, Tray, Standard
|
||||
@@ -16,7 +25,6 @@ Menu, Tray, Add, Returns to Desktop, min
|
||||
Menu, Tray, Add
|
||||
Menu, Tray, Add, Close, Exit
|
||||
Menu, Tray, Click, 1
|
||||
Menu, Tray, Tip, Kinto
|
||||
|
||||
winkb(){
|
||||
Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat win, %A_ScriptDir%
|
||||
@@ -29,24 +37,74 @@ mackb(){
|
||||
min(){
|
||||
; Refocus last active Window
|
||||
Send {LAlt down}{tab}{LAlt up}
|
||||
}
|
||||
}
|
||||
|
||||
tray_suspend(){
|
||||
suspend toggle
|
||||
if (a_isSuspended = 1){
|
||||
menu, tray, check , Suspend Kinto
|
||||
I_Icon = %A_ScriptDir%\assets\kinto-color-invert.ico
|
||||
Menu, Tray, Icon, %I_Icon%,, 1
|
||||
Menu, Tray, Tip, Suspended - Kinto
|
||||
IfWinExist, detectUSB.ahk
|
||||
WinClose
|
||||
}
|
||||
else{
|
||||
menu, tray, unCheck, Suspend Kinto
|
||||
; I_Icon = %A_ScriptDir%\assets\kinto-white.ico ; MacModifiers
|
||||
; I_Icon = %A_ScriptDir%\assets\kinto-white-invert.ico ; WinModifiers
|
||||
Menu, Tray, Icon, %I_Icon%,,1
|
||||
Run, %A_ScriptDir%\detectUSB.ahk
|
||||
}
|
||||
; Refocus last active Window
|
||||
Send {LAlt down}{tab}{LAlt up}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -64,7 +122,7 @@ GroupAdd, posix, ahk_exe ConEmu.exe
|
||||
GroupAdd, posix, ahk_exe ConEmu64.exe
|
||||
GroupAdd, posix, ahk_exe Hyper.exe
|
||||
GroupAdd, posix, ahk_exe mintty.exe
|
||||
GroupAdd, terminals, ahk_exe Terminus.exe
|
||||
GroupAdd, posix, ahk_exe Terminus.exe
|
||||
GroupAdd, posix, Fluent Terminal ahk_class ApplicationFrameWindow
|
||||
|
||||
GroupAdd, ConEmu, ahk_exe ConEmu.exe
|
||||
@@ -181,15 +239,16 @@ $^+Right::Send +{End}
|
||||
; Cmd+Space Alternative
|
||||
^Space::Send ^{Esc}
|
||||
|
||||
; ; Sublime Text Remaps for VS Code
|
||||
#IfWinActive ahk_group vscode ; ST2CODE
|
||||
; Sublime Text Remaps for VS Code
|
||||
#IfWinActive ahk_group vscode
|
||||
; Remap Ctrl+Shift to behave like macOS Sublimetext
|
||||
; Will extend cursor to multiple lines
|
||||
#+Up::send ^!{Up} ; ST2CODE
|
||||
#+Down::send ^!{Down} ; ST2CODE
|
||||
; #+Up::send ^!{Up} ; ST2CODE
|
||||
; #+Down::send ^!{Down} ; ST2CODE
|
||||
; Remap Ctrl+Cmd+G to select all matches
|
||||
#^g::send ^+{L} ; ST2CODE
|
||||
#If ; ST2CODE
|
||||
; #^g::send ^+{L} ; ST2CODE
|
||||
!+g::send ^+{G} ; View source control
|
||||
#If
|
||||
|
||||
#IfWinActive ahk_exe sublime_text.exe
|
||||
; Remap Ctrl+Shift to behave like macOS Sublimetext
|
||||
|
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
|
@@ -118,6 +118,7 @@ define_keymap(lambda wm_class: wm_class.casefold() not in mscodes,{
|
||||
K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word
|
||||
K("M-Right"): K("C-Right"), # Right of Word
|
||||
K("M-Shift-Right"): K("C-Shift-Right"), # Select Right of Word
|
||||
K("M-Shift-g"): K("C-Shift-g"), # View source control
|
||||
# ** VS Code fix **
|
||||
# Electron issue precludes normal keybinding fix.
|
||||
# Alt menu auto-focus/toggle gets in the way.
|
||||
|
Reference in New Issue
Block a user