Created
March 14, 2024 05:06
-
-
Save jialeicui/0a6f5328beb83ec525fc3e620f4be0b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SendMode Input | |
SetWorkingDir %A_ScriptDir% | |
SetTitleMatchMode, 2 | |
show_class() | |
{ | |
bbb := WinActive("WeTERM") | |
MsgBox, "%bbb%" | |
WinGetClass, class, A | |
MsgBox, The active window's class is "%class%". | |
Clipboard = %class% | |
} | |
#i::show_class() | |
; ===================== | |
; 1. clipboard | |
; - copy (CMD+C) | |
; - paste (CMD+V) | |
; - cut (CMD+X) | |
; - paste with dest formatting (CMD+ALT+SHIFT+V) | |
#c::Send ^c | |
#v::Send ^v | |
#x::Send ^x | |
#!+v::Send ^+v | |
; ===================== | |
; 2. text editing - cursor manipulation | |
; - jump to beginning/end of line (CMD+Left/Right) | |
; - select to beginning/end of line (CMD+SHIFT+Arrow) | |
; - move between words (ALT+Arrow) | |
; - select by word (ALT+SHIFT+Arrow) | |
#Left::Send {Home} | |
#+Left::Send +{Home} | |
#Right::Send {End} | |
#+Right::Send +{End} | |
#Up::Send ^{Home} | |
#+Up::Send ^+{Home} | |
#Down::Send ^{End} | |
#+Down::Send ^+{End} | |
#Backspace::Send +{Home}{Delete} | |
!Backspace::Send ^{Backspace} | |
!Left::Send ^{Left} | |
!+Left::Send ^+{Left} | |
!Right::Send ^{Right} | |
!+Right::Send ^+{Right} | |
^g::Send {Home} | |
^+g::Send {End} | |
; ===================== | |
; 2b. text editor | |
; - select all (CMD+A) | |
; - find (CMD+F) | |
; - formatting (CMD+B, CMD+I, CMD+U) | |
; - change font size (CMD+SHIFT+>, CMD+SHIFT+<) | |
#a::Send ^a | |
#f::Send ^f | |
#b::Send ^b | |
;#i::Send ^i | |
;#u::Send ^u | |
#+>::Send ^+> | |
#+<::Send ^+< | |
; ===================== | |
; 3. window management | |
; - quit app (CMD+Q) | |
; - switch between | |
; - close window/ta (CMD+W), CMD+` | |
; disclaimer: CMD+` requires Easy Window Switcher neosmart (https://neosmart.net/Download) | |
#q::Send !{F4} | |
#`::Send !~ | |
; ===================== | |
; 4. In-browser actions | |
; - new tab (CMD+T) | |
; - reopen recently closed tab (CMD+SHIFT+T) | |
; - close tab (CMD+W) | |
; - zoom (CMD+=, CMD+SHIFT+=) | |
; - switch between tabs (CMD+1...CMD+0) | |
#t::Send ^t | |
#+t::Send ^+t | |
#w::Send ^w{Esc} | |
#=::Send ^= | |
#-::Send ^- | |
#1::Send ^1 | |
#2::Send ^2 | |
#3::Send ^3 | |
#4::Send ^4 | |
#5::Send ^5 | |
#6::Send ^6 | |
#7::Send ^7 | |
#8::Send ^8 | |
#9::Send ^9 | |
#0::Send ^0 | |
; ===================== | |
; 5. standard actions | |
; - new file (CMD+N) | |
; - new item, used in several apps - (CMD+SHIFT+N), | |
; - open file (CMD+O) | |
; - print (CMD+P) | |
; - save (CMD+S) | |
; - save-as (CMD+SHIFT+S) | |
; - undo (CMD+Z) | |
; - redo (CMD+SHIFT+Z) | |
#n::Send ^n | |
#+n::Send ^+n | |
#o::Send ^o | |
#+o::Send ^+o | |
#p::Send ^p | |
#+p::Send ^+p | |
#s::Send ^s | |
#+s::Send ^!s | |
; ===================== | |
; 6. undo/redo (CMD+Z, CMD+SHIFT+Z) | |
#z::Send ^z | |
#+z::Send ^y | |
; ===================== | |
; 7. additional in-app commands | |
; - CMD+R | |
; - CMD+D | |
; - CMD+\ (requires 1password) | |
; - CMD+], CMD+[, CMD+\ (Visual Studio Code) | |
#r::Send ^r | |
#d::Send ^d | |
#\::Send ^\ | |
#]::Send ^] | |
#[::Send ^[ | |
#/::Send ^/ | |
; ===================== | |
; 8. win10 capture screenshot CTRL+SHIFT+S (since CMD+SHIFT+S has been remapped to Save As) | |
^+s::Send #+s | |
; ===================== | |
; 9. spotlight (CMD+SPACE), tasks (CMD+ALT+ESC) | |
#Space::Send ^{Space} | |
#!Esc::Send ^+{Esc} | |
; ===================== | |
; 10. App-Switcher (CMD+Tab, CMD+Paragraph) | |
; unfortunately CMD+SHIFT+Tab doesn't work (AutoHotKey has very limited support for this, so we use CMD+Paragraph (the key above Tab) to switch to previous app) | |
<#Tab::AltTab | |
<#Sc056::ShiftAltTab | |
; ===================== | |
; 11. MagnetApp-Like window snapping - CTRL+ALT+Arrow | |
^!Left::WinMove, A,, 0, 0, (A_ScreenWidth/2), (A_ScreenHeight) | |
^!Right::WinMove, A,, (A_ScreenWidth/2), 0, (A_ScreenWidth/2), (A_ScreenHeight) | |
^!Up::WinMove, A,, 0, 0, (A_ScreenWidth), (A_ScreenHeight/2) | |
^!Down::WinMove, A,, 0, (A_ScreenHeight/2), (A_ScreenWidth), (A_ScreenHeight/2) | |
^!u::WinMove, A,, 0, 0, (A_ScreenWidth/2), (A_ScreenHeight/2) | |
^!i::WinMove, A,, (A_ScreenWidth/2), 0, (A_ScreenWidth/2), (A_ScreenHeight/2) | |
^!j::WinMove, A,, 0, (A_ScreenHeight/2), (A_ScreenWidth/2), (A_ScreenHeight/2) | |
^!k::WinMove, A,, (A_ScreenWidth/2), (A_ScreenHeight/2), (A_ScreenWidth/2), (A_ScreenHeight/2) | |
; MagnetApp-Like maximize/restore window - CTRL+ALT+Enter | |
^!Enter:: | |
SysGet, VirtualScreenWidth, 78 | |
WinGetPos, X, Y, Width, Height, A | |
If (Virtualscreenwidth = A_ScreenWidth) { | |
If (Width < A_ScreenWidth) { | |
WinMaximize, A | |
} Else { | |
WinRestore, A | |
} | |
} | |
Return | |
global PreviousActiveWindow | |
#u:: | |
DetectHiddenWindows, On | |
if (WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) { | |
if(WinActive("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) { | |
WinActivate, ahk_id %PreviousActiveWindow% | |
} else { | |
WinGet, PreviousActiveWindow, , A ; 'A' for currently active window | |
WinActivate, ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
} | |
} else { | |
TerminalLink = %localappdata%\Microsoft\WindowsApps\wt.exe | |
if FileExist(TerminalLink) { | |
WinGet, PreviousActiveWindow, , A ; 'A' for currently active window | |
Run, %TerminalLink% | |
} else { | |
MsgBox, Windows Terminal not installed | |
} | |
} | |
Return | |
; emacs keybinding without windows terminal | |
;#IfWinNotActive ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
#If not (WinActive("WeTERM") or WinActive("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) | |
$^a::Send {Home} | |
^e::Send {End} | |
^n::Send {Down} | |
$^p::Send {Up} | |
^b::Send {Left} | |
^f::Send {Right} | |
^h::Send {Backspace} | |
^d::Send {Delete} | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment