diff --git a/setup.py b/setup.py index f7a3024..24f1543 100755 --- a/setup.py +++ b/setup.py @@ -16,13 +16,13 @@ def windows_setup(): default = int(input("\nPlease enter your desired keymap (1 - " + str(len(keymaps)) + ") : ")) print("") # Short DOS path notation - path= cmdline('echo %cd%')[:-1] + path= cmdline('echo ''%cd%''')[:-1] if default > 0 and default < 3: print("Will now install chocolatey and autohotkey with elevated privileges...") print("This install will fail if you are not running with elevated privileges") os.system('powershell -executionpolicy bypass ".\\windows\\autohotkey.ps1"') print("Copying autohotkey combinations for Terminals & Editors...") - os.system("copy /Y " + path + "\\windows\\kinto.ahk " + path + "\\windows\\kinto-new.ahk") + os.system('copy /Y "' + path + '\\windows\\kinto.ahk" "' + path + '\\windows\\kinto-new.ahk"') if default == 1: os.system('C:\\Strawberry\\perl\\bin\\perl.exe -pi -e "s/(; )(.*)(; MacModifiers)/$2$3/g" .\\windows\\kinto-new.ahk') elif default == 2: @@ -36,27 +36,28 @@ def windows_setup(): print("Ending any running Kinto tasks...") os.system("(taskkill /IM autohotkey.exe) 2> nul") print("Removing Kinto from users profile directory...") - os.system('(rd /s /q %userprofile%\\.kinto) 2> nul') + os.system('(rd /s /q "%userprofile%\\.kinto") 2> nul') print("") print("Uninstall of Kinto is Complete.") if default > 0 and default < 3: stvscode = yn_choice(bcolors.CYELLOW2 + "Would you like to use Sublime Text 3 keymaps in VS Code?\n" + bcolors.ENDC) print("\nWill now install Ubuntu Termimnal Theme as default...") - os.system("regedit " + path + "\\windows\\theme_ubuntu.reg") - os.system('robocopy '+ path + '\\assets "%userprofile%\\.kinto\\assets" /E') + os.system('regedit "' + path + '\\windows\\theme_ubuntu.reg"') + os.system('robocopy "'+ path + '\\assets" "%userprofile%\\.kinto\\assets" /E') if(stvscode): os.system('C:\\Strawberry\\perl\\bin\\perl.exe -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\\detectUSB.ahk "%userprofile%\\.kinto\\detectUSB.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\\detectUSB.ahk" "%userprofile%\\.kinto\\detectUSB.ahk"') os.system('mklink "%userprofile%\\Start Menu\\Programs\\Startup\\kinto-start.vbs" "%userprofile%\\.kinto\\kinto-start.vbs"') - os.system('copy /Y '+ path + '\\windows\\NoShell.vbs "%userprofile%\\.kinto\\NoShell.vbs"') - os.system('copy /Y '+ path + '\\windows\\toggle_kb.bat "%userprofile%\\.kinto\\toggle_kb.bat"') - os.system('copy /Y '+ path + '\\windows\\kinto-new.ahk "%userprofile%\\.kinto\\kinto.ahk"') + os.system('copy /Y "'+ path + '\\windows\\NoShell.vbs" "%userprofile%\\.kinto\\NoShell.vbs"') + os.system('copy /Y "'+ path + '\\windows\\toggle_kb.bat" "%userprofile%\\.kinto\\toggle_kb.bat"') + os.system('copy /Y "'+ path + '\\windows\\kinto-new.ahk" "%userprofile%\\.kinto\\kinto.ahk"') os.system("del /f .\\windows\\kinto-new.ahk") os.system("del \"C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\kinto.ahk\" 2> nul") - os.system("%userprofile%\\AppData\\Roaming\\Microsoft\\Windows\\STARTM~1\\Programs\\Startup\\kinto-start.vbs") - + userpath = cmdline('cmd /c for %A in ("%userprofile%") do @echo %~sA')[:-1] + print('Starting... "' + userpath + '\\AppData\\Roaming\\Microsoft\\Windows\\STARTM~1\\Programs\\Startup\\kinto-start.vbs"') + os.system('"' + userpath + '\\AppData\\Roaming\\Microsoft\\Windows\\STARTM~1\\Programs\\Startup\\kinto-start.vbs"') # # print("\nPlease log off and back on for changes to take full effect.") print("If using WSL then please remember to right click on title bar -> Properties -> Edit Options -> Use Ctrl+Shift+C/V as Copy/Paste and enable it.") else: diff --git a/windows/detectUSB.ahk b/windows/detectUSB.ahk index f09c33f..18f9ddd 100644 --- a/windows/detectUSB.ahk +++ b/windows/detectUSB.ahk @@ -11,13 +11,12 @@ 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") + exec := WshShell.Exec("cscript /nologo ""%userprofile%\.kinto\usb.vbs""") kbtype := exec.StdOut.ReadAll() DllCall("FreeConsole") Process Close, %pid% @@ -27,11 +26,11 @@ notify_change(wParam, lParam, msg, hwnd) if InStr(kbtype, "Apple") { ; MsgBox, Apple - Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat mac, %A_ScriptDir% + 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% + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" win, "%A_ScriptDir%" } ; MsgBox % kbtype } diff --git a/windows/kinto-start.vbs b/windows/kinto-start.vbs index fbe1078..374a1a4 100644 --- a/windows/kinto-start.vbs +++ b/windows/kinto-start.vbs @@ -2,6 +2,6 @@ Set oShell = CreateObject("Shell.Application") Set wShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") -path = wShell.ExpandEnvironmentStrings("%userprofile%") -strFolder = fso.BuildPath(path, "\.kinto\kinto.ahk") +path = wShell.ExpandEnvironmentStrings("""%userprofile%") +strFolder = fso.BuildPath( path, "\.kinto\kinto.ahk""") oShell.ShellExecute "C:\Program Files\AutoHotkey\AutoHotkey.exe", strFolder, , "runas", 0 \ No newline at end of file diff --git a/windows/kinto.ahk b/windows/kinto.ahk index 548f8e2..9e722aa 100644 --- a/windows/kinto.ahk +++ b/windows/kinto.ahk @@ -46,11 +46,11 @@ Menu, Tray, Add, Close, Exit Menu, Tray, Click, 1 winkb(){ - Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat win, %A_ScriptDir% + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" win, "%A_ScriptDir%" } mackb(){ - Run, %A_ScriptDir%\NoShell.vbs %A_ScriptDir%\toggle_kb.bat mac, %A_ScriptDir% + Run, "%A_ScriptDir%\NoShell.vbs" "%A_ScriptDir%\toggle_kb.bat" mac, "%A_ScriptDir%" } min(){ @@ -134,6 +134,8 @@ GroupAdd, vstudio, ahk_exe devenv.exe GroupAdd, intellij, ahk_exe idea.exe GroupAdd, intellij, ahk_exe idea64.exe +; SetCapsLockState, AlwaysOff ; CB/IBM + #IfWinNotActive ahk_group virtm ; New AltTab and CtrlTab fix @@ -265,7 +267,7 @@ GroupAdd, intellij, ahk_exe idea64.exe ^+Up::Send ^+{Home} ^Down::Send ^{End} ^+Down::Send ^+{End} - ^Backspace::Send +{Home}{Delete} + $^Backspace::Send +{Home}{Delete} !Backspace::Send ^{Backspace} !Left::Send ^{Left} !+Left::Send ^+{Left} @@ -273,7 +275,7 @@ GroupAdd, intellij, ahk_exe idea64.exe !+Right::Send ^+{Right} ; Cmd+Space Alternative - ^Space::Send ^{Esc} + $^Space::Send ^{Esc} #IfWinActive ahk_group intellij ; General @@ -310,7 +312,7 @@ GroupAdd, intellij, ahk_exe idea64.exe #+q::Send !q ;Context info #!o::Send ^!o ;Optimize imports #!i::Send ^!i ;Auto-indent line(s) - ^Backspace::Send ^y ;Delete line at caret + $^Backspace::Send ^y ;Delete line at caret #+j::Send ^+j ;Smart line join !Delete::Send ^{Delete} ;Delete to word end !Backspace::Send ^{Backspace} ;Delete to word start @@ -370,6 +372,9 @@ GroupAdd, intellij, ahk_exe idea64.exe ; Sublime Text Remaps for VS Code #IfWinActive ahk_group vscode + #p::send {Up} ; Allow for traversing quick list + #n::send {Down} ; Allow for traversing quick list + #Space::Send ^{Space} ; Basic code completion ; Remap Ctrl+Shift to behave like macOS Sublimetext ; Will extend cursor to multiple lines ; #+Up::send ^!{Up} ; ST2CODE @@ -382,6 +387,7 @@ GroupAdd, intellij, ahk_exe idea64.exe #If #IfWinActive ahk_exe sublime_text.exe + #Space::Send ^{Space} ; Basic code completion #^Up::send !{O} ; Switch file #^f::send {F11} ; toggle_full_screen ^!v::send {Ctrl Down}k{Ctrl Up}{Ctrl Down}v{Ctrl Up} ; paste_from_history diff --git a/windows/usb.vbs b/windows/usb.vbs index ab0cdef..7cdf704 100644 --- a/windows/usb.vbs +++ b/windows/usb.vbs @@ -1,5 +1,5 @@ Option Explicit -Dim oWMISrv, collDvcs, iUSBDvc , iDvc, sDvcID, sPID, sVID +Dim oWMISrv, collDvcs, iUSBDvc , iDvc, sDvcID, sPID, sVID, deviceID ' add item to array Function AddItem(arr, val) @@ -49,21 +49,23 @@ Dim nonApple: nonApple = 0 Dim i If vcount = 1 Then + deviceID = deviceVID(0) If StrComp(deviceVID(0), "05AC") = 0 Then - Wscript.Echo "Apple" + Wscript.Echo "Apple " & deviceID Else - Wscript.Echo "Windows" + Wscript.Echo "Windows " & deviceID End If Else For i = 0 To counter-1 + deviceID = deviceVID(i) If StrComp(deviceVID(i), "05AC") = -1 Then nonApple = 1 End If Next If nonApple = 1 Then - Wscript.Echo "Windows" + Wscript.Echo "Windows " & deviceID Else - Wscript.Echo "Apple" + Wscript.Echo "Apple " & deviceID End If End If diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 897d81b..6f661ed 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -214,6 +214,7 @@ define_keymap(None,{ }) define_keymap(lambda wm_class: wm_class.casefold() not in mscodes,{ + K("Super-Space"): K("C-Space"), # Basic code completion # Wordwise remaining - for Everything but VS Code K("M-Left"): K("C-Left"), # Left of Word K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word @@ -273,6 +274,7 @@ define_keymap(re.compile(codeStr, re.IGNORECASE),{ # Keybindings for Sublime Text define_keymap(re.compile("Sublime_text", re.IGNORECASE),{ + K("Super-Space"): K("C-Space"), # Basic code completion K("C-Super-up"): K("M-o"), # Switch file K("Super-RC-f"): K("f11"), # toggle_full_screen K("C-M-v"): [K("C-k"), K("C-v")], # paste_from_history