├── 尝试创建新文档!.txt ├── 虚拟桌面3 →→.ahk ├── 虚拟桌面 1 ←←.ahk ├── 虚拟桌面2 →←.ahk ├── voice.exe ├── justCNEN.exe ├── AutoHotkey.chm ├── open-book.png ├── AutoHotkey64.exe ├── Local_Code HTM postulation.code-workspace ├── workspace i3 Rime.code-workspace ├── justCNEN.ahk ├── Pomodoro.txt ├── Basic_Remap.ahk ├── README.md ├── HotStrings.ahk ├── EMACS.ahk ├── WindowSpy.ahk ├── Mouse.ahk ├── Modifiers.ahk ├── Script_1 not recommend, simplified ├── keys.md ├── Script_2 recommend Enhance keyboard └── MAIN.ahk /尝试创建新文档!.txt: -------------------------------------------------------------------------------- 1 | 尝试创建新文档! 2 | -------------------------------------------------------------------------------- /虚拟桌面3 →→.ahk: -------------------------------------------------------------------------------- 1 | Send("^#{Right}") 2 | ; 3 | -------------------------------------------------------------------------------- /虚拟桌面 1 ←←.ahk: -------------------------------------------------------------------------------- 1 | Send("^#{left 2}") 2 | ; Send("^#{left 2}") 3 | -------------------------------------------------------------------------------- /虚拟桌面2 →←.ahk: -------------------------------------------------------------------------------- 1 | Send("^#{Right 3}") 2 | Send("^#{left 1}") 3 | -------------------------------------------------------------------------------- /voice.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NomandChan/AHK-Direct-IME-changer/HEAD/voice.exe -------------------------------------------------------------------------------- /justCNEN.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NomandChan/AHK-Direct-IME-changer/HEAD/justCNEN.exe -------------------------------------------------------------------------------- /AutoHotkey.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NomandChan/AHK-Direct-IME-changer/HEAD/AutoHotkey.chm -------------------------------------------------------------------------------- /open-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NomandChan/AHK-Direct-IME-changer/HEAD/open-book.png -------------------------------------------------------------------------------- /AutoHotkey64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NomandChan/AHK-Direct-IME-changer/HEAD/AutoHotkey64.exe -------------------------------------------------------------------------------- /Local_Code HTM postulation.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "D:\\我的文件\\Local_Code" 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /workspace i3 Rime.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "..\\..\\..\\AppData\\Roaming\\Rime" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /justCNEN.ahk: -------------------------------------------------------------------------------- 1 | Capslock:: 2 | { 3 | SetCapsLockState("AlwaysOff") 4 | ; clear_mouse_flag_altered() 5 | ; Send("{Esc}") 6 | ; vim user ↑↑↑ 7 | en() 8 | } 9 | RAlt::cn() 10 | ~Esc::en() 11 | 12 | 13 | en(mode := "postmessage"){ 14 | PostMessage 0x0050, 0, 0x4090409,, "A" ; 0x0050 is WM_INPUTLANGCHANGEREQUEST. 15 | 16 | 17 | } 18 | 19 | cn(mode := "postmessage"){ 20 | PostMessage 0x0050, 0, 0x8040804,, "A" 21 | ; 0x4040404 是繁体中文!,简体中文的编号是什么 0x8040804 22 | 23 | 24 | } -------------------------------------------------------------------------------- /Pomodoro.txt: -------------------------------------------------------------------------------- 1 | 🍅 Tuesday, May 10 2022, 7:19 PM 2 | 🍅 Tuesday, May 10 2022, 7:50 PM 3 | 🍅 Wednesday, May 11 2022, 9:26 AM 4 | 🍅 Wednesday, May 11 2022, 10:05 AM 5 | 🍅 Wednesday, May 11 2022, 12:54 PM 6 | 🍅 Wednesday, May 11 2022, 1:24 PM 7 | 🍅 Wednesday, May 11 2022, 1:55 PM 8 | 🍅 Wednesday, May 11 2022, 4:42 PM 9 | 🍅 Wednesday, May 11 2022, 5:22 PM 10 | 🍅 day 11 Year Week:202219 11 | 🍅 day 11 Year Week:202219 12 | 🍅 Year Week:202219day 12 13 | 🍅 completed Year Week:202219day 12 14 | 🍅 completed Year Week:202219day 12 15 | 🍅 completed Year Week:202219day 12 16 | 🍅 completed Year Week:202219day 12 17 | 🍅 completed Year Week:202219day 12 18 | 🍅 completed Year Week:202219day 15 19 | 🍅 completed Year Week:202219day 15 20 | 🍅 completed Year Week:202219day 15 21 | 🍅 completed Year Week:202219day 15 22 | 🍅 completed Year Week:202219day 15 23 | 🍅 completed Year Week:202219day 15 24 | 🍅 completed Year Week:202220day 17 25 | 🍅 completed Year Week:202220day 17 26 | 🍅 completed Year Week:202220day 17 27 | 🍅 completed Year Week:202220day 18 28 | 🍅 completed Year Week:202220day 19 29 | 🍅 completed Year Week:202220day 20 30 | 🍅 completed Year Week:202220day 20 31 | 🍅 completed Year Week:202220day 20 32 | 🍅 completed Year Week:202220day 20 33 | 🍅 completed Year Week:202220day 20 34 | 🍅 completed Year Week:202220day 20 35 | 🍅 completed Year Week:202220day 20 36 | 🍅 completed Year Week:202220day 20 37 | 🍅 completed Year Week:202220day 21 38 | 🍅 completed Year Week:202220day 21 39 | 🍅 completed Year Week:202220day 21 40 | 🍅 completed Year Week:202220day 21 41 | 🍅 completed Year Week:202220day 21 42 | 🍅 completed Year Week:202220day 21 43 | 🍅 completed Year Week:202220day 21 44 | 🍅 completed Year Week:202221day 23 45 | 🍅 completed Year Week:202221day 23 46 | 🍅 completed Year Week:202222day 30 47 | 🍅 completed Year Week:202222day 30 48 | 🍅 completed Year Week:202222day 30 49 | ?? completed Year Week:202222day 31 50 | ?? completed Year Week:202222day 31 51 | ?? completed Year Week:202222day 31 52 | ?? completed Year Week:202222day 31 53 | ?? completed Year Week:202222day 31 54 | ?? completed Year Week:202222day 31 55 | ?? completed Year Week:202222day 31 56 | ?? completed Year Week:202222day 31 57 | ?? completed Year Week:202222day 01 58 | ?? completed Year Week:202222day 02 59 | ?? completed Year Week:202222day 02 60 | ?? completed Year Week:202222day 02 61 | ?? completed Year Week:202222day 02 62 | ?? completed Year Week:202222day 02 63 | ?? completed Year Week:202222day 02 64 | ?? completed Year Week:202222day 02 65 | ?? completed Year Week:202222day 02 66 | ?? completed Year Week:202222day 02 67 | 🍅 completed Year Week:202222day 03 68 | 🍅 completed Year Week:202222day 03 69 | 🍅 completed Year Week:202223day 07 70 | 🍅 completed Year Week:202223day 07 71 | 🍅 completed Year Week:202223day 07 72 | 🍅 completed Year Week:202223day 07 73 | 🍅 completed Year Week:202223day 07 74 | 🍅 completed Year Week:202223day 09 75 | 🍅 completed Year Week:202223day 09 76 | 🍅 completed Year Week:202223day 09 77 | 🍅 completed Year Week:202223day 09 78 | 🍅 completed Year Week:202223day 10 79 | 🍅 completed Year Week:202223day 10 80 | 🍅 completed Year Week:202223day 12 81 | 🍅 completed Year Week:202223day 12 82 | 🍅 completed Year Week:202224day 14 83 | 🍅 completed Year Week:202225day 23 84 | 🍅 completed Year Week:202225day 23 85 | 🍅 completed Year Week:202225day 24 86 | -------------------------------------------------------------------------------- /Basic_Remap.ahk: -------------------------------------------------------------------------------- 1 | ; 不涉及循环的调用函数,只修改 Caps 和 comma 2 | 3 | 4 | 5 | ; ^\::change_to_chn_and_retype() 6 | 7 | 8 | 9 | ; caps+ wasd 控制文本上下左右,qe 左删除右删除, r/f 回到开始回到结尾,uo一样.`n b 打开大学锁定、 T/G更改副文本上标和下标(鼠标滚轮一样)。 zxcv → 撤销、删除一行、回车、软回车 10 | 11 | 12 | ;--------------------这部分最好不同步, , 和 caps 分开。 13 | PrintScreen & 1::Send("^{left}") 14 | PrintScreen & 2::check_calc_space_and_skip_bar("↓↓") 15 | PrintScreen & 3::check_calc_space_and_skip_bar("↑↑") 16 | CapsLock & RShift::SetCapsLockState("AlwaysOn") 17 | PrintScreen::Send("{" A_ThisHotKey "}") 18 | 19 | 20 | 21 | PrintScreen & BackSpace:: ; comma 22 | Capslock & BackSpace::change_to_chn_and_retype() 23 | PrintScreen & Enter:: 24 | Capslock & Enter::change_to_en_and_put_stringSpace() 25 | 26 | ;---------------------------------LHS------------------------------ 27 | ; 逗号 向右偏移的键位。 hjkl ←↓↑→ d↑ f↓ 28 | ; ALT Q 最近两处跳跃,A home/end 两处跳跃 29 | ; c 清除修饰键 v B和N back next 跳转。 m:enter 30 | 31 | 32 | 33 | 34 | PrintScreen & a::Send( modifier "{left}") 35 | PrintScreen & w::SendInput(modifier "{up}") 36 | PrintScreen & s::SendInput(modifier "{down}") 37 | PrintScreen & d::SendInput(modifier "{right}") 38 | 39 | 40 | 41 | PrintScreen & t::Send(modifier "{PgUp}") 42 | PrintScreen & g::Send(modifier "{PgDn}") 43 | PrintScreen & r::Send("{Enter}") 44 | 45 | 46 | PrintScreen & q::Send(modifier "{bs}") 47 | PrintScreen & e::Send(modifier "{delete}") 48 | 49 | PrintScreen & f:: 50 | { 51 | repeatTime:= updateSharedRepeat(,2) 52 | switch repeatTime 53 | { 54 | case 0: send("{end}") 55 | case 1: send("{home}") 56 | 57 | } 58 | return 59 | } 60 | 61 | 62 | PrintScreen & LShift::global modifier .= "+" 63 | PrintScreen & LCtrl::global modifier .= "^" 64 | PrintScreen & LAlt::global modifier .= "!" 65 | PrintScreen & Lwin::global modifier .= "#" 66 | PrintScreen & c::global modifier := "" 67 | PrintScreen & V::Text_only_paste() 68 | 69 | 70 | ;---------------------------RHS------------------------ 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | ; 右边半区负责框选 hjkl ←↓↑→ 79 | 80 | PrintScreen & u::Send("^+{Left}") 81 | PrintScreen & o::Send("^+{Right}") 82 | PrintScreen & j::Send("^{Left}") 83 | PrintScreen & l::Send("^{Right}") 84 | PrintScreen & i::Send("+{up}") 85 | PrintScreen & k::Send("+{down}") 86 | 87 | PrintScreen & m::Send("{BackSpace}") 88 | PrintScreen & .::Send("{enter}") ; 必须用 sc 代码 89 | PrintScreen & sc034::Send("{enter}") ; 90 | 91 | 92 | 93 | 94 | PrintScreen & N::Send("!{right}") 95 | PrintScreen & b::Send("!{left}") ; 前后跳转最有用了,重新定义一下更好用。 96 | 97 | 98 | ; 对输入法莫大的提升,不去选数字而是利用 GUI 选择。 ( IME 确定是 回车,其他非方向的情况下是空格。) 99 | PrintScreen & space:: 100 | { 101 | if( A_PriorHotkey == "PrintScreen & s" or A_PriorHotkey == "PrintScreen & a" or A_PriorHotkey == "PrintScreen & d" or A_PriorHotkey == "PrintScreen & w" or ( A_PriorHotkey == "PrintScreen & space" And A_TimeSincePriorHotkey < 1000)) 102 | Send("{Space}") 103 | else { 104 | Send("{enter}") ; space 智能一点:只有方向键选择以后,需要空格确定而不是回车。 105 | } 106 | return 107 | } 108 | 109 | 110 | 111 | PrintScreen & WheelUp::Send("{PgUp}") 112 | PrintScreen & WheelDown::Send("{PgDn}") 113 | 114 | 115 | 116 | 117 | 118 | 119 | ;---------------------------------LHS------------------------------ 120 | ; 逗号 向右偏移的键位。 hjkl ←↓↑→ d↑ f↓ 121 | ; ALT Q 最近两处跳跃,A home/end 两处跳跃 122 | ; c 清除修饰键 v B和N back next 跳转。 m:enter 123 | 124 | 125 | 126 | 127 | Capslock & a::Send( modifier "{left}") 128 | Capslock & w::SendInput(modifier "{up}") 129 | Capslock & s::SendInput(modifier "{down}") 130 | Capslock & d::SendInput(modifier "{right}") 131 | 132 | 133 | 134 | Capslock & t::Send(modifier "{PgUp}") 135 | Capslock & g::Send(modifier "{PgDn}") 136 | Capslock & r::Send("{Enter}") 137 | 138 | 139 | Capslock & q::Send(modifier "{bs}") 140 | Capslock & e::Send(modifier "{delete}") 141 | 142 | Capslock & f:: 143 | { 144 | repeatTime:= updateSharedRepeat(,2) 145 | switch repeatTime 146 | { 147 | case 0: send("{end}") 148 | case 1: send("{home}") 149 | 150 | } 151 | return 152 | } 153 | 154 | 155 | Capslock & LShift::global modifier .= "+" 156 | Capslock & LCtrl::global modifier .= "^" 157 | Capslock & LAlt::global modifier .= "!" 158 | Capslock & Lwin::global modifier .= "#" 159 | Capslock & c::global modifier := "" 160 | Capslock & V::Text_only_paste() 161 | Capslock & p::Send("{Media_Play_Pause}") 162 | 163 | 164 | 165 | ;---------------------------RHS------------------------ 166 | 167 | ; 右边半区负责框选 hjkl ←↓↑→ 168 | 169 | Capslock & u::Send("^+{Left}") 170 | Capslock & o::Send("^+{Right}") 171 | Capslock & j::Send("^{Left}") 172 | Capslock & l::Send("^{Right}") 173 | Capslock & i::Send("+{up}") 174 | Capslock & k::Send("+{down}") 175 | 176 | Capslock & m::Send("{BackSpace}") 177 | Capslock & .::Send("{enter}") ; 必须用 sc 代码 178 | Capslock & sc034::Send("{enter}") ; 179 | 180 | 181 | 182 | Capslock & N::Send("!{right}") 183 | Capslock & b::Send("!{left}") ; 前后跳转最有用了,重新定义一下更好用。 184 | 185 | ; 不去选数字而是利用 GUI 选择。 ( IME 确定是 回车,其他非方向的情况下是空格。) 186 | Capslock & space:: 187 | { 188 | ;And A_TimeSincePriorHotkey < 1000 189 | if( A_PriorHotkey == "Capslock & s" or A_PriorHotkey == "Capslock & a" or A_PriorHotkey == "Capslock & d" or A_PriorHotkey == "Capslock & w" or A_PriorHotkey == "Capslock & space" ) 190 | Send("{Space}") 191 | else { 192 | Send("{Space}") ; space 智能一点:只有方向键选择以后,需要空格确定而不是回车。 193 | } 194 | return 195 | } 196 | 197 | 198 | 199 | Capslock & WheelUp::Send("{PgUp}") 200 | Capslock & WheelDown::Send("{PgDn}") 201 | 202 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # AHK 直接切换中英文 Swtich Input Method & Type Greek symbols 3 | (注意使用 AHK v2 运行脚本文件) 4 | 5 | 最方便的切换方式 6 | --- 7 | 8 | ; 把之前的字退回,重新送给 IME。 MAIN 文件里搜索这个函数: 9 | change_to_chn_and_retype() 10 | 11 | 输入法中切英平常的时候会直接上屏,但是英切中不会 “后悔”,所以手动写了这个方法。把前几个字剪切,一个字一个字重新发送,送进 IME 里面。这样能永远埋头打字,发现错误再事后矫正,我称之为最方便的切换方法。 12 | 我把它分配给了` ^space::change_to_chn_and_retype()`。 替代原始 ctrl+space. 但注意要保留 shift 原本功能,因为整个流程是` eng 状态、向左选择、剪切、shift 切换 chn 状态,发送文字` 13 | 14 | ## 最粗暴的方式,使用 windows 的接口直接切换中文、英文的方法! 15 | 16 | 使用 windows 接口 不用任何设置、不用快捷键! 17 | ``` 18 | RAlt::PostMessage, 0x50, 0, 0x4090409,, A 19 | LAlt::PostMessage, 0x50, 0, 0x8040804,, A 20 | ``` 21 | 22 | 其他切换方式 23 | --- 24 | MAIN 文件上面搜索这个: 25 | cn(mode := "两次切换Ctrl+Shift", smart_half:=0){ 26 | 27 | 里面包含了很多种指定切换中英文的方式。 28 | 29 | 30 | 利用 AHK 多样的触发方式 31 | --- 32 | 发挥你们的创造力!自己打造智能切换的输入法。例如每次碰 ~Esc:: 都调用这个,就能愉快👌🏻使用 VIM 了。 33 | hotstring 触发、F1等当修饰等等 34 | 35 | 我个人最喜欢的切换方式:并击 “ik”→ 中文, “ed"→ Eng ,只有同时按下才触发,标准指法根本不可能影响正常打字: 36 | ``` 37 | ; ~i:: 38 | ~k:: 39 | { 40 | ; check_io_pressed_in_the_same_time() 41 | ; if( GetKeyState("j") and GetKeyState("i") and GetKeyState("o")) 42 | if( GetKeyState("i")){ 43 | Send("{bs 2}") 44 | Sleep(200) 45 | cn() 46 | 47 | 48 | } 49 | 50 | } 51 | ; ~e:: 52 | ~d:: 53 | { 54 | ; check_ew_pressed_in_the_same_time() 55 | if( GetKeyState("e") and GetKeyState("d") ){ 56 | Send("{bs 2}") 57 | Sleep(200) 58 | en() 59 | } 60 | } 61 | 62 | ~Esc::en() 63 | Capslock:: 64 | { 65 | SetCapsLockState("AlwaysOff") 66 | en() 67 | 68 | } 69 | Shift::smartVimCN() 70 | RAlt::cn() 71 | 72 | ; LCtrl::cn() 这个不能要 73 | 74 | smartVimCN(){ 75 | if WinActive("ahk_exe Obsidian.exe"){ ; 这个笔记本里才生效,其他软件不生效。 encn 切换及时 vim 状态错了也会被冲刷掉。 76 | en() 77 | Send("{i}") ; VIM 的输入模式 78 | cn() 79 | } 80 | else { 81 | cn() 82 | } 83 | } 84 | ``` 85 | 86 | 87 | 88 | ↑↑↑ 89 | 参考: http://tll.tl/zh/ 90 | ↑↑↑ 91 | 這兩行的功能是將::前的按鍵,右Alt或左Alt定義成後面的功能,也就是將現在的鍵盤配置切換為中文(0x4040404)或英文(0x4090409)。同理,你也可以設定成自己想要的任何按鍵(例如,Capslock、LWin、LCtrl、AppsKey)。用這種方式重新指定修飾鍵(Modifier,也就是Alt、Ctrl這類要和其他按鍵組合才有功能的鍵)並不會破壞其他快速鍵,因此相當於是鍵盤多了一個快捷鍵。 ; 0x4040404 是繁体中文!,简体中文的编号是 0x8040804 92 | 93 | 别的键盘布局可以通过这个函数查看! 94 | ``` 95 | checkCurrentKeyboardLayout() { 96 | ThreadId := DllCall("User32.dll\GetWindowThreadProcessId", "Ptr", WinExist("A"), "Ptr", 0, "UInt") 97 | 98 | hCurrentKBLayout := DllCall("User32.dll\GetKeyboardLayout", "UInt", ThreadId, "Ptr") 99 | msgbox(hCurrentKBLayout) 100 | return 101 | } 102 | ``` 103 | 104 | # AHK V2 各种小功能,调用搜索、查词等等 105 | 写这么多,只适合我自己;只有一点学习分享价值,还是放在这留着吧…… 106 | 语音播报选择的txt、发送给网页进行搜索,鼠标边缘手势等等等,太多了懒得写介绍,希望学习 AHK V2 的人可以自己进去翻翻学习。有些函数前面有注释,VSCODE 插件能看见,还可以跳转定义,一定要装这个插件: autohotkey2 language support。 107 | AHK 可玩性太高了,可以通过任意的按键进行功能组合、调用……但脚本越来越臃肿。 108 | 109 | -------------- 110 | 最近才发现这个项目 https://github.com/jbensmann/mouseless, 只有 linux 下可以用。 111 | 他写的鼠标模式、键盘方向键模式很简洁,默认配置文件只有七十多行,软件还是专一一些好,不会像我一样,脚本越来越大,越来越容易起冲突;搞到最后我自己都不想用了…… 112 | 113 | 114 | 115 | 下面有两个文件是 AHK V1 的代码,没什么参考价值了。 116 | 117 | ## Functions AHK V1 script: 118 | * Quick switch between English keyboard and Chinese/Japanese/Korean IME. It detect Language code, tap CAPSLOCK to select English and long press it to CTRL+SHIFT(or anything you want). 119 | * Caps+ wasd to help type point moving, q/e for delete leftward/rightward. Caps+ B for bold. 120 | * Hotstrings to type math unicode symbole (see below). 121 |
122 | 123 | To type Greek letters, "α", just a + \` , Σ for S and \`,; To type your email: dontclick@gmail.com for email\`, ½ ← half\`, ∫ ← integral\`. ;
124 | Type superscript/underscript unicode math equation: " y̅ = C₁eʳ¹ᵗ + C₂eʳ²ᵗ+ C₃eʳ³ᵗ" by pressing Combo keys “Esc +3456rty” or "F1 +123rt"
125 | To change language, there are two logic presented in script 2. Toggle or designate language. In toggling logic, press Caps is simply control+shift. In designate logic, tap to select ENG and long press to selcet CHN.
126 | To move insertion point by "CAPS + wasd". Script 2 is more responsive but need run in Administrator mode: it detect double tap, recording keys and times like another keyboard is running in your physical keyboard; Script 1 is much more easier to understand (and not great)
127 | 128 | 129 | 130 | 131 | 132 | 133 |   134 | 大小写键用来切换输入法,光这一点就值得用😃,脚本内还有了很多数学、短语、希腊字符的快速输入方法,快速切换输入环境、输入特殊字符,用上就是赚到。
135 | 136 |
You just found a treasure. AHK can automatize everything, using it to edit HTML webpages, store codelet, quick typing phone numbers and address, and control windows programs and mouse.(which is too complicated to be included in here).the AHK built in function are easy/good to use.
137 | ## AHK setting up 138 | Install AHK → create txt and copy it → change .txt suffix to .ahk → run it 139 | 140 | 141 | ## How to use this 脚本基本功能 142 | * CapsLock to swtich language 用来切换中文英文。
143 | * hotstring :( something and a end character )快捷键:字母(letter of string)+ \`撇号得到希腊字母和数字上下标,例如:a+\` → α,c + \` →ξ ,C+\`→Ξ
144 | * Combo keys :组合键 : ESC +1234 → 数字上标: ¹²³⁴ ;数字下标F1 + 1234-=[] → ₁₂₃₄₋₌₍₎
145 | * text selecting funcion: Caps + wasd to move with typing, Caps + Space + wasd to rapidly move. (advanced mode is in script 2 and need administrator mode to run it) 146 | 147 |

148 | 149 | 字母,加撇\` →→ 希腊字母 ;单词加撇 →→ 常用短语,例如 150 | email+结束符\`得到自定义短语: cmyistu@gmail.com。 151 | 字母+结束符\`得到希腊字母: a+\`→ α S+\` →Σ x+ \` → χ half+ \` → ½ quater + Tab → ¼ 152 | 组合键用来输入上下标,例如 Esd + 123 → ¹²³ F1+123 → ₁₂₃ Esc + e →ᵉ 153 | 154 |
155 | 安装 AHK (文末) → 新建 txt,复制脚本进去 → 改文件名后缀为 .ahk → 运行。
156 |  输入希腊字符的方式是,hotstring+结束符,结束符是 tab 或 撇号。hotstring 最方便了,让你用说话的同时输入特殊符号,相当于一个自己写的输入法。输入这些让人头疼的数学符号,在 AHK 的帮助下,unicode 也可以完成很多数学公式的展示,这种方式不需要复杂的插件支持,人人都可以复制粘贴,非常方便。
157 |   The apostrophe end character was space or enter by default AHK setting, but I changed it to Tab and \` (either of them), cuz it's already used by Chinese IME.
158 | 展示一下 Unicode 输入公式是什么样的: 159 |

160 | 161 | Σⁿ₀ αₙ = Σⁿ₀ 1/n² 162 | 163 | f(ε)= ∫ᵇₐ f(x)dx /|b-a| 164 | 165 | ∫ᵇₐ f(x)g(x)dx = f(ε) ∫ᵇₐ g(x)dx , ε∈(a,b) 166 | 167 | f'(x)/1+f(x)² ← d arctan f(x) 168 | 169 | X~χ² (n) X∼N(μ₁+μ₂,√(σ²₁+σ²₂)) 170 | 171 | Variance[H(N,M,n)]=nᐧ(M⁄n)ᐧ(1-M⁄N)ᐧ(N-n)/(N-1) 172 | 173 | ↑←↓→⁰ αk3¹λοπ⁹ 174 | ⁺⁻⁼ ⁽ ⁾ ₀ ₁ ₂ ₃⁺⁻ᐧ/÷×-+≠≡≈≝≤≥∂∞∘∫∫∂∮∯∇ ◠◡ ), ᵘ ᵛ ʷ ˣ ʸ ᶻ ᴮ ᴰ ᴱ ( ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ). 175 | 176 |




177 | 具体实现很细节,请见 script 2 178 | For non-english users, it's a pain to type formula and text simutaneously, juggling between them is already annoying for bilinguals and IME is getting in the way. So I made this script to make life easier by using rarely used Capslock to switch language, move typing point and making hotstring and quick replacement for math symbols, greek letters, and selfdefined unicode strings.
179 |  将 CapsLock 变废为宝,把长按\短按大写锁定变成切换语言的功能,是中文用户必不可少的自定义;将希腊字母,上下标映射到组合键和快捷键上,而且当用户掌握以后,可以自行添加符号“ ℱℒ𝒵” 等。 再加上组合键、快捷方式,使键盘顺手不少,(甚至用于账号密码保存)。这个脚本是我自己每天都使用的,希望这篇文章帮助大家打开新世界。
180 | 181 | -------------------------------------------------------------------------------- /HotStrings.ahk: -------------------------------------------------------------------------------- 1 | 2 | ; *不需要结束字符触发、x 是命令模式、o 是忽略最后添加的空格。 3 | ; ? (question mark): The hotstring will be triggered even when it is inside another word; that is, when the character typed immediately before it is alphanumeric. For example, if :?:al::airline is a hotstring, typing "practical " would produce "practicairline ". Use ?0 to turn this option back off. 4 | ;#Hotstring EndChars -()[]{}:;'"/\,.?!`n `t 5 | #HotString EndChars `t.- 6 | #HotString o k50 ; omitted ending space 7 | 8 | 9 | 10 | 11 | Esc & 2::² ;;这个上标太常用了 12 | Esc & 0::₀ 13 | Esc & w::func_superscript_text() 14 | Esc & s::func_underscript_text() 15 | Esc & f::ᶠ ; f 只有上标没有下标。 16 | 17 | 18 | 19 | 20 | :oC:/0::⁄// 21 | :oC:/1::⁄ 22 | :oC:lt::≤ ; less than 23 | :oC:<=::≤ ; less than 24 | :oC:>=::≥ ;greater than, 25 | :oC:gt::≥ ;greater than, 26 | 27 | 28 | 29 | Esc & n::Send("ᵃᵅᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ") ;上标 superscript 特殊字母的 abcd=>>ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts 30 | Esc & u::Send("ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓ") 31 | F1 & i::ᵢ 32 | F1 & n::ₙ 33 | 34 | 35 | :o:*.::ᐧ ; small multiply ᐧᐧᐧᐧᐧᐧᐧᐧ 36 | :o:*x::× ; multiply 37 | :o:/::÷ ; devide 38 | ; :o:8::* ; 无 shift 能方便很多。 39 | ; :o:=::+ ; 无 shift 能方便很多。 40 | ; :o:-::- ------=== **9 9 0 9 0 41 | 42 | 43 | 44 | ::par::∂ 45 | ::partial::∂ 46 | ; 1⁄1 2/2 3/3 三种除法 47 | ::int:: ∫ 48 | ::inf:: ∞ 49 | ::infinity:: ∞ 50 | 51 | ::sqrt:: √ 52 | 53 | :oC:+-::± 54 | :oC:!=::≠ 55 | :oC:~=::≈ 56 | :oC:y=::≈ 57 | :oC:-.::-> 58 | 59 | :oC:1/2::½ 60 | :oC:1/4::¼ 61 | :oC:1/4::¼ 62 | 63 | 64 | ::half:: ½ 65 | ::quater:: ¼ 66 | ::variesas::∝ 67 | ::neq:: ≠ 68 | 69 | 70 | ::nabla::𝛁 ;nabla。 71 | ::del::𝛁 ;nabla 又叫 del 72 | ::sum:: Σ ;大写 s 加 撇号也行。 73 | ::vec:: ⃗ ;vector 向量箭头 可能显示不出来 74 | ::tilde::{Sc029} 75 | ::semicolon::SC027 76 | ::fx::f(x) 77 | ::Fx::F(x) 78 | ::fx'::f'(x) 79 | ::fx''::f⁽²⁾(x) 80 | ::fx2::f(x)² 81 | ::belong:: x ∈ (0,∞) ;belong 属于 82 | 83 | 84 | ;自定义短语 αβγδκλμνξπρρστυφχψωθ 85 | ;( ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ ), 86 | ;a full superscript Latin lowercase alphabet except q ( ᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ ), 87 | ;a limited uppercase Latin alphabet ( ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ), 88 | ;a few subscripted lowercase letters ( ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ ), 89 | ;and some Greek letters ( ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ). 90 | ; 候选无冲突: engs chns vywr vw yw不行 https://www.thefreedictionary.com/words-containing-uio 91 | 92 | ;---------------------------------- 93 | ::email::c15601360539@gmail.com 94 | 95 | 96 | ::nb::🐮🍺 97 | ::stars::✶★☆✯ ⭐️⭐ 🌟✨✸✹ 98 | ;--------------------------------- 99 | 100 | 101 | ::jiji::基极 102 | ::jidjji::集电极 103 | ::bji:: 基极 104 | ::cji:: 集电极 105 | ::eji:: 发射极 106 | ::gji:: 栅极 107 | ::dji:: 漏极 108 | ::sji:: 源极 109 | 110 | ::proxy1::set http_proxy=http://127.0.0.1:7890`nset https_proxy=http://127.0.0.1:7890`n 111 | :x:proxy2::Send("set http_proxy=http://127.0.0.1:7890`nset https_proxy=http://127.0.0.1:7890`n") 112 | :x:proxy3::Send("{Raw}set http_proxy=http://127.0.0.1:7890`nset https_proxy=http://127.0.0.1:7890`n") 113 | :x:runproxy::Run(A_ScriptDir "\Batch\cmdproxy.bat") 114 | 115 | 116 | 117 | 118 | 119 | Capslock & Up::↑ 120 | Capslock & Down::↓ 121 | Capslock & Left::← 122 | Capslock & Right::→ 123 | Capslock & =::⟷ 124 | :oC:defs::⟺ ≝ ⟸ ⟾ 125 | ; laplace transform 126 | ; Fourier transform 127 | ; Z transform 128 | :oC:laplace::ℒ ℱ 𝒵 129 | 130 | 131 | 132 | 133 | 134 | 135 | F4 & m::Send("✶ * ᵀ") ;transpose of a Matrix convolution 卷积 Adjugate matrix 136 | 137 | 138 | F4 & o::Send("∪") ;union 139 | F4 & 7::Send("∩") ;intersection 140 | 141 | F4 & s:: 142 | { 143 | repeatTime:= updateSharedRepeat(" bar letter,Greeks,curly,integral,summation,brackets,bracckets 2,sets,arrows") 144 | switch repeatTime 145 | { 146 | case 0: Send("{Raw}oterh letters with bar:`nA̅ B̅ C̅ D̅ a̅ b̅ c̅ d̅ α̅ β̅ γ̅ δ̅ ε̅ x̅ X̅ y̅ ĀāḆḇḎḏĒēḠḡH̱ẖĪīḴḵḺḻṈŌōṞṟṮṯŪūX̱x̱ȲȳẔẕ") 147 | case 1: Send("Captical/Greek supersprits and suberscripts:`nᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ") 148 | case 2: Send("{Raw}see more A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 curly letters, calligraphy script, Bold Italic at wiki : https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols") 149 | case 3: Send("{Raw}∫∬∭⨌∱⨑∲∳ ∮∯∰") 150 | case 4: Send("{Raw}summation and integral `n⎲⎳⌠⌡") 151 | case 5: Send("{Raw}brackets:`n ⎛⎝⎜⎝⎧⎨⎪⎩") 152 | case 6: Send("{Raw}ction bracket:`n⎛`n⎨`n⎪`n⎩") 153 | case 7: Send("{Raw}϶∀∁∃∄∅∈∉∵∴") 154 | case 8: Send("emoji ⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙ 💫 ⭐️ 🌟 ✨ ⚡️ ☄️ 💥 🔥 🌪 🌈 ☀️ 🌤 ⛅️ ☁️ 🌦 🌧 ⛈ 🌩 🌨 ❄️ ☃️ ⛄️ 🌬 💨 💧 💦 ☔️ ☂️ 🌊 🌫✔️❌♠️♥️♦️♣️") 155 | } 156 | return 157 | } 158 | 159 | 160 | 161 | 162 | 163 | ; 添加C 代表区分大小写,这样能完整的映射希腊大小写字母。 但是这样占用按键太多了. ;; ; ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ https://en.wikipedia.org/wiki/Beta_Code 164 | 165 | ; :oC:a::α ; lower case alpha 166 | ; :oC:b::β ; lower case beta 167 | ; :oC:c::ξ ; lower case xi 168 | ; :oC:d::δ ; lower case delta 169 | ; :oC:e::ε ; lower case epsilon 170 | ; :oC:f::φ ; lower case phi 171 | ; :oC:g::γ ; lower case gamma 172 | ; :oC:h::η ; lower case eta 173 | ; :oC:i::ι ; lower case iota 174 | ; :oC:k::κ ; lower case kappa 175 | ; :oC:l::λ ; lower case lambda 176 | ; :oC:m::μ ; lower case mu 177 | ; :oC:n::ν ; lower case nu 178 | ; :oC:o::ο ; lower case omicron 179 | ; :oC:p::π ; lower case pi 180 | ; :oC:q::θ ; lower case theta , θ (think, birthday, south) 181 | ; :oC:ql::ð ; ð voiced th (the, father, them) 182 | ; :oC:r::ρ ; lower case rho 183 | ; :oC:s::σ ; lower case sigma 184 | ; :oC:t::τ ; lower case tau 185 | ; :oC:u::υ ; low er case upsilon 186 | ; :oC:w::ω ; lower case omega 187 | ; :oC:x::χ ; lower case chi 188 | ; :oC:y::ψ ; lower case psi 189 | ; :oC:z::ζ ; lower case zeta 190 | 191 | ; :oC:A::Α ; capital alpha 192 | ; :oC:B::Β ; capital beta 193 | ; :oC:C::Ξ ; capital xi 194 | ; :oC:D::Δ ; capital delta 195 | ; :oC:E::Ε ; capital epsilon 196 | ; :oC:F::Φ ; capital phi 197 | ; :oC:G::Γ ; capital gamma 198 | ; :oC:H::Ε ; capital eta 199 | ; :oC:I::Ι ; capital iota 200 | ; :oC:K::Κ ; capital kappa 201 | ; :oC:L::Λ ; capital lambda 202 | ; :oC:M::Μ ; capital mu 203 | ; :oC:N::Ν ; capital nu 204 | ; :oC:o::Ο ; capital omicron 205 | ; :oC:P::Π ; capital pi 206 | ; :oC:Q::Θ ; capital theta 207 | ; :oC:R::Ρ ; capital rho 208 | ; :oC:S::Σ ; capital sigma 209 | ; :oC:T::Τ ; capital tau 210 | ; :oC:U::Υ ; capital upsilon 211 | ; :oC:W::Ω ; capital omega 212 | ; :oC:X::Χ ; capital chi 213 | ; :oC:Y::Ψ ; capital psi 214 | ; :oC:Z::Ζ ; capital zeta 215 | :oC:greeksall::Send("{Raw}ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκΛλΜμΝνΞξΟοΠπΡρΣσςΤτΥυΦφΧχΨψΩω") 216 | ;直接使用上下标的 unicode码。¹²³₁₂₃ ;⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ 上标 superscript 217 | 218 | 219 | ; https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts 220 | :oC:u+::⁺ ; capital capital zetaRaw 221 | :oC:u-::⁻ 222 | :oC:u=::⁼ 223 | :oC:u(::⁽ 224 | :oC:u)::⁾ 225 | 226 | :oC:u1::¹ 227 | :oC:u2::² 228 | :oC:u3::³ 229 | :oC:u4::⁴ 230 | :oC:u5::⁵ 231 | :oC:u6::⁶ 232 | :oC:u7::⁷ 233 | :oC:u8::⁸ 234 | :oC:u9::⁹ 235 | :oC:u0::⁰ 236 | 237 | ;------------- 下标 subscript 238 | :oC:d+::₊ 239 | :oC:d-::₋ 240 | :oC:d=::₌ 241 | :oC:d(::₍ 242 | :oC:d)::₎ 243 | 244 | :oC:d1::₁ 245 | :oC:d2::₂ 246 | :oC:d3::₃ 247 | :oC:d4::₄ 248 | :oC:d5::₅ 249 | :oC:d6::₆ 250 | :oC:d7::₇ 251 | :oC:d8::₈ 252 | :oC:d9::₉ 253 | :oC:d0::₀ 254 | ;------------- 下标 subscript 255 | 256 | ; *不需要结束字符触发、x 是命令模式、o 是忽略最后添加的空格。 257 | ; ? (question mark): The hotstring will be triggered even when it is inside another word; that is, when the character typed immediately before it is alphanumeric. For example, if :?:al::airline is a hotstring, typing "practical " would produce "practicairline ". Use ?0 to turn this option back off. 258 | 259 | ; #HotString *oCx 260 | ; ::FD::en() 261 | ; ::DF::cn() 262 | ; ::JK::en() 263 | ; ::KJ::cn() 264 | 265 | #HotString *oCx? 266 | ::SDF::change_to_chn_and_retype() ; 想要重复利用,就得让短的编码不能及时触发。 267 | ::FDS::change_to_en_and_put_stringSpace() 268 | ::DAW::delete_a_word() 269 | ::DTE::delete_from_here_to_end_of_the_line() ; to end 270 | ::DTL::delete_one_line() ; the line 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /EMACS.ahk: -------------------------------------------------------------------------------- 1 | ; ;; 2 | ; ;; An autohotkey script that provides emacs-like keybinding on Windows 3 | ; ;; 4 | 5 | ; ; The following line is a contribution of NTEmacs wiki http://www49.atwiki.jp/ntemacs/pages/20.html 6 | ; SetKeyDelay 0 7 | 8 | ; ; turns to be 1 when ctrl-x is pressed 9 | ; is_pre_x := 0 10 | ; ; turns to be 1 when ctrl-space is pressed 11 | ; is_pre_spc := 0 12 | 13 | ; ; Applications you want to disable emacs-like keybindings 14 | ; ; (Please comment out applications you don't use) 15 | ; is_target() 16 | ; { 17 | ; IfWinActive,ahk_class ConsoleWindowClass ; Cygwin 18 | ; Return 1 19 | ; IfWinActive,ahk_class MEADOW ; Meadow 20 | ; Return 1 21 | ; IfWinActive,ahk_class cygwin/x X rl-xterm-XTerm-0 22 | ; Return 1 23 | ; IfWinActive,ahk_class MozillaUIWindowClass ; keysnail on Firefox 24 | ; Return 1 25 | ; ; Avoid VMwareUnity with AutoHotkey 26 | ; IfWinActive,ahk_class VMwareUnityHostWndClass 27 | ; Return 1 28 | ; IfWinActive,ahk_class Vim ; GVIM 29 | ; Return 1 30 | ; ; IfWinActive,ahk_class SWT_Window0 ; Eclipse 31 | ; ; Return 1 32 | ; ; IfWinActive,ahk_class Xming X 33 | ; ; Return 1 34 | ; ; IfWinActive,ahk_class SunAwtFrame 35 | ; ; Return 1 36 | ; ; IfWinActive,ahk_class Emacs ; NTEmacs 37 | ; ; Return 1 38 | ; ; IfWinActive,ahk_class XEmacs ; XEmacs on Cygwin 39 | ; ; Return 1 40 | ; Return 0 41 | ; } 42 | 43 | ; delete_char() 44 | ; { 45 | ; Send {Del} 46 | ; global is_pre_spc = 0 47 | ; Return 48 | ; } 49 | ; delete_backward_char() 50 | ; { 51 | ; Send {BS} 52 | ; global is_pre_spc = 0 53 | ; Return 54 | ; } 55 | ; kill_line() 56 | ; { 57 | ; Send {ShiftDown}{END}{SHIFTUP} 58 | ; Sleep 50 ;[ms] this value depends on your environment 59 | ; Send ^x 60 | ; global is_pre_spc = 0 61 | ; Return 62 | ; } 63 | ; open_line() 64 | ; { 65 | ; Send {END}{Enter}{Up} 66 | ; global is_pre_spc = 0 67 | ; Return 68 | ; } 69 | ; quit() 70 | ; { 71 | ; Send {ESC} 72 | ; global is_pre_spc = 0 73 | ; Return 74 | ; } 75 | ; newline() 76 | ; { 77 | ; Send {Enter} 78 | ; global is_pre_spc = 0 79 | ; Return 80 | ; } 81 | ; indent_for_tab_command() 82 | ; { 83 | ; Send {Tab} 84 | ; global is_pre_spc = 0 85 | ; Return 86 | ; } 87 | ; newline_and_indent() 88 | ; { 89 | ; Send {Enter}{Tab} 90 | ; global is_pre_spc = 0 91 | ; Return 92 | ; } 93 | ; isearch_forward() 94 | ; { 95 | ; Send ^f 96 | ; global is_pre_spc = 0 97 | ; Return 98 | ; } 99 | ; isearch_backward() 100 | ; { 101 | ; Send ^f 102 | ; global is_pre_spc = 0 103 | ; Return 104 | ; } 105 | ; kill_region() 106 | ; { 107 | ; Send ^x 108 | ; global is_pre_spc = 0 109 | ; Return 110 | ; } 111 | ; kill_ring_save() 112 | ; { 113 | ; Send ^c 114 | ; global is_pre_spc = 0 115 | ; Return 116 | ; } 117 | ; yank() 118 | ; { 119 | ; Send ^v 120 | ; global is_pre_spc = 0 121 | ; Return 122 | ; } 123 | ; undo() 124 | ; { 125 | ; Send ^z 126 | ; global is_pre_spc = 0 127 | ; Return 128 | ; } 129 | ; find_file() 130 | ; { 131 | ; Send ^o 132 | ; global is_pre_x = 0 133 | ; Return 134 | ; } 135 | ; save_buffer() 136 | ; { 137 | ; Send, ^s 138 | ; global is_pre_x = 0 139 | ; Return 140 | ; } 141 | ; kill_emacs() 142 | ; { 143 | ; Send !{F4} 144 | ; global is_pre_x = 0 145 | ; Return 146 | ; } 147 | 148 | ; move_beginning_of_line() 149 | ; { 150 | ; global 151 | ; if is_pre_spc 152 | ; Send +{HOME} 153 | ; Else 154 | ; Send {HOME} 155 | ; Return 156 | ; } 157 | ; move_end_of_line() 158 | ; { 159 | ; global 160 | ; if is_pre_spc 161 | ; Send +{END} 162 | ; Else 163 | ; Send {END} 164 | ; Return 165 | ; } 166 | ; previous_line() 167 | ; { 168 | ; global 169 | ; if is_pre_spc 170 | ; Send +{Up} 171 | ; Else 172 | ; Send {Up} 173 | ; Return 174 | ; } 175 | ; next_line() 176 | ; { 177 | ; global 178 | ; if is_pre_spc 179 | ; Send +{Down} 180 | ; Else 181 | ; Send {Down} 182 | ; Return 183 | ; } 184 | ; forward_char() 185 | ; { 186 | ; global 187 | ; if is_pre_spc 188 | ; Send +{Right} 189 | ; Else 190 | ; Send {Right} 191 | ; Return 192 | ; } 193 | ; backward_char() 194 | ; { 195 | ; global 196 | ; if is_pre_spc 197 | ; Send +{Left} 198 | ; Else 199 | ; Send {Left} 200 | ; Return 201 | ; } 202 | ; scroll_up() 203 | ; { 204 | ; global 205 | ; if is_pre_spc 206 | ; Send +{PgUp} 207 | ; Else 208 | ; Send {PgUp} 209 | ; Return 210 | ; } 211 | ; scroll_down() 212 | ; { 213 | ; global 214 | ; if is_pre_spc 215 | ; Send +{PgDn} 216 | ; Else 217 | ; Send {PgDn} 218 | ; Return 219 | ; } 220 | 221 | 222 | ; ^x:: 223 | ; If is_target() 224 | ; Send %A_ThisHotkey% 225 | ; Else 226 | ; is_pre_x = 1 227 | ; Return 228 | ; ^f:: 229 | ; If is_target() 230 | ; Send %A_ThisHotkey% 231 | ; Else 232 | ; { 233 | ; If is_pre_x 234 | ; find_file() 235 | ; Else 236 | ; forward_char() 237 | ; } 238 | ; Return 239 | ; ^c:: 240 | ; If is_target() 241 | ; Send %A_ThisHotkey% 242 | ; Else 243 | ; { 244 | ; If is_pre_x 245 | ; kill_emacs() 246 | ; } 247 | ; Return 248 | ; ^d:: 249 | ; If is_target() 250 | ; Send %A_ThisHotkey% 251 | ; Else 252 | ; delete_char() 253 | ; Return 254 | ; ^h:: 255 | ; If is_target() 256 | ; Send %A_ThisHotkey% 257 | ; Else 258 | ; delete_backward_char() 259 | ; Return 260 | ; ^k:: 261 | ; If is_target() 262 | ; Send %A_ThisHotkey% 263 | ; Else 264 | ; kill_line() 265 | ; Return 266 | ; ;; ^o:: 267 | ; ;; If is_target() 268 | ; ;; Send %A_ThisHotkey% 269 | ; ;; Else 270 | ; ;; open_line() 271 | ; ;; Return 272 | ; ^g:: 273 | ; If is_target() 274 | ; Send %A_ThisHotkey% 275 | ; Else 276 | ; quit() 277 | ; Return 278 | ; ;; ^j:: 279 | ; ;; If is_target() 280 | ; ;; Send %A_ThisHotkey% 281 | ; ;; Else 282 | ; ;; newline_and_indent() 283 | ; ;; Return 284 | ; ^m:: 285 | ; If is_target() 286 | ; Send %A_ThisHotkey% 287 | ; Else 288 | ; newline() 289 | ; Return 290 | ; ^i:: 291 | ; If is_target() 292 | ; Send %A_ThisHotkey% 293 | ; Else 294 | ; indent_for_tab_command() 295 | ; Return 296 | ; ^s:: 297 | ; If is_target() 298 | ; Send %A_ThisHotkey% 299 | ; Else 300 | ; { 301 | ; If is_pre_x 302 | ; save_buffer() 303 | ; Else 304 | ; isearch_forward() 305 | ; } 306 | ; Return 307 | ; ^r:: 308 | ; If is_target() 309 | ; Send %A_ThisHotkey% 310 | ; Else 311 | ; isearch_backward() 312 | ; Return 313 | ; ^w:: 314 | ; If is_target() 315 | ; Send %A_ThisHotkey% 316 | ; Else 317 | ; kill_region() 318 | ; Return 319 | ; !w:: 320 | ; If is_target() 321 | ; Send %A_ThisHotkey% 322 | ; Else 323 | ; kill_ring_save() 324 | ; Return 325 | ; ^y:: 326 | ; If is_target() 327 | ; Send %A_ThisHotkey% 328 | ; Else 329 | ; yank() 330 | ; Return 331 | ; ^/:: 332 | ; If is_target() 333 | ; Send %A_ThisHotkey% 334 | ; Else 335 | ; undo() 336 | ; Return 337 | 338 | ; ;$^{Space}:: 339 | ; ;^vk20sc039:: 340 | ; ^vk20:: 341 | ; If is_target() 342 | ; Send {CtrlDown}{Space}{CtrlUp} 343 | ; Else 344 | ; { 345 | ; If is_pre_spc 346 | ; is_pre_spc = 0 347 | ; Else 348 | ; is_pre_spc = 1 349 | ; } 350 | ; Return 351 | ; ^@:: 352 | ; If is_target() 353 | ; Send %A_ThisHotkey% 354 | ; Else 355 | ; { 356 | ; If is_pre_spc 357 | ; is_pre_spc = 0 358 | ; Else 359 | ; is_pre_spc = 1 360 | ; } 361 | ; Return 362 | ; ^a:: 363 | ; If is_target() 364 | ; Send %A_ThisHotkey% 365 | ; Else 366 | ; move_beginning_of_line() 367 | ; Return 368 | ; ^e:: 369 | ; If is_target() 370 | ; Send %A_ThisHotkey% 371 | ; Else 372 | ; move_end_of_line() 373 | ; Return 374 | ; ^p:: 375 | ; If is_target() 376 | ; Send %A_ThisHotkey% 377 | ; Else 378 | ; previous_line() 379 | ; Return 380 | ; ^n:: 381 | ; If is_target() 382 | ; Send %A_ThisHotkey% 383 | ; Else 384 | ; next_line() 385 | ; Return 386 | ; ^b:: 387 | ; If is_target() 388 | ; Send %A_ThisHotkey% 389 | ; Else 390 | ; backward_char() 391 | ; Return 392 | ; ^v:: 393 | ; If is_target() 394 | ; Send %A_ThisHotkey% 395 | ; Else 396 | ; scroll_down() 397 | ; Return 398 | ; !v:: 399 | ; If is_target() 400 | ; Send %A_ThisHotkey% 401 | ; Else 402 | ; scroll_up() 403 | ; Return 404 | -------------------------------------------------------------------------------- /WindowSpy.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; Window Spy for AHKv2 3 | ; 4 | 5 | #NoTrayIcon 6 | #SingleInstance Ignore 7 | SetWorkingDir A_ScriptDir 8 | CoordMode "Pixel", "Screen" 9 | 10 | Global oGui 11 | 12 | WinSpyGui() 13 | 14 | WinSpyGui() { 15 | Global oGui 16 | 17 | oGui := Gui("AlwaysOnTop Resize MinSize +DPIScale","Window Spy for AHKv2") 18 | oGui.OnEvent("Close",WinSpyClose) 19 | oGui.OnEvent("Size",WinSpySize) 20 | 21 | oGui.Add("Text",,"Window Title, Class and Process:") 22 | oGui.Add("Checkbox","yp xp+200 w120 Right vCtrl_FollowMouse","Follow Mouse").Value := 1 23 | oGui.Add("Edit","xm w320 r5 ReadOnly -Wrap vCtrl_Title") 24 | oGui.Add("Text",,"Mouse Position") 25 | oGui.Add("Edit","w320 r4 ReadOnly vCtrl_MousePos") 26 | oGui.Add("Text","w320 vCtrl_CtrlLabel",(txtFocusCtrl := "Focused Control") ":") 27 | oGui.Add("Edit","w320 r4 ReadOnly vCtrl_Ctrl") 28 | oGui.Add("Text",,"Active Window Postition:") 29 | oGui.Add("Edit","w320 r2 ReadOnly vCtrl_Pos") 30 | oGui.Add("Text",,"Status Bar Text:") 31 | oGui.Add("Edit","w320 r2 ReadOnly vCtrl_SBText") 32 | oGui.Add("Checkbox","vCtrl_IsSlow","Slow TitleMatchMode") 33 | oGui.Add("Text",,"Visible Text:") 34 | oGui.Add("Edit","w320 r2 ReadOnly vCtrl_VisText") 35 | oGui.Add("Text",,"All Text:") 36 | oGui.Add("Edit","w320 r2 ReadOnly vCtrl_AllText") 37 | oGui.Add("Text","w320 r1 vCtrl_Freeze",(txtNotFrozen := "(Hold Ctrl or Shift to suspend updates)")) 38 | 39 | oGui.Show("NoActivate") 40 | WinGetClientPos(&x_temp, &y_temp2,,,"ahk_id " oGui.hwnd) ; GetClientSize(hGui, &x_temp, &y_temp2) 41 | 42 | ; oGui.horzMargin := x_temp*96//A_ScreenDPI - 320 ; now using oGui.MarginX 43 | 44 | oGui.txtNotFrozen := txtNotFrozen ; create properties for futur use 45 | oGui.txtFrozen := "(Updates suspended)" 46 | oGui.txtMouseCtrl := "Control Under Mouse Position" 47 | oGui.txtFocusCtrl := txtFocusCtrl 48 | 49 | SetTimer Update, 250 50 | } 51 | 52 | WinSpySize(GuiObj, MinMax, Width, Height) { 53 | Global oGui 54 | 55 | If !oGui.HasProp("txtNotFrozen") ; WinSpyGui() not done yet, return until it is 56 | return 57 | 58 | SetTimer Update, (MinMax=0)?250:0 ; suspend updates on minimize 59 | 60 | ctrlW := Width - (oGui.MarginX * 2) ; ctrlW := Width - horzMargin 61 | list := "Title,MousePos,Ctrl,Pos,SBText,VisText,AllText,Freeze" 62 | Loop Parse list, "," 63 | oGui["Ctrl_" A_LoopField].Move(,,ctrlW) 64 | } 65 | 66 | WinSpyClose(GuiObj) { 67 | ExitApp 68 | } 69 | 70 | Update() { ; timer, no params 71 | Try TryUpdate() ; Try 72 | } 73 | 74 | TryUpdate() { 75 | Global oGui 76 | 77 | If !oGui.HasProp("txtNotFrozen") ; WinSpyGui() not done yet, return until it is 78 | return 79 | 80 | Ctrl_FollowMouse := oGui["Ctrl_FollowMouse"].Value 81 | CoordMode "Mouse", "Screen" 82 | MouseGetPos &msX, &msY, &msWin, &msCtrl, 2 ; get ClassNN and hWindow 83 | actWin := WinExist("A") 84 | 85 | if (Ctrl_FollowMouse) { 86 | curWin := msWin, curCtrl := msCtrl 87 | WinExist("ahk_id " curWin) ; updating LastWindowFound? 88 | } else { 89 | curWin := actWin 90 | curCtrl := ControlGetFocus() ; get focused control hwnd from active win 91 | } 92 | curCtrlClassNN := "" 93 | Try curCtrlClassNN := ControlGetClassNN(curCtrl) 94 | 95 | t1 := WinGetTitle(), t2 := WinGetClass() 96 | if (curWin = oGui.hwnd || t2 = "MultitaskingViewFrame") { ; Our Gui || Alt-tab 97 | UpdateText("Ctrl_Freeze", oGui.txtFrozen) 98 | return 99 | } 100 | 101 | UpdateText("Ctrl_Freeze", oGui.txtNotFrozen) 102 | t3 := WinGetProcessName(), t4 := WinGetPID() 103 | 104 | UpdateText("Ctrl_Title", t1 "`nahk_class " t2 "`nahk_exe " t3 "`nahk_pid " t4 "`nahk_id " curWin) 105 | CoordMode "Mouse", "Window" 106 | MouseGetPos &mrX, &mrY 107 | CoordMode "Mouse", "Client" 108 | MouseGetPos &mcX, &mcY 109 | mClr := PixelGetColor(msX,msY,"RGB") 110 | mClr := SubStr(mClr, 3) 111 | 112 | UpdateText("Ctrl_MousePos", "Screen:`t" msX ", " msY " (less often used)`n" 113 | . "Window:`t" mrX ", " mrY " (default)`nClient:`t" mcX ", " mcY " (recommended)`n" 114 | . "Color:`t" mClr " (Red=" SubStr(mClr, 1, 2) " Green=" SubStr(mClr, 3, 2) " Blue=" SubStr(mClr, 5) ")") 115 | 116 | UpdateText("Ctrl_CtrlLabel", (Ctrl_FollowMouse ? oGui.txtMouseCtrl : oGui.txtFocusCtrl) ":") 117 | 118 | if (curCtrl) { 119 | ctrlTxt := ControlGetText(curCtrl) 120 | cText := "ClassNN:`t" curCtrlClassNN "`nText:`t" textMangle(ctrlTxt) 121 | ControlGetPos &cX, &cY, &cW, &cH, curCtrl 122 | cText .= "`n`tx: " cX "`ty: " cY "`tw: " cW "`th: " cH 123 | WinGetClientPos(&cX,&cY,,,curCtrl) ; WinToClient(curCtrl, &cX, &cY) 124 | GetClientSize(curCtrl, &cW, &cH) 125 | cText .= "`nClient:`tx: " cX "`ty: " cY "`tw: " cW "`th: " cH 126 | } else 127 | cText := "" 128 | 129 | UpdateText("Ctrl_Ctrl", cText) 130 | wX := "", wY := "", wW := "", wH := "" 131 | WinGetPos &wX, &wY, &wW, &wH, "ahk_id " curWin 132 | WinGetClientPos(&wcX,&wcY,&wcW, &wcH,"ahk_id " curWin) ; GetClientSize(curWin, &wcW, &wcH) 133 | 134 | UpdateText("Ctrl_Pos", "`tx: " wX "`ty: " wY "`tw: " wW "`th: " wH "`n" 135 | . "Client:`tx: " wcX "`ty: " wcY "`tw: " wcW "`th: " wcH) 136 | sbTxt := "" 137 | 138 | Loop { 139 | ovi := "" 140 | Try ovi := StatusBarGetText(A_Index) 141 | if (ovi = "") 142 | break 143 | sbTxt .= "(" A_Index "):`t" textMangle(ovi) "`n" 144 | } 145 | 146 | sbTxt := SubStr(sbTxt,1,-1) ; StringTrimRight, sbTxt, sbTxt, 1 147 | UpdateText("Ctrl_SBText", sbTxt) 148 | bSlow := oGui["Ctrl_IsSlow"].Value ; GuiControlGet, bSlow,, Ctrl_IsSlow 149 | 150 | if (bSlow) { 151 | DetectHiddenText False 152 | ovVisText := WinGetText() ; WinGetText, ovVisText 153 | DetectHiddenText True 154 | ovAllText := WinGetText() ; WinGetText, ovAllText 155 | } else { 156 | ovVisText := WinGetTextFast(false) 157 | ovAllText := WinGetTextFast(true) 158 | } 159 | 160 | UpdateText("Ctrl_VisText", ovVisText) 161 | UpdateText("Ctrl_AllText", ovAllText) 162 | } 163 | 164 | ; =========================================================================================== 165 | ; WinGetText ALWAYS uses the "slow" mode - TitleMatchMode only affects 166 | ; WinText/ExcludeText parameters. In "fast" mode, GetWindowText() is used 167 | ; to retrieve the text of each control. 168 | ; =========================================================================================== 169 | WinGetTextFast(detect_hidden) { 170 | controls := WinGetControlsHwnd() 171 | 172 | static WINDOW_TEXT_SIZE := 32767 ; Defined in AutoHotkey source. 173 | 174 | buf := Buffer(WINDOW_TEXT_SIZE * 2,0) 175 | 176 | text := "" 177 | 178 | Loop controls.Length { 179 | hCtl := controls[A_Index] 180 | if !detect_hidden && !DllCall("IsWindowVisible", "ptr", hCtl) 181 | continue 182 | if !DllCall("GetWindowText", "ptr", hCtl, "Ptr", buf.ptr, "int", WINDOW_TEXT_SIZE) 183 | continue 184 | 185 | text .= StrGet(buf) "`r`n" ; text .= buf "`r`n" 186 | } 187 | return text 188 | } 189 | 190 | ; =========================================================================================== 191 | ; Unlike using a pure GuiControl, this function causes the text of the 192 | ; controls to be updated only when the text has changed, preventing periodic 193 | ; flickering (especially on older systems). 194 | ; =========================================================================================== 195 | UpdateText(vCtl, NewText) { 196 | Global oGui 197 | static OldText := {} 198 | ctl := oGui[vCtl], hCtl := Integer(ctl.hwnd) 199 | 200 | if (!oldText.HasProp(hCtl) Or OldText.%hCtl% != NewText) { 201 | ctl.Value := NewText 202 | OldText.%hCtl% := NewText 203 | } 204 | } 205 | 206 | GetClientSize(hWnd, &w, &h) { 207 | rect := Buffer(16,0) ; VarSetCapacity(rect, 16) 208 | 209 | DllCall("GetClientRect", "ptr", hWnd, "ptr", rect.ptr) 210 | w := NumGet(rect, 8, "int"), h := NumGet(rect, 12, "int") 211 | } 212 | 213 | WinToClient(hWnd, &x, &y) { 214 | WinGetPos &wX, &wY,,, "ahk_id " hWnd 215 | If (wX != "" And wY != "") { 216 | x += wX, y += wY 217 | pt := Buffer(8,0) ; VarSetCapacity(pt, 8) 218 | 219 | NumPut "Int", x, "Int", y, pt ; NumPut(y, NumPut(x, pt, "int"), "int") 220 | 221 | if !DllCall("ScreenToClient", "ptr", hWnd, "ptr", pt.ptr) 222 | return false 223 | x := NumGet(pt, 0, "int"), y := NumGet(pt, 4, "int") 224 | return true 225 | } Else 226 | return false 227 | } 228 | 229 | textMangle(x) { 230 | elli := false 231 | if (pos := InStr(x, "`n")) 232 | x := SubStr(x, 1, pos-1), elli := true 233 | else if (StrLen(x) > 40) 234 | x := SubStr(x,1,40), elli := true 235 | if elli 236 | x .= " (...)" 237 | return x 238 | } 239 | 240 | suspend_timer() { 241 | Global oGui 242 | SetTimer Update, 0 243 | UpdateText("Ctrl_Freeze", oGui.txtFrozen) 244 | } 245 | 246 | ~*Shift:: 247 | ~*Ctrl::suspend_timer() 248 | 249 | ~*Ctrl up:: 250 | ~*Shift up::SetTimer Update, 250 251 | -------------------------------------------------------------------------------- /Mouse.ahk: -------------------------------------------------------------------------------- 1 | 2 | ; AltSnap 是 Altdrag 软件的替代,后者不更新了。 3 | ; AltSnap 提供 move、resize、lower (title 标题栏 roll、unroll 卷起和展开,只剩下一个标题栏) 4 | 5 | 6 | 7 | 8 | 9 | ; ( 10 | ; ~ 1 2 3 左/中/右键 4 5 跳转 alt→ alt← 11 | ; q 左键 W 智能浏览 E 删除 R 回车 T 12 | ; a← s↓ D→ f F 切换任务 g 13 | ; z 最小化 X 关闭 c v 粘贴 B 移动窗口 14 | ; Tab +s 标签页 F1 2 3 4 5 6 7 15 | 16 | ; u o 屏幕左右边. ijkl 复现 mousemode. 17 | ; } 18 | 19 | ; $sc029::send("{sc029}") ;` 20 | sc029:: 21 | { 22 | Send("{AppsKey}") 23 | ; Send("{sc029 Up}") 24 | } 25 | ^sc029::Send("^{sc029}") 26 | 27 | 28 | $+`::Clip("~") 29 | esc & sc029::Send("{``}") 30 | 31 | 32 | 33 | sc029 & F1::search_with_edge(1) 34 | sc029 & F2::thesis_remove_enter_saladict() 35 | sc029 & F3::voice_text_to_speach("en") 36 | sc029 & F4::voice_text_to_speach("cn") 37 | 38 | ; sc029 & F3:: 39 | ; sc029 & f::AltTab 40 | 41 | sc029 & z::Send("#{d}") 42 | sc029 & x:: 43 | { 44 | repeatTime:= updateSharedRepeat(" 显示桌面,最小化,最大化,‘恢复大小’, 关闭") 45 | switch repeatTime 46 | { 47 | 48 | ; if ( WinActive("ahk_exe msedge.exe")) 49 | ; Send("^{w}") 50 | ; else{ 51 | ; WinClose("A") 52 | ; } 53 | case 0: Send("#{d}") 54 | case 1: WinMinimize("A") 55 | case 2: WinMaximize("A") 56 | case 3: WinRestore("A") 57 | case 4: WinClose("A") 58 | 59 | } 60 | return 61 | } 62 | 63 | 64 | 65 | 66 | 67 | 68 | sc029 & c::Send("^{c}") 69 | sc029 & V::Send("^{v}") 70 | 71 | sc029 & F5::maximizeORrestore() 72 | 73 | 74 | F3 & n::Run("onenote:https://d.docs.live.net/ff64712bc759b896/文档/雨爽/快速笔记.one#ToDo_FrontPage§ion-id={061EB8EC-DE60-4864-B92C-7BC1380657DF}&page-id={C2166799-8231-A942-9101-C8A5CDBE9172}&end") 75 | F3 & m::Run("onenote:https://d.docs.live.net/ff64712bc759b896/文档/雨爽/快速笔记.one#Marathon§ion-id={061EB8EC-DE60-4864-B92C-7BC1380657DF}&page-id={6833971E-4DFA-4DA8-8D42-DD9A7C0F47CC}&end") 76 | 77 | 78 | 79 | 80 | 81 | 82 | sc029 & LShift:: ; 带 shift 的点击 83 | { 84 | Send("{LShift Down}{LButton}") 85 | ; KeyWait("sc029") 86 | ; Send("{LShift Up}") 87 | SetTimer () => Send("{LShift Up}"), -750 88 | } 89 | ; 一松开就取消了 powertoys 的功能, 不能用原来的 Lshift ,。 微软官方的功能检查优先级比 AHK高,不会先通知脚本 shift 放开了,而是先通知 Powertoys "Shift放开”。 90 | sc029 & Lalt::AltTab 91 | 92 | ; sc029 & LWin::Send("#^{Right}") ;虚拟桌面 93 | ; sc029 & LCtrl::Send("#^{Left}") 94 | sc029 & LWin::VirgoRight() 95 | sc029 & LCtrl::VirgoLeft() 96 | #F1::Send("#^{Left}") 97 | #F2::Send("#^{Right}") 98 | 99 | ; SC15C & F1::Send("#^{Left}") RWin 没有用,并且家里的键盘根本没有这个按键,放弃。 100 | ; SC15C & F2::Send("#^{Right}") 101 | 102 | Esc & F1:: 103 | sc029 & 1:: 104 | { 105 | global M_altered_wait_click 106 | M_altered_wait_click := 1 107 | ToolTip() 108 | Click("Down") ; hold down 鼠标左键 109 | ErrorLevel := !KeyWait("1") 110 | ErrorLevel := !KeyWait("F1") 111 | Click("Up") 112 | Return 113 | } 114 | 115 | 116 | 117 | sc029 & 2:: 118 | { 119 | Click("Middle Down") 120 | ErrorLevel := !KeyWait(2) 121 | Click("Middle Up") 122 | Return 123 | } 124 | 125 | Esc & F3:: 126 | sc029 & 3::Click("Right") 127 | 128 | sc029 & 4::Send("!{left}") 129 | sc029 & 5::Send("!{Right}") 130 | 131 | Esc & F2:: 132 | sc029 & e::smart_wheelUpDown() 133 | smart_wheelUpDown() 134 | { 135 | global XwhereMwas 136 | global YwhereMwas 137 | 138 | Title := WinGetProcessName("A") 139 | ; WinGetPos(&X, &Y, &W, &H, "A") 140 | ToolTip(return_last_combined_key() ) 141 | 142 | start_height := YwhereMwas 143 | while( key(return_last_combined_key()) ){ 144 | 145 | MouseGetPos(&xpos, &ypos) 146 | d := ypos - start_height 147 | 148 | 149 | if( d < -10) 150 | Send("{WheelUp}") 151 | else if( d > 10) 152 | Send("{WheelDown}") 153 | 154 | Sleep( 150 ) 155 | } 156 | } 157 | 158 | sc029 & -::Send("{WheelLeft}") 159 | sc029 & =::Send("{WheelRight}") 160 | sc029 & Q:: 161 | sc029 & a:: 162 | ;-------------------------------------------------------------------- 163 | sc029 & Backspace:: 164 | sc029 & Tab::change_to_chn_and_retype() 165 | sc029 & enter:: ; tilde 166 | sc029 & CapsLock:: ; tilde 167 | sc029 & space::change_to_en_and_put_stringSpace() 168 | ;-------------------------------------------------------------------- 169 | 170 | 171 | sc029 & R::Send("{enter}") 172 | 173 | 174 | 175 | sc029 & W::Send("{WheelUp}") 176 | sc029 & s::Send("{wheeldown}") 177 | 178 | sc029 & t::Send("{Sleep 1000}{t}") 179 | ; sc029 & M::enter_mouse_mode() 180 | sc029 & 8::MouseMove(500, 1000) 181 | sc029 & 7::MouseMove(-700, 1100) 182 | sc029 & i::function_my_mouse_momentum(0,-1) ;↑ y<0 ← x<0 ↓ y>0 → x>0 183 | sc029 & k::function_my_mouse_momentum(0,1) ;↑ y<0 ← x<0 ↓ y>0 → x>0 184 | sc029 & J::function_my_mouse_momentum(-1,0) ;↑ y<0 ← x<0 ↓ y>0 → x>0 185 | sc029 & L::function_my_mouse_momentum(1,0) ;↑ y<0 ← x<0 ↓ y>0 → x>0 186 | 187 | 188 | sc029 & WheelUp:: 189 | { 190 | WinGetPos(&X, &Y, &W, &H, "A") 191 | repeatTime:= updateSharedRepeat(,3) 192 | switch repeatTime 193 | { 194 | case 0: MouseMove( x+2 , y+2 ) ; 软件左上角的 toolbar位置、屏幕左上角的位置,副屏幕位置。 195 | case 1: MouseMove( 561,26 ) 196 | case 2: MouseMove( -648,696 ) 197 | repeatTime:=0 198 | } 199 | return 200 | } 201 | 202 | 203 | sc029 & WheelDown:: 204 | { 205 | WinGetPos(&X, &Y, &W, &H, "A") 206 | repeatTime:= updateSharedRepeat( ,2) 207 | switch repeatTime 208 | { 209 | case 0: MouseMove( x+w-10 , y+195) ; 滚动条位置 210 | case 1: MouseMove( x+w-5 , y+h-5 ) ;右下角位置 211 | case 2: MouseMove( -726, 1150 ) 212 | repeatTime:=-1 213 | } 214 | return 215 | } 216 | 217 | 218 | sc029 & P:: 219 | { 220 | ihOutputVar := InputHook("L3 T1.5 M"), ihOutputVar.Start(), ihOutputVar.Wait(), OutputVar := ihOutputVar.Input 221 | switch OutputVar 222 | { 223 | ; 这里不区分大小写。 224 | case "R": switch_to_a_program( ["MuPDF","adobe Acrobat DC","pdf","WPF Office"] ) 225 | case "st": switch_to_a_program( ["Sticky", "便笺"]) 226 | case "we": switch_to_a_program( ["微信", "Teams","Zoom", "wechat"]) 227 | case "x": switch_to_a_program( ["微信", "Teams","Zoom", "wechat"]) 228 | case "t": switch_to_a_program( ["Command Prompt", "PowerShell","Bash", "Terminal","Terminus","prompt"]) ; win + t/ win + shift + t 有的人可能觉得这个按键挺有用的。 但我用 win + 滚轮 实现了更方便的,就占用了。 terminus 程序名字比较特殊,他可以启动 cmd powershell WSL,名字会变。 229 | case "c": switch_to_a_program( ["Visual Studio Code", "Visual Studio","PyCharm", "Arduino"]) ;IDEs 230 | case "i": switch_to_a_program( ["Visual Studio Code"]) ;IDEs 231 | case "ppt": switch_to_a_program( ["PowerPoint"]) 232 | case "wor": switch_to_a_program( ["Word","Excel", "OnlyOffice","Libreoffice"]) 233 | case "e": switch_to_a_program( ["Edge"],True ) 234 | case "O": switch_to_a_program( ["OneNote"],True ) ; 一句话打开 Onenote 。 后面这是一键创建新笔记:Run, onenote-cmd://quicknote?onOpen=typing 。但是没有别的指令,就非常难受。 235 | case "Ob": switch_to_a_program( ["Obsidian"], True ) 236 | case "One": switch_to_a_program( ["OneCommander"],True ) ; 不能使用文件浏览器,他们没有固定的名字,wintitle 是文件的名字,找不到程序. switch_to_a_program( ["Explorer.EXE", "OneCommander.exe"] , True ) ;程序自带快捷键 237 | 238 | 239 | } 240 | 241 | return 242 | } 243 | 244 | 245 | enter_mouse_mode() 246 | { 247 | BlockInput("On") 248 | global flag_controlling_mouse 249 | global speed 250 | flag_controlling_mouse:=1 251 | base_speed := "12" 252 | base_sleep_time:=60 253 | speed:=base_speed 254 | ;Keywait, Esc ;?? 255 | ToolTip(" 鼠标模式 需要运行在管理员模式下 need run `n “过一段时间重置速度”, 按 ijkl 移动鼠标↑←↓→,会越来越慢(越来越精细),不操作才能加速。`n 也可以用 ~1234 来调整速度…… 其他快捷键: `t`n 单击:: u/f `t 双击 y/g `t 右键 p/r `t 鼠标中键 h/d `t鼠标滚轮 w↑/s↓ `n " ) 256 | 257 | mouse_Start_time := A_TickCount 258 | 259 | while(true) 260 | { 261 | if (key("Esc")) ; key 函数是 getkeystate 的缩写。如果按键不按下,返回值是 0. if else 结构 那么按下才进入,相当于一个反逻辑。 262 | break 263 | ;如果长时间不动就重置速度 264 | 265 | if( A_TimeIdlePhysical > 550 or (A_TickCount - mouse_Start_time > 1500)) 266 | { 267 | mouse_Start_time := A_TickCount 268 | ToolTip("长时间不动 speed reseted 速度重置了 tilde = " tilde " `n " A_TickCount) 269 | speed:=base_speed 270 | } 271 | 272 | tilde:=key("Sc029") 273 | tab:=key("Tab") 274 | Win:=key("Win") 275 | dash:=key("-") 276 | plus:=key("=") 277 | q:=key("q") 278 | w:=key("w") 279 | e:=key("e") 280 | r:=key("r") 281 | t:=key("t") 282 | y:=key("y") 283 | u:=key("u") 284 | i:=key("i") 285 | o:=key("o") 286 | p:=key("p") 287 | a:=key("a") 288 | s:=key("s") 289 | d:=key("d") 290 | f:=key("f") 291 | g:=key("g") 292 | h:=key("h") 293 | j:=key("j") 294 | k:=key("k") 295 | l:=key("l") 296 | z:=key("z") 297 | x:=key("x") 298 | c:=key("c") 299 | v:=key("v") 300 | b:=key("b") 301 | n:=key("n") 302 | m:=key("m") 303 | ; 基本按键缩写还是能更快的。 304 | 305 | speed:= base_speed*( 1+ key("Sc029")*(-0.8) + key("1")*(-0.5) + key("Space") + key("2")*(0.5) + key("3")*(0.9) + key("4") *(1.1) ) 306 | 307 | ; ↑ y<0 ← x<0 ↓ y>0 → x>0 308 | x:=0 309 | y:=0 310 | if( i ) 311 | y:=-1 312 | if( j ) 313 | x := "-1" 314 | if( k ) 315 | y:=1 316 | if( l ) 317 | x:=1 318 | if( i or j or k or l) 319 | { 320 | 321 | TimeLength := A_TickCount - mouse_Start_time 322 | speed:=Max(speed*Exp((TimeLength/400)*Ln(0.95)),1) 323 | ToolTip(speed) 324 | MouseMove(x*speed, y*speed, 100, "R") ; 100 仅仅是一个默认参数、 R 代表相对移动 325 | } 326 | ; else 327 | ; { 328 | ; } 329 | 330 | 331 | if(u or f) 332 | SendInput("{Click}") ;Click, 1 333 | if(y or g) 334 | SendInput("{click 2}") 335 | if(p or r) 336 | SendInput("{Click Right}") 337 | if(h or d) 338 | SendInput("{Click Middle}") 339 | if( w) 340 | SendInput("{Click WheelUp}") 341 | if( s ) 342 | SendInput("{Click WheelDown}") 343 | if(key("F4")) 344 | Send("^w") 345 | if(Tab) 346 | Send("!{Esc}") 347 | if(q) 348 | Send("!+{Esc}") 349 | if(t) 350 | Send("^{t}") 351 | if(Win) 352 | Send("{Win}") 353 | ; 放大缩小 -= + 354 | if(dash) 355 | Send("^{WheelDown}") 356 | if(plus) 357 | Send("^{WheelUp}") 358 | if( key("Enter") ) 359 | Send("{Enter}") 360 | ; if( A_IdleTimePhysical < 200 ) ; 如果有任意键背按下,就是活跃的 361 | ; sleep_time:=base_sleep_time*10 362 | if( h or n or dash or plus) 363 | sleep_time:=base_sleep_time*3 ; 翻页键需要更多反应时间。 364 | 365 | Sleep(sleep_time) 366 | } 367 | BlockInput("Off") 368 | ToolTip() 369 | } 370 | 371 | 372 | #HotIf useEnterAsSpace == 1 373 | $space:: 374 | { 375 | Send("{Enter}{Space}") 376 | } 377 | 378 | #HotIf 379 | 380 | 381 | #HotIf M_altered_wait_click == 1 382 | 383 | $1:: 384 | { 385 | Click("Down") 386 | ErrorLevel := !KeyWait( Trim(A_ThisHotkey,"$")) ; hold down 387 | Click("Up") 388 | } 389 | $2:: 390 | { 391 | if (A_PriorHotkey == A_ThisHotkey and A_TimeSincePriorHotkey < 400) 392 | { 393 | smart_wheelUpDown() 394 | return 395 | } 396 | 397 | Click("Down Middle") 398 | ErrorLevel := !KeyWait( Trim(A_ThisHotkey,"$")) ; hold down 399 | Click("Up Middle") 400 | } 401 | $3:: 402 | { 403 | Click("Down Right") 404 | ErrorLevel := !KeyWait( Trim(A_ThisHotkey,"$")) ; hold down 405 | Click("Up Right") 406 | } 407 | 4::smart_wheelUpDown() 408 | 409 | ; $space:: 410 | ; { 411 | ; Send("{Delete}") 412 | ; clear_mouse_flag_altered() 413 | 414 | ; ; global threshold_idle 415 | ; ; ; ToolTip( A_TimeIdleKeyboard "> " threshold_idle) ; 416 | ; ; if( flag_idle_space == 1){ 417 | ; ; cn() 418 | ; ; Send("{BackSpace}") 419 | ; ; } 420 | ; } 421 | 422 | 423 | ; d::Send("^{" ThisHotkey "}") 424 | 425 | ; mouse speed 426 | 427 | 428 | ; Up::function_my_mouse_momentum(0,-1) ;↑ y<0 ← x<0 ↓ y>0 → x>0 429 | ; Down::function_my_mouse_momentum(0,1) ;↑ y<0 ← x<0 ↓ y>0 → x>0 430 | ; Left::function_my_mouse_momentum(-1,0) ;↑ y<0 ← x<0 ↓ y>0 → x>0 431 | ; Right::function_my_mouse_momentum(1,0) ;↑ y<0 ← x<0 ↓ y>0 → x>0 432 | 433 | ; 应该不包括 ijkl,因为只映射 number 和 Fn , 还可以打字,没有干扰。 434 | isDirections(key){ 435 | switch key 436 | { 437 | case "Up": return 1 438 | case "Down": return 2 439 | case "Left": return 3 440 | case "Right": return 4 441 | ; case "i": return 1 442 | ; case "j": return 2 443 | ; case "k": return 3 444 | ; case "w": return 4 445 | default: return 0 446 | } 447 | } 448 | 449 | add_vector_directional(&x,&y,arrow){ 450 | switch arrow 451 | { 452 | case 1: y := -1 453 | case 2: y := 1 454 | case 3: x := -1 455 | case 4: x := 1 456 | } 457 | } 458 | 459 | global reset_not_using_K2Ms := 1 460 | global LastX := 0 461 | global LastY := 0 462 | global flag_is_old_key := 0 463 | 464 | ; mouse speed 不好设置,目前只能大范围跳跃。 465 | ; 这个函数多次进入是会“暂停”的,应该用全局变量保存。 466 | ; prior 记录根本不准, →↑ 会变成 ↑,必须每次都重新扫描 467 | function_my_mouse_momentum(x,y, keys:="IJKL" ){ 468 | global speed 469 | global Ts 470 | global LastX 471 | global LastY 472 | global reset_not_using_K2Ms 473 | base_speed := 100 474 | base_sleep_time := 60 475 | low_speed_limit := 1 476 | slow_down_rate := 1600 ; 数字越大衰减越慢。400 合适。 477 | speed := base_speed 478 | 479 | if( keys == "Arrows") 480 | veg := ["Up", "Down", "Left", "Right"] 481 | else if( keys == "IJKL") 482 | veg := ["I", "K", "J", "L"] 483 | if( reset_not_using_K2Ms == 1 ) 484 | { 485 | Ts := A_TickCount 486 | ; ToolTip("长 speed reseted `n " A_TickCount) 487 | speed:=base_speed 488 | } 489 | 490 | 491 | flag := 1 492 | while( flag ){ 493 | TrueKey := SubStr(A_ThisHotkey, -1) 494 | ThisKey := GetKeyState( TrueKey,'p') 495 | count := 0 496 | x :=0 497 | y := 0 498 | Loop veg.Length 499 | { 500 | if(GetKeyState( veg[A_Index],'p')) 501 | { 502 | add_vector_directional(&x,&y,A_Index) 503 | flag := 1 504 | count += 1 505 | } 506 | } 507 | if( count == 0) 508 | { 509 | flag := 0 510 | } 511 | reset_not_using_K2Ms := 0 512 | TimeLength := A_TickCount - Ts + 1 513 | k := Exp(-(TimeLength/ slow_down_rate)) * 00.94 514 | speed := Max( speed * k, low_speed_limit) 515 | ; ToolTip( speed "`t" count "`n" GetKeyState( TrueKey,'p') "`n" TrueKey "`n latter_key`n" ,0,0 ) 516 | MouseMove(x*speed, y*speed, 100, "R") 517 | 518 | 519 | Sleep( 15) ;加入循环自己判定,而不是按照 Auto repeat 判断时间间隔。 520 | } 521 | SetTimer () => ToolTip("R",100,100), -50 ;`这样的计时器是新建的,不会刷新。只有新建一个真的函数才会共享一个变量。 function_flag_mouse 522 | ; SetTimer () => ToolTip("speed reseted"), -50 ;`这样的计时器是新建的,不会刷新。只有新建一个真的函数才会共享一个变量。 function_flag_mouse 523 | SetTimer(function_flag_mouse, - 150 ) 524 | SetTimer () => ToolTip(), -1050 525 | 526 | 527 | } 528 | 529 | function_flag_mouse(){ 530 | global reset_not_using_K2Ms := 1 531 | } 532 | 533 | 534 | 535 | ; 9::Send("{WheelDown}") 2 已经实现了。 536 | ; 0::Send("{WheelUp}") 537 | 538 | ; Fn 按键不能立即触发,已经组成修饰键了,必须松开才触发。 539 | ; F1::search_with_edge(1) 540 | ; F2::thesis_remove_enter_saladict() 541 | ; F3::voice_text_to_speach("en") 542 | ; F4::voice_text_to_speach("cn") 543 | 544 | ; F5::Send("^{a}") 545 | ; F6::Send("^{x}") 546 | ; F7::Send("^{c}") 547 | ; F8::Send("^{v}") 548 | 549 | ; ------------- 打断思路 弃用--------------- 550 | ; f:: 551 | ; { 552 | ; en() 553 | ; clear_mouse_flag_altered() 554 | ; ; Send("{bs}") ~f:: 会在错误的时间发送! 555 | ; ToolTip(A_PriorHotkey " " ) 556 | ; ; if( !IsAlpha(A_PriorHotkey)) ;` 没有按键记录器,不能用 proir -hot- key 557 | ; ; { 558 | ; ; 559 | ; ; } 560 | ; } 561 | ; J:: 562 | ; { 563 | ; cn() 564 | ; clear_mouse_flag_altered() 565 | 566 | ; } 567 | ; ------------- 打断思路 弃用--------------- rr111 568 | 569 | ~q:: 570 | ~w:: 571 | ~e:: 572 | ~r:: 573 | ~t:: 574 | ~y:: 575 | ~u:: 576 | ~i:: 577 | ~o:: 578 | ~p:: 579 | ~a:: 580 | ~s:: 581 | 582 | ~f:: 583 | ~g:: 584 | ~h:: 585 | ~j:: 586 | ~k:: 587 | ~l:: 588 | ~b:: 589 | ~n:: 590 | ~m:: 591 | { 592 | clear_mouse_flag_altered() 593 | } 594 | #HotIf 595 | 596 | 597 | global USED_for_math := 0 598 | #HotIf USED_for_math == 1 599 | F9::Send("{Raw}+") 600 | F10::Send("{Raw}−") ;- −en dash - −em dash − 601 | F11::Send("{Raw}ᐧ") 602 | F12::Send("{Raw}⁄") 603 | 604 | #HotIf 605 | -------------------------------------------------------------------------------- /Modifiers.ahk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | XButton1::Send("{XButton1}") ; the "back" on the mouse. 5 | XButton1 & Tab:: 6 | End & PgUp:: 7 | { 8 | ; AltTabMenu() 9 | Send("!{Esc}") ; 这会卡在两个程序之间,挺好的。 而 !+Tab 会一直倒腾。 10 | ; Sleep(100) 11 | SHOW_Shake() 12 | } 13 | 14 | XButton1 & CapsLock:: 15 | End & home:: 16 | { 17 | ; ShiftAltTab 18 | Send("!+{Esc}") 19 | SHOW_Shake() 20 | } 21 | End & delete::WinRotate("left") 22 | End & PgDn::WinRotate("right") 23 | 24 | 25 | End & Tab:: Send("#{Tab}") 26 | XButton1 & p:: 27 | End & Space::Send("{Media_Play_Pause}") 28 | 29 | 30 | ; End::Send("{End}") 31 | End:: 32 | { 33 | CoordMode("ToolTip", "Screen") 34 | stringToolT := " 35 | ( 36 | win + number 指定数字切换。 37 | + wasd = ↑←↓→ 窗口管理 38 | T 沙拉查词 V wechat !+{w} 39 | x 关闭 & Space/delete::{Media_Play_Pause} 40 | & Tab::#{Tab}") & PgUp\PgDn::!+{Esc} 41 | )" 42 | 43 | if(A_ScreenHeight == 1920) ;横屏 的时候是 1080*1920 44 | { 45 | ToolTip(stringToolT,98,1862,1) 46 | ToolTip("1 2 3 4 5 6 7 8 9 0",108,1832,2) 47 | } 48 | else if( A_ScreenWidth == 1920) 49 | ToolTip(stringToolT,98,1008,1) 50 | ToolTip("1 2 3 4 5 6 7 8 9 0",108,1008,2) 51 | } 52 | End Up:: 53 | { 54 | Send("{End}") 55 | ToolTip 56 | ToolTip(,,,2) 57 | ToolTip(,,,3) 58 | } 59 | ~End & <::Send("!+{Esc}") ; 这两个竟然不生效,但是确实改变了这个按键的触发时间,所以需要保留。 60 | ~End & >::Send("!{Esc}") 61 | 62 | 63 | End & s::Send("#{Down}") 64 | End & a::Send("#{Left}") 65 | End & w::Send("#{Up}") 66 | End & d::Send("#{Right}") 67 | 68 | XButton1 & s::Send("#{Down}") 69 | XButton1 & a::Send("#{Left}") 70 | XButton1 & w::Send("#{Up}") 71 | XButton1 & d::Send("#{Right}") 72 | XButton1 & t::Send("!{d}") ; 沙拉查词 73 | XButton1 & v::Send("^!+{w}") ; 微信 74 | XButton1 & x::Send("!{F4}") ; 关闭窗口 75 | XButton1 & q::Send("^{PgUp}") ; 标签页 76 | XButton1 & e::Send("^{PgDn}") ; 标签翻页 77 | ; Tab 发送 切换程序。 alt tab。caps 发送逆 Tab 78 | 79 | 80 | ; win + number 81 | End & 1::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 82 | End & 2::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 83 | End & 3::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 84 | End & 4::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 85 | End & 5::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 86 | End & 6::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 87 | End & 7::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 88 | End & 8::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 89 | End & 9::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 90 | End & 0::Send("#{" SubStr(A_ThisHotkey, 7, 1) "}") 91 | 92 | 93 | XButton1 & 1::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 94 | XButton1 & 2::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 95 | XButton1 & 3::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 96 | XButton1 & 4::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 97 | XButton1 & 5::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 98 | XButton1 & 6::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 99 | XButton1 & 7::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 100 | XButton1 & 8::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 101 | XButton1 & 9::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") 102 | XButton1 & 0::Send("#{" SubStr(A_ThisHotkey, 12, 1) "}") ; win + number 103 | 104 | 105 | Lwin & delete::Send("!{F4}") 106 | 107 | 108 | ; Ralt & x::Send("!{F4}") 109 | ; Win Power Toys 修改以后,AHK 识别的位置还是原来的,所以 win 这一套这么写。 ; 但是和 win + x 自己的菜单冲突。 在 explorer 上面使用“关闭”就是关机了。2 110 | Ralt & Esc::Send("!{Esc}") ; 不改的话 会有 bug。 111 | Ralt & q::Send("{Media_Play_Pause}#{3}") 112 | Ralt & Sc029::Send("{Media_Play_Pause}") 113 | 114 | ; !z::Send("^{" SubStr(A_ThisHotkey,-1) "}") 115 | ; !x::Send("^{" SubStr(A_ThisHotkey,-1) "}") 116 | ; !c::Send("^{" SubStr(A_ThisHotkey,-1) "}") 117 | ; !v::Send("^{" SubStr(A_ThisHotkey,-1) "}") 118 | ; !s::Send("^{" SubStr(A_ThisHotkey,-1) "}") 119 | ; !f::Send("^{" SubStr(A_ThisHotkey,-1) "}") 120 | 121 | 122 | 123 | ; ALT 数字这套方案想得太简单了,和vscode 冲突! 124 | ; 不如直接 esc + symbol = 半角符号 125 | ; !9::ClipL("()") 126 | ; !'::ClipL("“”") 127 | ; !SC02B::Clip("、") 128 | ; >!,::ClipL("《》") 129 | ; ![::ClipL("【】") 130 | ; >!.::Send("{Right}") 131 | ; !SC027::Clip(";") 136 | 137 | 138 | 139 | ; ::,,::Clip(" ,") 140 | ; ::..::Clip("。") 141 | ; :://::Clip("?") 142 | ; ::\\::Clip("、") 143 | ; ::;;::Clip(";") 144 | ; ::''::ClipL("‘’") 145 | ; ::""::ClipL("“”") 146 | ; ::MM::Clip(":") 147 | ; ::((::ClipL("()") 148 | ; ::!!::Clip("!") 149 | ; ::6..::Clip("……") 150 | 151 | 152 | 153 | Esc & sc033::Clip_with_Enter(",") 154 | Esc & sc034::Clip_with_Enter(".") 155 | Esc & SC035::Clip_with_Enter("/") 156 | Esc & SC02B::Clip_with_Enter("\") 157 | Esc & SC027::Clip_with_Enter(";") 158 | Esc & m::Clip_with_Enter(":") 159 | Esc & SC028::Clip_with_Enter("`"") ; apostrophe "" 160 | Esc & a::Clip_with_Enter("'") ;accent sign; prime '' 161 | Esc & [::Clip_with_Enter("[") 162 | Esc & ]::Clip_with_Enter("]") 163 | Esc & 9::Clip_with_Enter("(") 164 | Esc & 0::Clip_with_Enter(")") 165 | Esc & 6::Clip_with_Enter("^") 166 | 167 | 168 | ; 临时切到 英文符号,写markdown 方便一些。 中→英文→中文 169 | Clip_with_Enter(text) 170 | { 171 | Send("^{.}") 172 | Send(Text) 173 | Send("^{.}") 174 | 175 | 176 | } 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | ^End::Send("^{Tab}") 187 | 188 | ^Home::Send("^+{Tab}") 189 | 190 | !Esc::Send("^!{Esc}") 191 | SHOW_Shake() 192 | { 193 | Sleep(200) 194 | WinGetPos(&X, &Y, &W, &H, "A") 195 | if(W==0 or H == 0) 196 | { 197 | W:= 1000 198 | H:=1000 199 | } 200 | ax := X+W/2 201 | ay := Y+H/2 202 | ToolTip(A_DDDD " " A_Hour ":" A_Min,ax,ay) 203 | SetTimer () => ToolTip(), -650 204 | 205 | } 206 | 207 | Shake(){ 208 | WinGetPos(&X, &Y, &W, &H, "A") 209 | if(W==0 or H == 0) 210 | { 211 | W:= 1000 212 | H:=1000 213 | } 214 | ax := X+W/2 215 | ay := Y+H/2 216 | MouseMove(ax, ay) 217 | WinGetPos(&X, &Y, &W, &H, "A") 218 | if(W==0 or H == 0) 219 | { 220 | W:= 1000 221 | H:=1000 222 | } 223 | ax := X+W/2 224 | ay := Y+H/2 225 | MouseMove(ax, ay) 226 | ; MouseMove(ax+100, ay+100,100) 227 | Loop 20 228 | ; Change this value to control how long the mouse will shake. Each loop will be one left movement and one right. 229 | { 230 | MouseMove( 100, 50, 100, "R") 231 | Sleep 15 ; Adjust these sleep values to control how quickly the mouse moves left to right. from my own testing I would not recommend you go less than 2. Else you likely will "loose" inputs due to the mouse moving too fast. 232 | MouseMove( -100, -50, 100, "R") 233 | Sleep 15 234 | } 235 | } 236 | ; ahk 自带的函数h::AltTabMenu 237 | ; n::AltTab 238 | ; m::ShiftAltTab 239 | 240 | 241 | ; 分号 冒号 等不要改,容易在 hotstring 里面出现! 改成热键就记录不了! 242 | ; 直接使用 波浪号,效果出奇的好。`n 243 | 244 | 245 | 246 | 247 | 248 | 249 | ; !a::Send("!{left}") 250 | ; !d::Send("!{Right}") 251 | 252 | !F4::Send("!{F4}") 253 | 254 | ; RAlt::cn("forced") ; 会变成菜单焦点。 255 | ; RShift::cn("forced") 这也不行,会直接不能作为修饰按键。 256 | ; RAlt & space::change_to_en_and_put_stringSpace() 257 | 258 | ;!q 不要占用,word 要用! 259 | 260 | 261 | ; 两处之间快速跳跃 262 | End & F1:: 263 | { 264 | repeatTime:= updateSharedRepeat(, 2) 265 | switch repeatTime 266 | { 267 | case 0: Send("!{left}") 268 | case 1: Send("!{Right}") 269 | } 270 | return 271 | } 272 | 273 | ; 三处之间快速跳跃 274 | End & F2:: 275 | { 276 | repeatTime:= updateSharedRepeat(, 3) 277 | switch repeatTime 278 | { 279 | case 0: Send("!{left}") 280 | case 1: Send("!{left}") 281 | case 2: Send("!{Right 2}") 282 | } 283 | return 284 | } 285 | 286 | sc029 & up:: 287 | sc029 & h:: 288 | End & Up::ScrollCurrentWindow("{WheelUp}") 289 | End & WheelUp::ScrollCurrentWindow("{WheelUp}") 290 | 291 | sc029 & down:: 292 | sc029 & n:: 293 | End & Down::ScrollCurrentWindow("{WheelDown}") 294 | End & WheelDown::ScrollCurrentWindow("{WheelDown}") 295 | 296 | ScrollCurrentWindow(AC){ 297 | 298 | WinGetPos(&X, &Y, &W, &H, "A") 299 | MouseMove(X+W*0.75, Y+H*0.75) 300 | ; Click() 301 | Send(AC) 302 | } 303 | 304 | F1:: 305 | { 306 | Send("{BackSpace}") 307 | Sleep(750) 308 | 309 | While( GetKeyState("F1","P")) 310 | { 311 | Send("{BackSpace}") 312 | Sleep(50) 313 | } 314 | 315 | 316 | } 317 | 318 | 319 | 320 | showHelp() 321 | { 322 | ToolTip " 323 | ( 324 | Esc 特殊字符、上标、unicode ↑↑ 小字体 `n 滚轮变 Tab 通用的下一页 325 | F1 特殊字符的 ↓↓ 下标 unicode `n 滚轮变 onenote 的专门的分区下一页^{PgDn} 326 | F2 滚轮变 下一页 {PgDn} 空格加滚轮也是. 327 | F3 winSpy; Help 328 | F4 F1~F4 都设置成输入数学公式的 329 | F5 330 | F6 B 保存文本到 1 c 手动输入内容 x 选择保存路径 s 选择保存文件名为指定 d 选择保存文件名为程序名称(pdf) `n 滚轮变 superscript underscri `N 排版功能 capslock & F6:: F6 & d 331 | F7 网页相关 7/8 搜索东西/复制并 i 上线, u 下线。 F7+F12睡眠, `n youtube baidu ab 站点. e= email; F7+w 是笔记软件的文件连接;`n + 数字是保留本来 ctrl+ 数字的的功能 332 | F8 pomodoro 333 | F9 保护原有功能(ctrl 占用) 334 | F10 335 | F11 F11 AHK 相关的了- 脚本禁用、重载,退出等等。 & r::Reload ; 暂停脚本。 `n f::KeyHistory 控制窗口 全屏 F11&F10 但不如win+↑ F11 & r::Reload 336 | F12 awindows.Length 相关的了- Sleep 睡眠、锁定并睡眠p Media_Play_Pause 890 stop previous next ; `n 滚轮和 - + 变音量 . F12 backspace 静音 F12 t::用脚本同步电脑的时间.(需要管理员权限) 337 | 338 | 窗口置顶 tilde 或 ti、tl = ` & F1, !F1:: #F1:: 339 | 空格 Space : z = 隐藏窗口; 很多的 切换程序:2 Obsidian w:OneDrive r:PDF d:沙拉查词 s 340 | )" 341 | } 342 | 343 | $F2:: 344 | $F3:: 345 | $F4:: 346 | $F5:: 347 | $F6:: 348 | $F7:: 349 | $F8:: 350 | $F9:: 351 | $F10:: 352 | $F11:: 353 | $F12:: 354 | { 355 | the_key := Trim(ThisHotkey,"$") 356 | Send( "{" the_key "}" ) 357 | ToolTip 358 | } 359 | 360 | $^Esc:: 361 | $^F1:: 362 | $^F2:: 363 | $^F3:: 364 | $^F4:: 365 | $^F5:: 366 | $^F6:: 367 | $^F7:: 368 | $^F8:: 369 | $^F9:: 370 | $^F10:: 371 | $^F11:: 372 | $^F12:: 373 | { 374 | the_key := Trim(ThisHotkey,"$^") 375 | ; ToolTip(the_key) 376 | ; Send( "^{" the_key "}" ) 377 | Send( "^{" the_key "}" ) 378 | ; ToolTip 379 | } 380 | 381 | ; - { when: always, accept: Control+F12, select: .next } 382 | ; - { when: always, accept: Control+F11, select: .next } 383 | ; - { when: always, accept: Control+F10, toggle: ascii_mode } 384 | ; - { when: always, accept: Control+F9, toggle: ascii_mode } 385 | ; - { when: always, accept: Control+F8, toggle: ascii_mode } 386 | ; - { when: always, accept: Control+F7, 387 | 388 | 389 | 390 | 391 | esc & k:: 392 | !U:: 393 | Esc & Up:: 394 | Esc & WheelUp::Send("^+{Tab}") ; 在 vscode 里面需要安装ctrl 才有下拉选单,这么发送就没有这个功能了。 395 | 396 | 397 | esc & j:: 398 | !I:: 399 | Esc & Down:: 400 | Esc & WheelDown::Send("^{Tab}") 401 | 402 | 403 | 404 | 405 | 406 | ; 第二级 页面翻页 407 | ;alt + 上下只有 onenote 会用. 太少用了,不如换成翻页. 408 | ; F2 & WheelUp::Send,!{Up} 409 | ; F2 & WheelDown::Send("!{Down}") 410 | 411 | 412 | F1 & J:: 413 | F1 & Up:: 414 | F1 & WheelUp::Send("^{PgUp}") 415 | 416 | F1 & K:: 417 | F1 & Down:: 418 | F1 & WheelDown::Send("^{PgDn}") 419 | 420 | F2 & K:: 421 | F2 & Up:: 422 | F2 & WheelUp::Send("{PgUp}") 423 | F2 & J:: 424 | F2 & Down:: 425 | F2 & WheelDown::Send("{PgDn}") 426 | 427 | ; 最好是网络地址 428 | ; F3 & s::Run("C:\Program Files\AutoHotkey\awindows["py"].ahk") 429 | F3 & h::Run("C:\Users\Administrator\OneDrive\代码\AHK\AutoHotkey64.exe") 430 | F3 & w::Run("https://www.jianshu.com/p/d5f2117fb329") ; word help 431 | F3 & F1::Run("onenote:https://d.docs.live.net/ff64712bc759b896/文档/雨爽/快速笔记.one#ToDo_FrontPage§ion-id={061EB8EC-DE60-4864-B92C-7BC1380657DF}&page-id={C2166799-8231-A942-9101-C8A5CDBE9172}&end") 432 | F3 & F2::Run("obsidian://open?vault=Shaun&file=ZettleDaily%2F2022-05-11") 433 | F3 & 1::Run("onenote:https://d.docs.live.net/ff64712bc759b896/文档/雨爽/快速笔记.one#Marathon§ion-id={061EB8EC-DE60-4864-B92C-7BC1380657DF}&page-id={6833971E-4DFA-4DA8-8D42-DD9A7C0F47CC}&end") 434 | F3 & 2::Run("obsidian://open?vault=SNN&file=2%20%E7%8C%9C%E6%B5%8B%E3%80%81%E8%A6%81%E5%AE%9E%E7%8E%B0%E7%9A%84%E6%A8%A1%E5%9E%8B%2F2%20%E7%8C%9C%E6%B5%8B%E3%80%81%E8%A6%81%E5%AE%9E%E7%8E%B0%E7%9A%84%E6%A8%A1%E5%9E%8B") ; Obsidian 435 | F3 & 3::Run("obsidian://open?vault=SNN&file=3%20List%20of%20Options%2F3%20List%20of%20Options") 436 | 437 | F3 & 5::Run("obsidian://open?vault=SNN&file=5%20%E6%90%9C%E7%BD%97%E6%9D%A5%E7%9A%84%E7%BB%86%E7%A2%8E%E3%80%81%E6%9D%82%E4%B9%B1%2F5%20%E6%90%9C%E7%BD%97%E6%9D%A5%E7%9A%84%E7%BB%86%E7%A2%8E%E3%80%81%E6%9D%82%E4%B9%B1") 438 | F9 & f::SendPlay("^{f}") 439 | 440 | 441 | 442 | ;--------Onenote 情况下,这些生效-----------------------------------------------------------------Onenote 没有对应专门的 exe -------------------- 443 | ; ; edge 浏览器。 444 | ; ; #IfWinActive ahk_exe msedge.exe 445 | ; ; 特殊的行为。 446 | #HotIf WinActive("ahk_exe ApplicationFrameHost.exe") ; Onenote 等 软件 447 | F2::Send("^+{n}") ;清空格式,resetFonts 448 | F4:: ; Onenote 复制链接,复制 指向段落的连接。(指向页面和指向段落的菜单不一样,设置指向段落更好,rbutton tab 四个↓ ) #IfWinActive ahk_exe ApplicationFrameHost.exe 就是onnote 449 | { 450 | Send("{Rbutton}") 451 | Sleep(200) 452 | Send("{tab}") 453 | Sleep(200) 454 | Send("{down 1}") ;不选择文字,剪切复制不能选择,只按1下选第三个“复制 指向段落的连接” 455 | Send("{enter}") 456 | return 457 | } 458 | 459 | ; F9::Send("{Raw}+") 460 | ; F10::Send("{Raw}−") ;- −en dash - −em dash − 461 | ; F11::Send("{Raw}ᐧ") 462 | ; F12::Send("{Raw}⁄") 463 | #HotIf 464 | 465 | #HotIf WinActive("ahk_exe zotero.exe") ; Onenote 等 软件 466 | F2::voice_text_to_speach() 467 | F3::voice_text_to_speach() 468 | #HotIf 469 | 470 | f7 & z:: ; 文字 OCR 或者 PDF 复制下来,最后都会有多余的空格 471 | { 472 | Send("{Down}{End}") 473 | Send("{Delete}") 474 | Send("{space}") 475 | return 476 | } 477 | 478 | F11 & Delete::func_wordpress_change_to_soft_enter() 479 | F11 & d::func_wordpress_change_to_soft_enter() 480 | F11 & Space::Send("{⠀}") ;insert blank that you can't see, but still can be underlined. 481 | 482 | 483 | 484 | 485 | ; ; 需要重复的不适合 hotstring. 486 | F6 & WheelUp::func_superscript_text() 487 | F6 & WheelDown::func_underscript_text() 488 | ;交给 ditto 复制粘贴就行了。有更多的文本处理选择。 489 | 490 | ;但 ditoo 是纯文本的,不方便排便一大堆有链接的目录。 491 | F6 & g::Send("{End}{Delete}{End}") ;排版用 pdf 多余的回车。 492 | F6 & b::Send("{End}{Down}") ;排版用 pdf 多余的回车。 493 | ; F6 & v::Text_only_paste() ;交给 ditto 复制粘贴就行了。有更多的文本处理选择。 494 | ; F6 & F5::thesis_remove_enter_saladict() 495 | ; F6 & space::adds_two_space_before_and_after() ; 这个功能 OBSIDIAN 笔记软件的 盘古插件有这个功能, 496 | 497 | ; F6 & 6::voice_text_to_speach() ; ` & F1 鼠标 498 | F6 & F4::Pause5Seconds() ; 暂停脚本。 499 | 500 | 501 | 502 | ; F7 & i::url_go("http://10.1.88.4/") 503 | F12 & u:: go_school_offline() 504 | F12 & I::go_school_online() 505 | F12 & r::Reload 506 | 507 | 508 | F7 & F12::SetTimer(GotoSleep,-300) 509 | 510 | F7 & y::url_go("https://www.youtube.com/") 511 | F7 & b::url_go("https://www.baidu.com/") 512 | F7 & g::url_go("https://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp&gws_rd=ssl") 513 | F7 & l::url_go("https://www.bilibili.com/") 514 | F7 & a::url_go("https://www.acfun.cn/") 515 | F7 & d::url_go("https://duckduckgo.com/") 516 | F7 & o::url_go("https://www.olevod.com/") 517 | F7 & e::url_go("https://mail.google.com/mail/u/0/") 518 | 519 | 520 | 521 | F9 & 1::Send("^{1}") 522 | F9 & 2::Send("^{2}") 523 | F9 & 3::Send("^{3}") 524 | F9 & 4::Send("^{4}") 525 | F9 & 5::Send("^{5}") 526 | F9 & 6::Send("^{6}") 527 | F9 & 7::Send("^{7}") 528 | F9 & 8::Send("^{8}") 529 | F9 & 9::Send("^{9}") 530 | F9 & 0::Send("^{0}") 531 | 532 | 533 | F12 & 7:: 534 | F12 & delete::SetTimer(GotoSleep,-3000) 535 | ; Sleep/Suspend: 不要直接进入睡眠,这样脚本会有 BUG,建议设置一个 timer ,过一会睡眠 536 | 537 | GotoSleep() 538 | { 539 | DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) 540 | ; Hibernate: 541 | ;DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) 542 | Return 543 | 544 | ; Lock and sleep 545 | } 546 | F12 & l:: 547 | { 548 | Run("rundll32.exe user32.dll,LockWorkStation") 549 | Sleep(1000) 550 | ; Sleep/Suspend: 551 | DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) 552 | ; Hibernate: 553 | ;DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) 554 | Return 555 | ;上标 superscript ;wordpress enchance 增强富文本上下标功能。 556 | } 557 | 558 | 559 | F12 & WheelDown::Send("{Volume_Down}") 560 | F12 & WheelUp::Send("{Volume_Up}") 561 | F12 & BackSpace::Send("{Volume_Mute}") 562 | 563 | 564 | ;分号 和 p 控制视频的播放: 565 | F12 & SC027:: 566 | F12 & p::Send("{Media_Play_Pause}") 567 | F12 & Space::Send("{Media_Play_Pause}") 568 | F12 & 8::Send("{Media_Stop}") 569 | F12 & 9::Send("{Media_Prev}") 570 | F12 & 0::Send("{Media_Next}") 571 | F12 & -::Send("{Volume_Down}") 572 | F12 & =::Send("{Volume_Up}") 573 | 574 | 575 | ; F12 & z::SendInput("/") 576 | 577 | F12 & t:: 578 | { 579 | If (A_IsAdmin) ;- I'm 'admin' so it works 580 | { 581 | ; RunAs, Administrator ; w32tm /resync 可以强制更新windows 时间。 582 | Run("*runas cmd") 583 | ErrorLevel := WinWait("Administrator: C:\awindows.Length\System32\cmd.exe", , 3) , ErrorLevel := ErrorLevel = 0 ? 1 : 0 584 | ; 这两个打字会有问题: SendRaw, w32tm /resync SendInput, w32tm /resync 585 | ; send % "w32tm " chr( 47 ) "resync" 这种方式也不行. 那只能用剪切板了. 586 | Clip("w32tm /resync") 587 | Send("{Enter}") 588 | } 589 | else 590 | MsgBox("ADMIN=" A_IsAdmin) 591 | return 592 | } 593 | ; F12 & i::Run("`"msedge.exe www.google.com/ --new-window`"") 594 | 595 | ;Run "msedge.exe http://10.1.88.4 --new-window" 596 | 597 | ; F11 & f::KeyHistory 598 | ; F11 & r::Reload 599 | 600 | 601 | ; F9 & s::Start_Listen_window_change() 602 | 603 | 604 | 605 | ; Start_Listen_window_change(){ 606 | ; ; Gui +LastFound 607 | ; hWnd := WinExist() 608 | ; DllCall( "RegisterShellHookWindow", UInt,Hwnd ) 609 | ; MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" ) 610 | ; OnMessage( MsgNum, "ShellMessage" ) 611 | ; Return 612 | ; } 613 | 614 | 615 | 616 | ; ShellMessage( wParam,lParam ) 617 | ; { 618 | ; WinGetTitle(title, ahk_id %lParam%) 619 | ; If (wParam=4) { ; 620 | ; ToolTip WinActivated`n%Title% 621 | ; sleep 1000 622 | ; ToolTip 623 | ; } 624 | ; } 625 | -------------------------------------------------------------------------------- /Script_1 not recommend, simplified: -------------------------------------------------------------------------------- 1 | ; Quick typing and text editing version 1, easy to use and understand, but not as responsive as script 2. 2 | ; use like any other AHK script. 3 | 4 | ;这个脚本控制着语言切换和快速输入数学符号,两个功能。 使用方法:可以直接新建 txt,然后更名为 xxx.ahk,复制全部代码,运行即可使用。说明见 readme 5 | 6 | 7 | ;------------------------------------------------------------------------------------------------------------- 8 | ;Environment settings 环境设置 9 | #NoEnv 10 | #Warn 11 | SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 12 | SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 13 | 14 | 15 | ;Tracking variable settings 环境设置 16 | global Current_IME_State:= 1 ;✨1 is Eng, 2 is Chinese, (IMEs are too complicated and way too bloated to extract the key info we need, so we better track the states by ourself. )✨ 17 | global Current_IME_Is_half_width:= 0 ;✨ "1" is full-width input mode, "0" is normal. ✨ 18 | global using_keyboard_controlling_mouse:=0 19 | global using_shift_to_help_typing_in_Chinese:=1 20 | global n_mouse_move_momentum:=0 21 | global Caps_Times:= 0 ; 没啥用,这里可以删。用几个变量为脚本增加一些功能,但是这些功能都太复杂,例如点 3 次某个键, 点 4 次某个键,触发什么什么功能,需要变量来记录。但最后我都删了,因为自己都记不住。 22 | global StartTime:= 0 23 | 24 | SetCapsLockState, AlwaysOff 25 | 26 | 27 | ;------------------------------------------------------------------------------------------------------------- 28 | 29 | 30 | 31 | 32 | ;自定义短语 αβγδκλμνξπρρστυφχψωθ 33 | ;( ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ ), 34 | ;a full superscript Latin lowercase alphabet except q ( ᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ ), 35 | ;a limited uppercase Latin alphabet ( ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ), 36 | ;a few subscripted lowercase letters ( ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ ), 37 | ;and some Greek letters ( ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ). 38 | 39 | #UseHook On 40 | 41 | ; https://en.wikipedia.org/wiki/Beta_Code 42 | ; 详情如何使用请见 https://github.com/scullion/greek.ahk/blob/master/greek.ahk 43 | ; 简单地说,字母加esc 底下的撇号,例如c~ 会自动变成 ξ ,a~ 变成α ,G~大写 shift g ` 变成 Γ 44 | 45 | #Hotstring EndChars `t`` 46 | ; 上一句话将 空格触发变成了 tab 和 撇好触发 hotstring。 例如 hotstring 是 a,那么 a~ (加的撇号)会变成 α , k~ κ l~ λ 见 ahk 的官网, #Hotstring EndChars -()[]{}:;'"/\,.?!`n `t 结束符设置什么都行。 47 | ; 添加o 代表最后的撇号、Tab会被省略。 48 | ; 添加C 代表区分大小写,这样能完整的映射希腊大小写。 49 | 50 | :oC:a::α ; lower case alpha 51 | :oC:b::β ; lower case beta 52 | :oC:c::ξ ; lower case xi 53 | :oC:d::δ ; lower case delta 54 | :oC:e::ε ; lower case epsilon 55 | :oC:f::φ ; lower case phi 56 | :oC:g::γ ; lower case gamma 57 | :oC:h::η ; lower case eta 58 | :oC:i::ι ; lower case iota 59 | :oC:k::κ ; lower case kappa 60 | :oC:l::λ ; lower case lambda 61 | :oC:m::μ ; lower case mu 62 | :oC:n::ν ; lower case nu 63 | :oC:o::ο ; lower case omicron 64 | :oC:p::π ; lower case pi 65 | :oC:q::θ ; lower case theta 66 | :oC:r::ρ ; lower case rho 67 | :oC:s::σ ; lower case sigma 68 | :oC:t::τ ; lower case tau 69 | :oC:u::υ ; lower case upsilon 70 | :oC:w::ω ; lower case omega 71 | :oC:x::χ ; lower case chi 72 | :oC:y::ψ ; lower case psi 73 | :oC:z::ζ ; lower case zeta 74 | 75 | ; ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 76 | 77 | :oC:A::Α ; capital alpha 78 | :oC:B::Β ; capital beta 79 | :oC:C::Ξ ; capital xi 80 | :oC:D::Δ ; capital delta 81 | :oC:E::Ε ; capital epsilon 82 | :oC:F::Φ ; capital phi 83 | :oC:G::Γ ; capital gamma 84 | :oC:H::Ε ; capital eta 85 | :oC:I::Ι ; capital iota 86 | :oC:K::Κ ; capital kappa 87 | :oC:L::Λ ; capital lambda 88 | :oC:M::Μ ; capital mu 89 | :oC:N::Ν ; capital nu 90 | :oC:o::Ο ; capital omicron 91 | :oC:P::Π ; capital pi 92 | :oC:Q::Θ ; capital theta 93 | :oC:R::Ρ ; capital rho 94 | :oC:S::Σ ; capital sigma 95 | :oC:T::Τ ; capital tau 96 | :oC:U::Υ ; capital upsilon 97 | :oC:W::Ω ; capital omega 98 | :oC:X::Χ ; capital chi 99 | :oC:Y::Ψ ; capital psi 100 | :oC:Z::Ζ ; capital zeta 101 | 102 | ;加入 10ms 延迟,对慢速的电脑来说,输入长字符串不会出现问题。 103 | :ok10:-::━━━━━━ 104 | :ok10:par:: ∂ 105 | :ok10:partial:: ∂ 106 | :ok10:divider:: / 107 | :ok10:fraction:: ⁄ ; 1⁄1 2/2 3/3 注意三种除法的区别,第三种可读性最高。 108 | :ok10:fra::⁄ 109 | :ok10:int:: ∫ 110 | :ok10:integral:: ∫∬∭⨌∱⨑∲∳ ∮∯∰ 111 | :ok10:sets::϶∀∁∃∄∅∈∉∵∴ ⎲⎳⌠⌡ 112 | :ok10:inf:: ∞ 113 | :ok10:infinity:: ∞ 114 | :ok10:neq:: ≠ 115 | :ok10:sqrt:: √ 116 | :ok10:half:: ½ 117 | :ok10:quater:: ¼ 118 | :ok10:plusminus:: ± 119 | :ok10:plmi:: ± 120 | :ok10:12:: ½ 121 | :ok10:14:: ¼ 122 | :ok10:variesas::∝ 123 | :ok10:nabla::𝛁 ;nabla 是 电磁场中常用的运算符。 124 | :ok10:del::𝛁 ;nabla 又叫 del 125 | :ok10:sum:: Σ ;大写 s 加 撇号也行。 126 | :ok10:vec:: ⃗ ;vector 向量箭头 可能显示不出来 127 | 128 | :ok10:email::info@ksrgroupllc.com 129 | :ok10:mima::john_cena 130 | 131 | :ok10:qq::1410046075 132 | :ok10:shouji::888-646-5693 133 | :ok10:dizhi::Cardi B c/o KSR Group, LLC 244 Fifth Ave Suite K261 New York, 134 | :ok10:k4::circa-2006 135 | :ok10:k6::Imma let you know 136 | :ok10:sfz::info@ksrgroupllc.com 137 | :ok10:jiji::基极 138 | :ok10:jidianji::集电极 139 | :ok10:bji:: 基极 140 | :ok10:cji:: 集电极 141 | :ok10:eji:: 发射极 142 | :ok10:gji:: 栅极 143 | :ok10:dji:: 漏极 144 | :ok10:sji:: 源极 145 | 146 | 147 | 148 | ;⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ 上标 superscript 149 | Esc & 0::⁰ 150 | Esc & 1::¹ 151 | Esc & 2::² 152 | Esc & 3::³ 153 | Esc & 4::⁴ 154 | Esc & 5::⁵ 155 | Esc & 6::⁶ 156 | Esc & 7::⁷ 157 | Esc & 8::⁸ 158 | Esc & 9::⁹ 159 | ; 很难去按组合热键, 三个键的组合键,esc+ shift + = 不等于 esc+ "+", doesn't work 160 | Esc & \::⁺ 161 | Esc & f9::⁺ 162 | Esc & f10::⁻ 163 | Esc & f11::ᐧ 164 | Esc & f12::/ 165 | Esc & ,::≤ ;less than 166 | Esc & .::≥ ;greater than 167 | F1 & f9::+ 168 | F1 & f10::- 169 | F1 & f11::× 170 | F1 & f12::÷ 171 | 172 | Esc & -::⁻ 173 | Esc & =::⁼ 174 | Esc & [::⁽ 175 | Esc & ]::⁾ 176 | 177 | 178 | ;abcd=>>ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ 上标 superscript 179 | Esc & a::ᵃ 180 | Esc & b::ᵇ 181 | Esc & c::ᶜ 182 | Esc & d::ᵈ 183 | Esc & e::ᵉ 184 | Esc & f::ᶠ 185 | Esc & g::ᵍ 186 | Esc & h::ʰ 187 | Esc & i::ⁱ 188 | Esc & j::ʲ 189 | Esc & k::ᵏ 190 | Esc & l::ˡ 191 | Esc & m::ᵐ 192 | Esc & n::ⁿ 193 | Esc & o::ᵒ 194 | Esc & p::ᵖ 195 | Esc & r::ʳ 196 | Esc & s::ˢ 197 | Esc & t::ᵗ 198 | Esc & u::ᵘ 199 | Esc & v::ᵛ 200 | Esc & w::ʷ 201 | Esc & x::ˣ 202 | Esc & y::ʸ 203 | Esc & z::ᶻ 204 | ;-------------₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ 下标 subscript 205 | F1 & 0::₀ 206 | F1 & 1::₁ 207 | F1 & 2::₂ 208 | F1 & 3::₃ 209 | F1 & 4::₄ 210 | F1 & 5::₅ 211 | F1 & 6::₆ 212 | F1 & 7::₇ 213 | F1 & 8::₈ 214 | F1 & 9::₉ 215 | ; 很难去按组合热键, 三个键的组合键,f1+ shift + = 不等于 f1+ "+", doesn't work 216 | F1 & \::₊ 217 | F1 & -::₋ 218 | F1 & =::₌ 219 | F1 & [::₍ 220 | F1 & ]::₎ 221 | 222 | ;abcd=>>ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓ 下标 subscript 223 | F1 & a::ₐ 224 | F1 & e::ₑ 225 | F1 & h::ₕ 226 | F1 & i::ᵢ 227 | F1 & j::ⱼ 228 | F1 & k::ₖ 229 | F1 & l::ₗ 230 | F1 & m::ₘ 231 | F1 & n::ₙ 232 | F1 & o::ₒ 233 | F1 & p::ₚ 234 | F1 & q::ᵅ ;α 235 | F1 & r::ᵣ 236 | F1 & s::ₛ 237 | F1 & t::ₜ 238 | F1 & u::ᵤ 239 | F1 & v::ᵥ 240 | F1 & x::ₓ 241 | F1 & z::Send,ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ;三个组合键的代码不好写,请各位自己铺开快捷键。 242 | 243 | 244 | 245 | ;→ ←↑↓ ┷ ┯⟾⟹⟺ ⟸ 246 | Esc & Up::↑ 247 | Esc & Down::↓ 248 | Esc & Left::← 249 | Esc & Right::→ 250 | F1 & Up::⟺ 251 | F1 & Down::≝ 252 | F1 & Left::⟸ 253 | F1 & Right::⟾ 254 | F1 & /::⁄ 255 | Esc & /::⁄ 256 | F2 & l::Send,ℒ ; laplace transform 257 | F2 & f::Send,ℱ ; Fourier transform 258 | F2 & z::Send,𝒵 ; Z transform 259 | F2 & x::Send,X̅ ; capital X bar 260 | 261 | 262 | 263 | F3 & a::Send,Ā 264 | F3 & b::Send,B̅ 265 | F3 & c::Send,C̅ 266 | F3 & d::Send,D̅ 267 | F3 & x::Send,x̅X̅ ; x bar 268 | F3 & y::Send,y̅Ȳ ; y bar 269 | F3 & u::Send,∪ ;union 270 | F3 & i::Send,∩ ;intersection 271 | :ok10:bars::A̅ B̅ C̅ D̅ a̅ b̅ c̅ d̅ α̅ β̅ γ̅ δ̅ ε̅ x̅ X̅ y̅ ĀāḆḇḎḏĒēḠḡH̱ẖĪīḴḵḺḻṈŌōṞṟṮṯŪūX̱x̱ȲȳẔẕ 272 | 273 | 274 | 275 | 276 | 277 | Insert & Space:: 278 | Esc & Space::Send,{⠀} ;insert blank that you can't see, but still can be underlined. 279 | :ok10:fx::f(x) 280 | :ok10:Fx::F(x) 281 | :ok10:fx'::f'(x) 282 | :ok10:fx''::f⁽²⁾(x) 283 | :ok10:fx2::f(x)² 284 | :ok10:shuyu:: x ∈ (0,∞) ;belong 属于 285 | :ok10:nb::🐮🍺 286 | 287 | 288 | 289 | ;最后一点忠告,千万不要修改tab的功能,很影响使用! 290 | 291 | 292 | Insert & s:: ;求和 双行 Summation double line formula prefab 293 | Send, ⎲ ∞ xⁿ⁺² +{Enter}⎳n=0 n ᐧ (n{+}2) 294 | Sleep,600 295 | Send,{Up} 296 | Sleep,100 297 | Send,{Space 12}{⠀} 298 | Sleep,100 299 | Send,{Home}{Right 8}{Shift down}{End}{Shift up} 300 | Sleep,500 301 | Send ^u 302 | return 303 | 304 | Insert & i::Send, ⌠x f(u) du =+{Enter}⌡0 x ᐧ (x{+}2) ;积分 integral formula prefab 305 | Insert & 1:: ;下划线 underline formula prefab 306 | Send,{Space 6}{1}{Space 6}{⠀} ;insert blanks . finally I can underline in Onenote, thank god. 307 | Sleep,100 308 | Send,{Home}{Right 8}{Shift down}{End}{Shift up} 309 | Sleep,500 310 | Send ^u 311 | return 312 | 313 | 314 | 315 | 316 | ;√ ∞ Σ ∫ ⇑ ⇒ ⇓ ⇐ ↔⇔→⇒ 317 | ;≠≡≈≝≤≥ ∂ 318 | ;∞∘∫∫∂∮∯∇ ◠◡ 319 | ;__⭜ ‾‾⭝ ⮨⮪⮩⮫⮬⮭⮮⮯ some arraw donesn't show in text editor, but it's ok in web browser and notebook. 320 | ;🠬 🠮 🠭 🠯 ⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙ 321 | ;⯬⯭⯮⯯ ⬎⬏⬐⬑ ⟹ ⇑ 322 | ;;⮠ ⮢ ⮡ ⮣ ⮥⮤ ⮧ ⮦ ◜◟◝◞ 323 | ;↑↓←→↖↙↘↗ → ←↑↓ 324 | ;⟵⟶⟷⟸⟹⟺⟻⟼⟽⟾┷┯┠ ┨ ╋ ━ ┃ 325 | ; ╲╱╱╲ 326 | ;​ ←←here is zero-width space, is it cool? it's there but you can't seem it. 327 | ;∫   x²   ∫   x²     ∫  a²                 328 | ;∫━━━━━━━━━━ =∫━━━━━━━━━━━  +∫ ━━━━━━━━━━━  329 | ;∫   x²   ∫√(x²+a²)   ∫ √(x²+a²) 330 | ;:sets::϶∀∁∃∄∅∈∉∵∴ ⎲⎳⌠⌡ 331 | 332 | Esc::Send,{Esc} ; keep basic functions 333 | F2::Send,{F2} ; 334 | F1::Send,{F1} ; 335 | 336 | 337 | ;-------------------------------------------------------------------------------------------------------------------------------------------------- 338 | 339 | 340 | ; 我试了很多种 增强大写锁定切换语言的方法,其中第三种最好用: 341 | ; 方法一:指定语言 342 | ; 方法二:轮流切换 ctrl+shift 切换语言。 343 | ; 方法三:√ 目前脚本使用的: 使用cap 瞬间短按是轮流切换、较短是英文、长按对应中文。同时,还支持指定切换: cap+R、F、B是中、英、大写指定切换。 344 | 345 | 346 | 347 | ;其他功能: 348 | ;代码中 IME = 0 是 英文,1 是中文。 349 | 350 | 351 | 352 | CapsLock:: 353 | KeyWait, CapsLock 354 | TimeLength := A_TimeSinceThisHotkey 355 | ;MsgBox, The BackSpace key has been held down for %TimeLength%ms 356 | 357 | if( A_PriorKey = "Capslock" ){ ;我的 Cap键绑定了很多功能,例如还有 cap+w 这种组合键,不幸的是这种写法会有干扰,不加处理的话,会同时触发 cap+w 和 切换语言的功能。所以需要判断有没有其他按键按下,如果没有,再切换语言。实现方法是这个系统变量 prior key,这个变量的名字是固定的,不用加%%来表示他是变量。 358 | if (TimeLength < 200) { 359 | Function_Set_Language(9) ;翻转中英文。 360 | } 361 | else if (TimeLength < 400) { ;(英文的按键时长要 大于 200 且 小于400ms,中文 <1000ms) 362 | Function_Set_Language(1) ; 2中文,1 英文 ;para in : Current_IME_State "9" to toggle, "1" to English, "2" to Chinese, 363 | SoundBeep, 3000, 100 ;频率3000hz,时长100ms 364 | } 365 | else if (TimeLength < 1000) { 366 | Function_Set_Language(2) ; 2中文, 1 英文 367 | SoundBeep, 1790, %TimeLength% ;频率1790hz,时长是你按下去大写的时间。 368 | } 369 | else { 370 | Send,{LButton} 371 | } 372 | } 373 | else { 374 | ToolTip, 您使用了其他组合键,将不触发切换语言功能。 , 100, 150 375 | } 376 | 377 | if(Current_IME_State==1){ 378 | ToolTip, The IME is English `n You have been holding CapsLock %TimeLength%ms 。`n , 1500, 500 ; I doesn't know why it suddenly wouln't work. 379 | } 380 | else{ 381 | ToolTip, 输入法为中文状态 `n 您按住大写锁定键时长%TimeLength% 毫秒 。`n , 1600, 550 ; I doesn't know why it suddenly wouln't work. 382 | } 383 | SetTimer, RemoveToolTip, -1000 384 | return 385 | 386 | CapsLock & B::SetCapsLockState, AlwaysOn 387 | CapsLock & n::SetCapsLockState, On 388 | CapsLock & m::SetCapsLockState, Off 389 | 390 | 391 | CapsLock & [::Function_Set_Language(2) ;切换并指定为中文 para in : Current_IME_State "9" to toggle, "1" to English, "2" to Chinese, 392 | CapsLock & ]::Function_Set_Language(1) ;切换并指定为英文 393 | CapsLock & p::Func_toggle_Full_half_width(9) ;全半角切换 394 | 395 | 396 | 397 | 398 | ;wordpress增强功能。 399 | CapsLock & -:: ;上标 superscript 400 | CapsLock & T:: 401 | SC027 & T:: 402 | Send,{Shift down}{Left}{Shift up} 403 | Send,{Ctrl down}{Shift down}={Shift up}{Ctrl up} 404 | Send,{Left} 405 | return 406 | ; esc 在我的脚本里是上标的意思,F1 对应下标很好记。更简单的选择是,直接使用上下标的 unicode码。¹²³₁₂₃ 407 | CapsLock & =:: ;下标 subscript 408 | CapsLock & G:: 409 | SC027 & G:: 410 | CapsLock & F1:: 411 | Send,{Shift down}{Left}{Shift up} 412 | Send,{Ctrl down}={Ctrl up} 413 | Send,{Left} 414 | return 415 | 416 | SC027 & Enter:: 417 | CapsLock & Enter::Send,+{Enter} 418 | 419 | 420 | 421 | 422 | ;------------------------------------------------------------------------------------------------------------- 423 | ; Mouse move and click 424 | CapsLock & Up::function_my_mouse_momentum(0,-1) 425 | CapsLock & Left::function_my_mouse_momentum(-1,0) 426 | CapsLock & Down::function_my_mouse_momentum(0,1) 427 | CapsLock & right::function_my_mouse_momentum(1,0) 428 | CapsLock & Ctrl::Send,{LButton} 429 | CapsLock & Numpad0::Send,{RButton} 430 | 431 | function_my_mouse_momentum(x,y){ ;↑ y<0 ← x<0 ↓ y>0 → x>0 432 | if(A_TimeSincePriorHotKey<150){ 433 | n_mouse_move_momentum += 15 434 | } 435 | else{ 436 | n_mouse_move_momentum=32 437 | } 438 | MouseMove, x*n_mouse_move_momentum, y*n_mouse_move_momentum, 100, R 439 | 440 | ;GetKeyState, state, Capslock 441 | ;vari_a:=GetKeyState("Up") 442 | ;ToolTip, %vari_a% , 100, 150 443 | ;if (state = "D") 444 | ; ToolTip, %state% , 100, 150 445 | 446 | } 447 | ;------------------------------------------------------------------------------------------------------------- 448 | ;分号用作打字法加强,上下左右移动键,翻页加强、删除。 449 | ;分号 semicolon 不是常用按键,需要一个特殊的编码"SC027"。 450 | +SC027::Send,{:} ;保护";"原来的功能 451 | *SC027::Send,{SC027} ;保护";"原来的功能 452 | 453 | ;------------------------------------------------------------------------------------------------------------- 454 | ;moving Insertion point functions; 455 | ;move I-beam horizontally and vertically with "←↓↑→ hjkl". 456 | ;move I-beam and selecting 457 | ; VIM use following setting, the whole set is too complicated, I just use the "←↓↑→ hjkl" 458 | ;h – Moves the cursor left. j – Moves the cursor down. k – Moves the cursor up. l – Moves the cursor right. CapsLock & 2:: 459 | ; by the way VIM is too hard to learn and has practical situation to use. VIM 太难学了/用不上。 460 | 461 | 462 | CapsLock & j:: 463 | SC027 & j::Send,{Left} 464 | CapsLock & k:: 465 | SC027 & k::Send,{Down} 466 | CapsLock & i:: 467 | SC027 & i::Send,{Up} 468 | CapsLock & l:: 469 | SC027 & l::Send,{Right} 470 | 471 | 472 | ;multiple key mapped to one function for clumpsy hands and easier to memory . 473 | 474 | 475 | ; srat of line / end of line 476 | CapsLock & z:: 477 | SC027 & z::Send,{Home} 478 | CapsLock & c:: 479 | SC027 & c::Send,{End} 480 | 481 | 482 | CapsLock & w:: 483 | SC027 & w::Send,{Up} 484 | CapsLock & a:: ;previous word 485 | SC027 & a::Send,{Ctrl down}{Left}{Ctrl up} 486 | CapsLock & s:: 487 | SC027 & s::Send,{Down} 488 | CapsLock & d:: 489 | SC027 & d::Send,{Ctrl down}{Right}{Ctrl up} 490 | 491 | 492 | CapsLock & q:: 493 | SC027 & q::Send,^{backspace} ;delete a word 494 | CapsLock & e:: 495 | SC027 & e::Send,^{delete} ;delete a word after I-beam. 496 | 497 | 498 | CapsLock & r:: 499 | SC027 & r::Send,^{z} ;redo 500 | 501 | ;1→delete, `→backward delete 502 | CapsLock & u:: 503 | SC027 & u::Send,{BackSpace} 504 | CapsLock & o:: 505 | SC027 & o::Send,{Delete} 506 | 507 | 508 | 509 | 510 | ;------------------- select texts-------------- 511 | ; a little enhance ( basiclly not useful) 512 | SC027 & Left::Send,{Shift down}{Ctrl down}{Left}{Ctrl up}{Shift up} ; 513 | SC027 & Down::Send,{Shift down}{Down}{Shift up} 514 | SC027 & Up::Send,{Shift down}{Up}{Shift up} 515 | SC027 & Right::Send,{Shift down}{Ctrl down}{Right}{Ctrl up}{Shift up} 516 | CapsLock & Backspace:: 517 | SC027 & Backspace::delete_one_line() ;自定义的函数 518 | 519 | 520 | ;------------------------------------------------------------------------------------------------------------- 521 | Insert & Tab::Send,{Home}    {Down} ;添加四个全角空格,缩进,顺便换一行 522 | Insert & delete::func_wordpress_change_to_soft_enter() 523 | Insert & End::Send,{Down}{End} ;配合使用软回车、换行 524 | 525 | Insert & ]::SetTimer, Right_func, 1500 526 | Insert & [::SetTimer, Left_func, 1500 527 | 528 | ;------------------------------ functions ----------------------- 529 | ;wordpress 文字修改,这个是添加软回车,wordpress 需要一整块的文字, 530 | func_wordpress_change_to_soft_enter(){ 531 | Send,{End} 532 | Sleep, 50 533 | Send,{delete} 534 | Sleep, 50 535 | Send,{Shift down}{Enter}{Shift up}{End} 536 | return 537 | } 538 | Right_func: 539 | Send,{Right} 540 | return 541 | Left_func: 542 | Send,{Left} 543 | return 544 | 545 | ;Abandoned 546 | ;CapsLock & c:: 547 | ;using_shift_to_help_typing_in_Chinese:=using_shift_to_help_typing_in_Chinese=1?0:1 548 | ;ToolTip, 开关shift功能,用 shift 组合键帮忙打中文。`n 当前状态%using_shift_to_help_typing_in_Chinese%, 100, 150 549 | ;SetTimer, RemoveToolTip, -5000 550 | ;return 551 | 552 | ;clipboard text replace, failing function. 暂时放弃,处理剪切板里的文字挺麻烦的。 553 | ;SC027 & m::replace_enter_to_soft_enter() ; 554 | ;replace_enter_to_soft_enter(){ ;这个有点问题,字符串替换不行,函数不能用。 555 | ;SoundBeep, 3000, 100 ;频率3000hz,时长100ms 556 | ;Send {Ctrl Down}c{Ctrl Up} 557 | ;Clipboard := StrReplace(Clipboard, "`r`n", "xxxxx") 558 | ;Send {Ctrl Down}v{Ctrl Up} 559 | ;return 560 | ;} 561 | 562 | ;toggle insert mode with notification. But insert mode in win 10 is not usable; only old software support it. In Office Word you need to go to option and turn it on. 563 | Capslock & Insert:: 564 | GetKeyState, InsertState, Insert, T 565 | If InsertState = U ;If insert is off 566 | { 567 | MsgBox, 260, , Are you sure you want to enable insert?, 5 568 | } 569 | If InsertState = D ;If insert is on 570 | { 571 | MsgBox, 4, , Are you sure you want to disable insert?, 5 572 | } 573 | IfMsgBox No 574 | return 575 | else IfMsgBox Timeout 576 | return 577 | Else 578 | Send {Insert} 579 | return 580 | 581 | delete_one_line(){ 582 | Send,{Home}{Shift down}{End}{Shift up} 583 | Sleep,1 584 | Send,{BackSpace} ;删除一行,而不是删除所有文字,功能挺顺手的。 585 | return 586 | } 587 | 588 | Func_flip_IME_state(){ 589 | ;Func_alt_shift() 590 | Func_ctrl_space() ; for most of people 591 | ;Send,{Ctrl} 592 | } 593 | 594 | 595 | ; 用系统的切换语言 596 | Func_alt_shift(){ 597 | Send, {Alt down}{Shift}{Alt up} 598 | } 599 | Func_ctrl_shift(){ 600 | Send, {Ctrl down}{Shift}{Ctrl up} 601 | return 0 602 | } 603 | ; 用 ime的切换语言, 604 | Func_ctrl_space(){ 605 | Send, {Ctrl down}{Space}{Ctrl up} 606 | return 0 607 | } 608 | ;全角半角切换。 609 | Func_flip_Full_width(){ 610 | Send, +{Space} 611 | return 0 612 | } 613 | 614 | 615 | 616 | ; This is simple enough. We track IME state by ourself. 617 | ; If the state in the program doesn't synchronize to the real IME state, just make them the same using mouse clicks. 618 | 619 | ;para in : Current_IME_State "9" to toggle, "1" to English, "2" to Chinese, 620 | ;para out: no output, everything is stored in global varibles. 621 | 622 | Function_Set_Language(target_state) { 623 | SetCapsLockState, AlwaysOff ;turn off Captitals 624 | Func_toggle_Full_half_width(0) ;turn off Full-width characters. 625 | if ( target_state <>Current_IME_State ){ ; 9 ≠ 1 and 9 ≠ 2 ,一定会接环只有想要切换的语言和当前语言不同的时候才切换。 626 | Func_flip_IME_state() 627 | Current_IME_State := 3-Current_IME_State ;jump between 1,2 628 | } 629 | else{ ;nothing changes 630 | } 631 | Return 0 632 | } 633 | 634 | ;(for ascii art) 635 | ; para in : Current_IME_Is_half_width: "0" for normal and "1" to Full-width Unicode . 636 | ;para out: no output, everything is stored in global varibles. 637 | Func_toggle_Full_half_width(target_HF){ 638 | if ( target_HF <>Current_IME_Is_half_width ){ 639 | Func_flip_Full_width() 640 | Current_IME_Is_half_width := 1-Current_IME_Is_half_width ;jump between 0,1 641 | } 642 | else{ ;nothing changes 643 | } 644 | Return 0 645 | } 646 | 647 | 648 | RemoveToolTip: 649 | ToolTip 650 | return 651 | 652 | 653 | -------------------------------------------------------------------------------- /keys.md: -------------------------------------------------------------------------------- 1 | 基本:A,^, !q,!←→, + 唤出窗口:#, +#N 2 | 本软件自定义: !, !# 特殊插件、功能:^W 3 | 4 | Sc029 ···· tilde ~ SC035 / forward slash sc033 逗号 sc034 句号 SC02B \ 非标准键盘, backslash 028=' 5 | semicolon SC027 SC028 引号,(双引号没有SC 码 6 | ; ctrl +k,ctrl+s 是让 VSCode 显示快捷键设置页面。 7 | 8 | 分号 冒号 等不要改,容易在 hotstring 里面出现! 改成热键就记录不了! 9 | SC02B & enter::clip("\n") 10 | SC02B & Tab::clip("\t") 11 | SC02B & sc033::clip("/") 12 | 13 | 14 | 15 | 16 | [;常用按键最好不整重复,现在是等待逻辑,干扰之前的输入 17 | 需要特殊的编码 ; 18 | ## 重复按键 19 | repeatTime:= updateSharedRepeat(" 最大化,关闭,min,‘恢复’") 20 | switch repeatTime 21 | { 22 | case 1: if ( WinActive("ahk_exe msedge.exe")) 23 | Send("^{w}") 24 | else{ 25 | WinClose("A") 26 | } 27 | case 0: WinMaximize("A") 28 | case 2: WinMinimize("A") 29 | case 3: WinRestore("A") 30 | } 31 | return 32 | 33 | 34 | # AHK 循环列表 35 | list switch_to_a_program(titile_names, 36 | 37 | switch_to_a_program( ["沙拉查词","Salad", "Sticky"]) 38 | 直接使用就行 titile_names[1] 39 | for index, element in titile_names ; Enumeration is the recommended approach in most cases. 40 | { 41 | 42 | 43 | 44 | Ctrl_+ Tab 切换标签页和 Ctrl + pagedown 在大部分软件里面功能都是一样的。 但是 OneNote 分的更细,pgdn/up 用于切换 pages。 45 | 就是说有五种种翻页方式:标签页翻页、页面翻页、PageUp/down 正常翻一页、ctrl+home/end 文件头尾和鼠标滚轮翻一点点翻。 46 | 对于双手的情况,ESC + 滚轮 或者 ESC + jk 可以满足习惯。 47 | 对于单手的情况,还是用 ctrl+tab 吧。 48 | 49 | 50 | ctrl + 上下 在 vs 里面是"预览",也就是文字编辑不动,却可以看别处. 但是在 OneNote 里面,就是大段的上下,作用完全不一样. 51 | 52 | 53 | ; 有双击冲突的符号: :: VSCODE [[ OBSIDIAN // 写作 \\ 文件地址 54 | ; 注释最好多加一个功能, 直接复用 ^/ double 55 | 56 | 57 | 58 | 垃圾箱,不想用的函数 59 | 60 | 61 | 62 | 63 | ;#]::fun/ c_display_wintitle() 64 | ; #, 原本是预览桌面,没啥用。 65 | ; #g:: game bar 录像没法关闭,用不了 .. #h voice typer. 66 | 67 | 68 | 69 | ; 尝试检测屏幕上是否有 IME 的候选框,结论是 输入法 IME 每次弹出窗口的进程号都是新的,虽然有递增的规律,但是不同窗口的号不一样,程序判断太难,实现不了。 70 | list_all(){ 71 | ; Gui, New 72 | DetectHiddenWindows(false) 73 | owindows := WinGetList(,,,) 74 | awindows := Array() 75 | windows := owindows.Length 76 | For v in owindows 77 | { awindows.Push(v) 78 | } 79 | ret := 0 80 | r := awindows.Length . "个程序" . "`n" 81 | ; Tooltip, %windows% 82 | 83 | Loop awindows.Length 84 | { 85 | r .= awindows[A_Index] . "`t" 86 | wt := WinGetTitle("ahk_id " id) 87 | r .= ahk_id . "`t" 88 | r .= wt . "`t" 89 | r .= "..." . "`n" 90 | } 91 | ; `↓↓↓ 现实所有 wintitle 不为空的程序名. 但是 IME 没有考虑这个, 名字是空白. 92 | ; Loop %windows% 93 | ; { 94 | ; id := windows%A_Index% 95 | ; WinGetTitle wt, ahk_id %id% 96 | ; if (wt == ""){ ;wt == "dummyLayeredWnd" 不知 97 | ; Continue 98 | ; ret += 1 99 | ; } 100 | ; r .= wt . "`n" 101 | ; } 102 | ; Gui +LastFound 103 | 104 | ogcMyText.Value := r 105 | ; Gui, Show 106 | ; Tooltip, %r% 107 | return ret 108 | } 109 | 110 | 111 | 检测窗口程序的 ID 112 | check_ids() 113 | { 114 | oWindowID := WinGetList(,,,) 115 | aWindowID := Array() 116 | WindowID := oWindowID.Length 117 | For v in oWindowID 118 | { aWindowID.Push(v) 119 | } 120 | Loop aWindowID.Length { 121 | cWindow := aWindowID[A_Index] 122 | Title := WinGetTitle("ahk_id " cWindow) 123 | Message := Message "`n" Title 124 | } 125 | MsgBox("List of Visible awindows.Length , " Message) 126 | } 127 | 128 | ; if WinExist("ahk_class Notepad") or WinExist("ahk_class" . ClassName) 129 | ; WinActivate ; 使用最近找到的窗口。 130 | 131 | 132 | 文件读写 133 | ; 这种文件写入不方便和其他程序沟通 134 | func_write_string_to_a_file(){ 135 | Send("^{c}") 136 | the_clipboard:= A_Clipboard 137 | 138 | ;trust your cloud drive. 139 | SetWorkingDir(A_ScriptDir "\Q") 140 | exe_name:=get_ahk_exe_name() 141 | file_name:=get_ahk_title_name() 142 | 143 | ; pdf 文件会很烦,它的程序名字会这样: 144 | ; 2001 Temporal and spatial coding in the rat vibrissal system .pdf and 2 more pages - Personal - Microsoft​ Edge 145 | ; 或者是这样: 146 | ; isaacson2011 How Inhibition Shapes Cortical Activity.pdf - 3/13 (92 dpi) 147 | ; 只要翻页程序名字会不一样,所以需要做一些裁剪. 148 | 149 | Title := WinGetTitle("A") 150 | FoundPos := InStr(Title, ".pdf") 151 | if ( FoundPos = 0 ){ 152 | location_file:= Title . ".md" 153 | } 154 | else{ 155 | OutputVar := SubStr(Title, 1, -1*(FoundPos)) 156 | location_file:= OutputVar . ".md" 157 | } 158 | ; location_file := "..\文档\QuickNotes" . location_file 159 | ; MsgBox, FoundPos %FoundPos% `n 最终位置 %location_file% `n %Title% 160 | FileEncoding("UTF-8") ; UTF 8 是包括中文的。 ; 如果不加, md 文件特别容易乱码。(我不知道怎么给 md 文件 加 BOM,我不太懂文件编码,但这一定是最简单的方法) 161 | FileAppend(the_clipboard "`n", location_file) ; 文件名不要加引号,否则识别不出来。 162 | 163 | SoundBeep(1000, 100) 164 | ToolTip(location_file " 已经写入。") 165 | A_Clipboard:= the_clipboard 166 | SetTimer(RemoveToolTip,-1000) 167 | } 168 | func_write_inputbox(){ 169 | SetWorkingDir(A_ScriptDir "\..\文档\QuickNotes") 170 | exe_name:=get_ahk_exe_name() 171 | file_name:=get_ahk_title_name() 172 | ;InputBox, UserInput, Quick Notes, It will be added, Hide, 200, 200,0,0 173 | location_file:= exe_name ".md" 174 | IB := InputBox("It will be added to " location_file, "Quick Notes", "w200 h150 x900 y900"), UserInput := IB.Value, ErrorLevel := IB.Result="OK" ? 0 : IB.Result="CANCEL" ? 1 : IB.Result="Timeout" ? 2 : "ERROR" 175 | FileAppend(UserInput "`n", location_file) 176 | } 177 | 178 | 179 | 更简单的复制粘贴 180 | take_notes( program){ 181 | ; freeze_clipboard() 182 | 183 | the_clipboard:= A_Clipboard 184 | Send("^{c}") 185 | Sleep(100) 186 | switch_to_a_program( [ program] ) ; 换成切换程序坏借鉴 187 | Sleep(200) 188 | Send("{Enter}") 189 | Send("^{v}") 190 | Sleep(100) 191 | Send("!{Tab}") 192 | A_Clipboard := the_clipboard 193 | } 194 | 195 | 196 | ; A_IdleTimePhysical 在快捷键出发的时候一定会被置零, 不实用了,需要自己记录几秒之前的状态. get_idle_time_before_this_key(t) t 取正值, t 越大取得时间越远. 197 | get_idle_time_before_this_key(*){ 198 | global TimeIdleKeyboardArray 199 | global index_Time 200 | global maxValue_Time 201 | 202 | get_i := mod(index_Time - 3+ maxValue_Time , maxValue_Time) 203 | ; ToolTip, %get_i% index_Time =%index_Time% 204 | return TimeIdleKeyboardArray[get_i] 205 | ; 206 | } 207 | 208 | 209 | ; 启动 exe 。run 这个指令需要用需要添加到环境变量里面。不在里面的话是运行不了的,而且这个必须是文件名一模一样。 快速启动大法 win + R 。 210 | Open_and_switch_to_a_program(titile_name,program_exe, software_has_the_need_to_hide_prompt := "false"){ 211 | ; Msgbox, %titile_name% %program_exe% debug winactive 默认找程序不行,需要指定 第二个模式,包含 title 就能切换过去,不死板地匹配。 212 | 213 | SetTitleMatchMode(2) 214 | ; WinActivate, %titile_name%,,2 215 | if WinExist(titile_name) 216 | { 217 | WinActivate() 218 | } 219 | else 220 | { 221 | Run(program_exe) 222 | ; 千万不要使用 runwait,那个是等他结束了 223 | ErrorLevel := WinWait(titile_name) , ErrorLevel := ErrorLevel = 0 ? 1 : 0 224 | ; SoundBeep, 2500,200 225 | if ( software_has_the_need_to_hide_prompt = "true") ; 第三个参数时可选的,默认不隐藏。 226 | func_hide_scoop_shim() 227 | } 228 | } 229 | func_hide_scoop_shim(){ 230 | ; scoop 这个软件的副作用,不用 scoop 管理器可以不加这句话。 shim “垫片” 过渡程序并不消失,但是 terminus bug 更重,连 shim 都不能关闭。 231 | ; 我知道了更深的原因,发过 GUI 的同学都知道, CLI 用来输出一些开发过程用的文字。但因为正常打开软件,标准输出是没有窗口的,所以那个黑窗口不存在。我们 run 却提供了一个 stdout 和 stderr 窗口。 232 | ; 但是如何把标准流 弄到 null 里面我不太会, ; RunWait, %program_exe% "">nul"", , Max ?? 干脆隐藏这个窗口就算了. 233 | ; 错误的解决方法: run 最后的参数 max 改成 hide。真的藏起来了,但对于正常程序是真的找不到了。愚蠢的方法 234 | SetTitleMatchMode(2) 235 | SetTitleMatchMode("slow") 236 | ; 不要用 IfWinExist 237 | WinExist("scoop\shims") 238 | WinHide() 239 | ; WinClose 240 | ; hide 最终只多出一个 2.0 MB 的程序, cpu 占用是 0% ,隐藏不渲染就不占用 cpu。除非开发人员像我一样话唠, stdout/err 很多,但是估计隐藏起来话多也影响不大,hide 是可以接受的方法。 run program >nul 没有成功。 241 | } 242 | 243 | 244 | 245 | F11 & a::all_program() 246 | all_program(){ 247 | DetectHiddenWindows(false) 248 | owindows := WinGetList(,,,) 249 | awindows := Array() 250 | windows := owindows.Length 251 | For v in owindows 252 | { awindows.Push(v) 253 | } 254 | Loop awindows.Length 255 | { 256 | id := awindows[A_Index] 257 | wt := WinGetTitle("ahk_id " id) 258 | r .= wt . "`t" 259 | } 260 | ToolTip(r) 261 | } 262 | ; 263 | 264 | List(listName,integer) 265 | { 266 | Loop Parse, listName, "|" 267 | { 268 | If (integer = A_Index) { 269 | returnValue := A_LoopField 270 | } 271 | } 272 | return returnValue 273 | } 274 | 275 | 276 | Language_code_on_GUI_Eng1_Chinese2_tray_icon(){ 277 | ; 假设你的任务栏是白色,在“语言栏”下方取几个点。如果全是白色,那么说明没有检测到“中”这个字下面的黑色,那么就是“英” 278 | ; 0xEEEEEE is white,白色色。因为不同输入法 GUI 字体不一样,多试几个点。黑色不一定是纯的 000000, 279 | CoordMode("Pixel", "Screen") 280 | color1 := PixelGetColor(14, 945, "Slow") 281 | color2 := PixelGetColor(14, 946, "Slow") 282 | color3 := PixelGetColor(15, 943, "Slow") 283 | color4 := PixelGetColor(16, 946, "Slow") 284 | ;tooltip, %color1% %color2% %color3% %color4%, 14,945,2 285 | if( is_white(color1) and is_white(color2) and is_white(color3) and is_white(color4)) 286 | return 1 ;全是白色,没有检测到“中”这个字下面的黑色,那么就是“英” 287 | else 288 | return 2 289 | } 290 | is_white(vv){ 291 | if(vv = 0xBEBEBE or vv = 0xEEEEEE or vv = 0xFFFFFF) 292 | return 1 293 | else 294 | return 0 295 | } 296 | is_black(vv){ 297 | if(is_white(vv)) 298 | return 0 299 | else 300 | return 1 301 | } 302 | 303 | ; 但是上一个方法只能针对固定宽度的任务栏,有的用户不会缩到最小,而且大家的桌面都不太一样,所以写一个稍微智能点的方法。 304 | Language_code_GUI_Eng1_Chin2_tray_icon_AHK_line_search(){ 305 | global IME_icon_position_x 306 | global IME_icon_position_y 307 | ; REMOVED: SetBatchLines, -1 308 | CoordMode("Pixel", "Screen") 309 | mark1:=0 310 | mark2:=0 311 | ; 因为桌面都不太一样,所以写一个稍微智能点的方法。 312 | ; version 2 313 | ; 那么做一个行扫描,对“中”“英”最底下那行扫描,判断两组黑点的位置区别,可以判断中英文输入法状态。 314 | ; 以下四个位置选择一个。矩形搜索只需要左上和右下两个点。 315 | ;如果你的任务栏是放下面(默认位置) 316 | ;leftup_x:= 1692 ; 自己量一下!! 1739 1692 都有可能,用 ahk 的 window spy查看。 317 | leftup_x:= 1733 ; 用 ahk 的 window spy查看。 318 | ;leftup_y:= 1062 ; leftup_y:= 1067 1062 319 | leftup_y:= 1065 ; leftup_y:= 1067 320 | rightdown_x:= 1780 321 | rightdown_y:= 1067 322 | 323 | ;如果你的任务栏是放上面 324 | ;leftup_x:= 1739 325 | ;leftup_y:= 26 326 | ;rightdown_x:= 1777 327 | ;rightdown_y:= 26 328 | ;如果的任务栏在左侧( 1080p 屏幕的第 944 行)。 对于任务栏放在屏幕左右的情况,由于它们宽度不是固定的,需要扫描范围大一点。 329 | ;leftup_x:= 0 330 | ;leftup_y:= 944 331 | ;rightdown_x:= 450 332 | ;rightdown_y:= 945 333 | ;debug 334 | ;mousemove , %leftup_x%, %leftup_y% 335 | mark1x:=0 336 | mark1y:=0 337 | mark2x:=0 338 | mark2y:=0 339 | ; 我这个算法分成两次 search,“英”扫到左下角和右下角的距离,撇和衲,距离合适则是“英”这个字。如果不是合适的距离(过远),那么就是扫到别的东西了,可以判断是“中”字。 340 | IME_icon_position_x:=leftup_x 341 | IME_icon_position_y:=leftup_y 342 | ErrorLevel := !PixelSearch(&mark1x, &mark1y, leftup_x, leftup_y, rightdown_x, rightdown_y, 0x000000, 200, "Fast") 343 | if ErrorLevel 344 | { 345 | return 8 346 | ;MsgBox, 111That color was not found in the specified region. 347 | } 348 | ;debug 349 | ;mousemove , %mark1x%, %mark1y% 350 | start2:= mark1x + 7 351 | ErrorLevel := !PixelSearch(&mark2x, &mark2y, start2, leftup_y, rightdown_x, rightdown_y, 0x000000, 200, "Fast") 352 | if ErrorLevel 353 | { 354 | return 8 355 | ;MsgBox, 111That color was not found in the specified region. 356 | } 357 | mark2x:=99999 358 | distance:= Abs(mark2x - mark1x) 359 | ;debug 360 | ;mousemove , %mark2x%, %mark2y% 361 | ;Tooltip, IME= search two strokes in character`n ……%mark1x% %mark2x%, 200 , 980 362 | SetTimer(RemoveToolTip,-3000) 363 | 364 | 365 | 366 | if( distance< 18 ) { ; 18 > distance >5 符合"英"字最低下分开的两部分,能判断是英文。如果中文状态,只会扫描到了中字最下面一点。 367 | return 1 368 | } 369 | else{ 370 | return 2 371 | } 372 | } 373 | 374 | F5 & n::cycle_through_programs("n") 375 | cycle_through_programs(the_key) 376 | { 377 | Send("#{Tab}") 378 | ErrorLevel := !KeyWait(the_key, "T0.7") 379 | while(ErrorLevel = 1) 380 | { 381 | Send("{Right}") 382 | ErrorLevel := !KeyWait(the_key, "T0.7") 383 | } 384 | Send("{enter}") 385 | return 386 | } 387 | 388 | 389 | sc029 & C:: ; 快速移动鼠标位置 390 | { 391 | while( key("c")){ 392 | WinGetPos(&X, &Y, &W, &H, "A") 393 | MouseGetPos(&xpos, &ypos) 394 | Sleep(50) 395 | MouseGetPos(&xpos2, &ypos2) 396 | vectorx:= (xpos2 - xpos)*5 397 | vectory:= (ypos2 - ypos)*5 398 | MouseMove(vectorx, vectory, 100, "R") 399 | MouseGetPos(&xpos3, &ypos3) 400 | ToolTip(xpos3 " " ypos3) 401 | ; 屏幕的中心, 副屏幕是负数. 402 | ; MouseMove, 500, 1000 403 | ; MouseMove, -700, 1100 404 | ; if(A_PriorHotkey != "sc029 & b") 405 | ; MouseMove, 500, 1000 406 | ; else { 407 | ; MouseMove, -700, 1100 408 | ; } 409 | ; BlockInput, Mousemove 410 | ; KeyWait, B 411 | ; BlockInput, MouseMoveOff 412 | } 413 | Return 414 | } 415 | 416 | 417 | ; AutoHotkey v1.1 到 V2 改得太多太麻烦了 删除! 418 | F5 & /::func_wait_my_secondary_command_Length_2() 419 | func_wait_my_secondary_command_Length_2(){ 420 | ; InputHook vs. Input (v1) 改得太多太麻烦了删除! 421 | ; ih := InputHook("L2 T10","{enter}.{esc}{tab}"), ihUserInput.Start(), ihUserInput.Wait(), UserInput := ihUserInput.Input 422 | ; ih.Start() 423 | ; ih.Wait() 424 | 425 | ; switch ErrorLevel 426 | ; { 427 | ; case "Max": 428 | ; MsgBox, You entered "%UserInput%", which is the maximum length of text. 429 | ; return 430 | ; case "Timeout": 431 | ; MsgBox, You entered "%UserInput%" at which time the input timed out. 432 | ; return 433 | ; case "NewInput": 434 | ; return 435 | ; default: 436 | ; if InStr(ErrorLevel, "EndKey:") 437 | ; { 438 | ; MsgBox, You entered "%UserInput%" and terminated the input with %ErrorLevel%. 439 | ; return 440 | ; } 441 | ; } 442 | 443 | ; switch ih.Input 444 | ; { 445 | ; case "dd": delete_one_line() 446 | ; case "de": delete_from_here_to_end_of_the_line() 447 | ; case "fl": Send("{backspace 3}Florida") 448 | ; case "ca": Send(", {backspace 3}California") 449 | ; ; case "ho": Run, Explorer C:\awindows.Length\System32\drivers\etc 450 | 451 | 452 | 453 | ; } 454 | } 455 | 456 | 457 | 458 | ; 每次空格都不能对齐新的一页,这个功能搜索黑色文字的像素,跳过空白区域。(直到有黑色的东西) 459 | check_blank_space_and_skip(){ 460 | 461 | if (WinExist("A")){ 462 | Title := WinGetTitle() 463 | Class := WinGetClass() 464 | Proc := WinGetProcessName() 465 | flag := 1 466 | ; ToolTip(Title "`n" Title "`n" Proc) 467 | if( Proc == "zotero.exe"){ 468 | while (flag){ 469 | PixelSearch( &outx,&outy, 143,184,944,200,0x000000,150) 470 | if( outx == ""){ ; 找黑色,没找到就是空字符串,白色,应该跳过白色区域。 471 | Send("{WheelDown}") 472 | flag := 1 473 | ; ToolTip( outx " {WheelDown} " outy , 143,184) 474 | } 475 | else 476 | flag := 0 477 | } 478 | 479 | } 480 | } 481 | } 482 | ; ebebeb 灰色, zotero 页面直接的分割线,用于找到一页的开始。 483 | ; ffffff 白色,000000 黑色。 484 | 485 | check_blank_space_and_skip_up(){ 486 | 487 | if (WinExist("A")){ 488 | Title := WinGetTitle() 489 | Class := WinGetClass() 490 | Proc := WinGetProcessName() 491 | flag := 1 492 | ; ToolTip(Title "`n" Title "`n" Proc) 493 | if( Proc == "zotero.exe"){ 494 | 495 | while (flag){ 496 | PixelSearch( &outx,&outy, 143,184,944,300,0x000000,150) ; 找黑色 497 | if( outx != ""){ ; 白色 498 | Send("{WheelUp 2}") 499 | flag := 1 500 | Sleep(200) 501 | ; SoundBeep() 502 | } 503 | else 504 | flag := 0 505 | 506 | } 507 | 508 | } 509 | } 510 | } 511 | 512 | 513 | if (WinExist("A")){ 514 | Title := WinGetTitle() 515 | Class := WinGetClass() 516 | Proc := WinGetProcessName() 517 | ; ToolTip(Title "`n" Title "`n" Proc) 518 | if( Proc == "zotero.exe"){ 519 | 520 | if( xpos == W -1){ 521 | MouseMove( -20, 0, 50, "R") 522 | ToolTip( xpos) 523 | } 524 | } 525 | } 526 | 527 | 528 | $1:: 529 | { 530 | global M_altered_wait_click 531 | if( M_altered_wait_click ==0) 532 | { 533 | Send("1") 534 | } 535 | else if( M_altered_wait_click == 1) 536 | { 537 | Click("Down") 538 | ErrorLevel := !KeyWait("1") ; hold down 539 | Click("Up") 540 | } 541 | } 542 | 543 | $2:: 544 | { 545 | global M_altered_wait_click 546 | if( M_altered_wait_click ==0) 547 | { 548 | Send("2") 549 | } 550 | else if( M_altered_wait_click == 1) 551 | { 552 | Click("Down Middle") 553 | ErrorLevel := !KeyWait("2") ; hold down 554 | Click("Up Middle") 555 | } 556 | } 557 | $3:: 558 | { 559 | global M_altered_wait_click 560 | if( M_altered_wait_click ==0) 561 | { 562 | Send("3") 563 | } 564 | else if( M_altered_wait_click == 1) 565 | { 566 | Click("Down Right") 567 | ErrorLevel := !KeyWait("3") ; hold down 568 | Click("Up Right") 569 | } 570 | } 571 | 572 | ; mouse speed 573 | ; 这个函数多次进入是会“暂停”的,应该用全局变量保存。 574 | ; prior 记录根本不准, →↑↑ 会变成 ↑,必须每次都重新扫描 575 | function_my_mouse_momentum(x,y){ 576 | global speed 577 | global Ts 578 | global LastX 579 | global LastY 580 | global remap_arrow2m_not_using 581 | base_speed := "90" 582 | base_sleep_time := 60 583 | speed := base_speed 584 | 585 | 586 | if( remap_arrow2m_not_using == 1 ) 587 | { 588 | Ts := A_TickCount 589 | ToolTip("长时间不动 speed reseted 速度重置了 `n " A_TickCount) 590 | speed:=base_speed 591 | } 592 | 593 | 594 | 595 | ThisKey := GetKeyState( A_ThisHotKey,'p') 596 | 597 | 598 | ;加入循环自己判定,而不是按照 Auto repeat 判断时间间隔。 599 | ; ToolTip(speed "`n" GetKeyState( A_ThisHotkey,'p') "`n" A_ThisHotkey) 600 | while( ThisKey ){ 601 | ThisKey := GetKeyState( A_ThisHotKey,'p') 602 | type := isDirections(A_PriorHotkey) 603 | if( type ){ 604 | if(GetKeyState( A_PriorHotkey,'p')) 605 | add_vector_directional(&x,&y,type) 606 | } 607 | 608 | TimeLength := A_TickCount - Ts + 1 609 | k := Exp(-(TimeLength/800)) * 0.94 ; 数字越大衰减越慢。400 合适。 610 | speed := Max( speed * k,10) 611 | ToolTip( speed "`n" GetKeyState( A_ThisHotKey,'p') "`n" A_ThisHotKey "`n latter_key`n" A_PriorHotkey GetKeyState( A_PriorHotkey,'p') ,0,0 ) 612 | MouseMove(x*speed, y*speed, 100, "R") 613 | remap_arrow2m_not_using := 0 614 | 615 | Sleep(10) 616 | } 617 | SetTimer () => ToolTip("speed reseted"), -550 ;`这样的计时器是新建的,不会刷新。只有新建一个真的函数才会共享一个变量。 function_flag_mouse 618 | SetTimer(function_flag_mouse, -500 ) 619 | SetTimer () => ToolTip(), -1050 620 | 621 | 622 | } 623 | smart_wheelUpDown() 624 | { 625 | Title := WinGetProcessName("A") ;模仿按住中间浏览的操作. 626 | ;更具鼠标的位置发送滚轮上下. 627 | ToolTip(return_last_combined_key() ) 628 | 629 | while( key(return_last_combined_key()) ){ 630 | 631 | WinGetPos(&X, &Y, &W, &H, "A") 632 | MouseGetPos(&xpos, &ypos) 633 | ; relative to current window 634 | ; d := Min( Abs(Y + 50 -ypos ) , Abs( Y+H - 150 - ypos) ) 635 | 636 | ; relative to whole screen 637 | d := Min( Abs( 0 -ypos ) , Abs( A_ScreenHeight - ypos) ) 638 | sleep_time := Min( 500, 2 + 500*d/H) 639 | 640 | if ( xpos < X or xpos > X+W or ypos < Y or ypos > Y+H){ 641 | Click() 642 | } 643 | if( ypos > Y- H*0.3 and ypos < Y + H*0.55) 644 | Send("{WheelUp}") 645 | else if( ypos > Y+ H*0.55 and ypos < Y+ H*1.3 ) 646 | Send("{WheelDown}") 647 | 648 | Sleep(sleep_time) 649 | } 650 | } -------------------------------------------------------------------------------- /Script_2 recommend Enhance keyboard: -------------------------------------------------------------------------------- 1 | ;script 2, advanced version, need run in administrator mode. 2 | ; enhanced text selecting funcion. Quick typing and editing is the same 3 | ;-------------------------Caps + wasd to move (double tap aa/dd to fast move)---------- 4 | ; Q W E R 5 | ; backspace ↑(!) delete home(!) 6 | ; A S D F 7 | ; ←(!) ↓(!) →(!) end(!) 8 | ; Z X C V 9 | ; redo (ctrl+z) cut copy paste 10 | ;--------------------Caps + Space + wasd to rapidly move--------------------------------- 11 | 12 | 13 | ; The hotstring and and formula typing Greek letters example is in the readme on the website. (superscripts and undersccripts) 14 | ; Press Caps change the language, caps + B to turn on capital. 15 | 16 | ; another function is manipulating text, Caps + wasd to navigate, adding Alt to jumping-select words. 17 | 18 | 19 | 20 | 21 | 22 | ;it's modern and intuitive. Same settings to the righ hand "7890 uiop jkl; m,./" . 23 | 24 | 25 | ;Environment settings 环境设置 26 | #NoEnv 27 | #Warn 28 | SendMode Input 29 | SetWorkingDir %A_ScriptDir% 30 | 31 | 32 | ;Tracking variable settings 环境设置 33 | global Current_IME_State:= 1 ;✨1 is Eng, 2 is Chinese, (IMEs are too complicated and way too bloated to extract the key info we need, so we better track the states by ourself. )✨ 34 | global Current_IME_Is_half_width:= 0 ;✨ "1" is full-width input mode, "0" is normal. ✨ 35 | global using_keyboard_controlling_mouse:=0 36 | 37 | ;K1 is this key, K2 is prior key, and K3 is the key that befor prior key. _T for time of pressing. 38 | global K1:=0 39 | global K2:=0 40 | global K3:=0 41 | global K1_T:=0 42 | global K2_T:=0 43 | global K3_T:=0 44 | global K12_T_span:=0 45 | is_double_tap_happening := 0 46 | ;(just check a to z) 47 | global using_shift_to_help_typing_in_Chinese:=1 48 | global n_mouse_move_momentum:=0 49 | global Caps_Times:= 0 ; 没啥用,这里可以删。用几个变量为脚本增加一些功能,但是这些功能都太复杂,例如点 3 次某个键, 点 4 次某个键,触发什么什么功能,需要变量来记录。但最后我都删了,因为自己都记不住。 50 | global StartTime:= 0 51 | 52 | SetCapsLockState, AlwaysOff 53 | ;------------------------------------------------------------------------------------------------------------- 54 | 55 | 56 | 57 | 58 | ;自定义短语 αβγδκλμνξπρρστυφχψωθ 59 | ;( ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ ), 60 | ;a full superscript Latin lowercase alphabet except q ( ᵃ ᵇ ᶜ ᵈ ᵉ ᶠ ᵍ ʰ ⁱ ʲ ᵏ ˡ ᵐ ⁿ ᵒ ᵖ ʳ ˢ ᵗ ᵘ ᵛ ʷ ˣ ʸ ᶻ ), 61 | ;a limited uppercase Latin alphabet ( ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ), 62 | ;a few subscripted lowercase letters ( ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ ), 63 | ;and some Greek letters ( ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ). 64 | 65 | #UseHook On 66 | 67 | 68 | ; Inspired by : https://github.com/scullion/greek.ahk/blob/master/greek.ahk 69 | ; 70 | 71 | #Hotstring EndChars `t`` 72 | ; 将空格触发变成了 tab 和 撇号触发 hotstring。可选这些结束符 #Hotstring EndChars -()[]{}:;'"/\,.?!`n `t 。 73 | ; 例如 a~ (加字母加 esc 底下的撇号)会变成 α , k~ κ l~ λ ,、例如c~ 会自动变成 ξ ,a~ 变成α ,G~大写 shift g ` 变成 Γ 。添加o 代表最后的撇号、Tab会被省略。添加C 代表区分大小写,这样能完整的映射希腊大小写字母。 74 | 75 | :oC:a::α ; lower case alpha 76 | :oC:b::β ; lower case beta 77 | :oC:c::ξ ; lower case xi 78 | :oC:d::δ ; lower case delta 79 | :oC:e::ε ; lower case epsilon 80 | :oC:f::φ ; lower case phi 81 | :oC:g::γ ; lower case gamma 82 | :oC:h::η ; lower case eta 83 | :oC:i::ι ; lower case iota 84 | :oC:k::κ ; lower case kappa 85 | :oC:l::λ ; lower case lambda 86 | :oC:m::μ ; lower case mu 87 | :oC:n::ν ; lower case nu 88 | :oC:o::ο ; lower case omicron 89 | :oC:p::π ; lower case pi 90 | :oC:q::θ ; lower case theta ; https://en.wikipedia.org/wiki/Beta_Code 91 | :oC:r::ρ ; lower case rho 92 | :oC:s::σ ; lower case sigma 93 | :oC:t::τ ; lower case tau 94 | :oC:u::υ ; lower case upsilon 95 | :oC:w::ω ; lower case omega 96 | :oC:x::χ ; lower case chi 97 | :oC:y::ψ ; lower case psi 98 | :oC:z::ζ ; lower case zeta 99 | 100 | ; ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ 101 | 102 | :oC:A::Α ; capital alpha 103 | :oC:B::Β ; capital beta 104 | :oC:C::Ξ ; capital xi 105 | :oC:D::Δ ; capital delta 106 | :oC:E::Ε ; capital epsilon 107 | :oC:F::Φ ; capital phi 108 | :oC:G::Γ ; capital gamma 109 | :oC:H::Ε ; capital eta 110 | :oC:I::Ι ; capital iota 111 | :oC:K::Κ ; capital kappa 112 | :oC:L::Λ ; capital lambda 113 | :oC:M::Μ ; capital mu 114 | :oC:N::Ν ; capital nu 115 | :oC:o::Ο ; capital omicron 116 | :oC:P::Π ; capital pi 117 | :oC:Q::Θ ; capital theta 118 | :oC:R::Ρ ; capital rho 119 | :oC:S::Σ ; capital sigma 120 | :oC:T::Τ ; capital tau 121 | :oC:U::Υ ; capital upsilon 122 | :oC:W::Ω ; capital omega 123 | :oC:X::Χ ; capital chi 124 | :oC:Y::Ψ ; capital psi 125 | :oC:Z::Ζ ; capital zeta 126 | 127 | ;加入 10ms 延迟,对慢速的电脑来说,输入长字符串不会出现问题。 128 | :ok10:-::━━━━━━ 129 | :ok10:par:: ∂ 130 | :ok10:partial:: ∂ 131 | :ok10:divider:: / 132 | :ok10:fraction:: ⁄ ; 1⁄1 2/2 3/3 注意三种除法的区别,第三种可读性最高。 133 | :ok10:fra::⁄ 134 | :ok10:int:: ∫ 135 | :ok10:integral:: ∫∬∭⨌∱⨑∲∳ ∮∯∰ 136 | :ok10:sets::϶∀∁∃∄∅∈∉∵∴ ⎲⎳⌠⌡ 137 | :ok10:inf:: ∞ 138 | :ok10:infinity:: ∞ 139 | :ok10:neq:: ≠ 140 | :ok10:sqrt:: √ 141 | :ok10:half:: ½ 142 | :ok10:quater:: ¼ 143 | :ok10:plusminus:: ± 144 | :ok10:plmi:: ± 145 | :ok10:12:: ½ 146 | :ok10:14:: ¼ 147 | :ok10:variesas::∝ 148 | :ok10:nabla::𝛁 ;nabla 是 电磁场中常用的运算符。 149 | :ok10:del::𝛁 ;nabla 又叫 del 150 | :ok10:sum:: Σ ;大写 s 加 撇号也行。 151 | :ok10:vec:: ⃗ ;vector 向量箭头 可能显示不出来 152 | 153 | :ok10:email::c15601360539@gmail.com 154 | :ok10:youxiang::15601360539@163.com 155 | :ok10:mima::john_cenam 156 | 157 | :ok10:qq::A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 158 | :ok10:shouji::A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 159 | :ok10:dizhi::北京A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 北京市A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 160 | :ok10:k4::A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 161 | :ok10:k6::A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 162 | :ok10:sfz::A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 163 | :ok10:jiji::基极 164 | :ok10:jidianji::集电极 165 | :ok10:bji:: 基极 166 | :ok10:cji:: 集电极 167 | :ok10:eji:: 发射极 168 | :ok10:gji:: 栅极 169 | :ok10:dji:: 漏极 170 | :ok10:sji:: 源极 171 | 172 | 173 | 174 | ;⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺⁻⁼ ⁽ ⁾ 上标 superscript ; esc 在我的脚本里是上标的意思,F1 对应下标很好记。更简单的选择是,直接使用上下标的 unicode码。¹²³₁₂₃ 175 | Esc & 0::⁰ 176 | Esc & 1::¹ 177 | Esc & 2::² 178 | Esc & 3::³ 179 | Esc & 4::⁴ 180 | Esc & 5::⁵ 181 | Esc & 6::⁶ 182 | Esc & 7::⁷ 183 | Esc & 8::⁸ 184 | Esc & 9::⁹ 185 | ; 很难去按组合热键, 三个键的组合键,esc+ shift + = 不等于 esc+ "+", doesn't work 186 | Esc & \::⁺ 187 | Esc & f9::⁺ 188 | Esc & f10::⁻ 189 | Esc & f11::ᐧ 190 | Esc & f12::/ 191 | Esc & ,::≤ ;less than 192 | Esc & .::≥ ;greater than 193 | F1 & f9::+ 194 | F1 & f10::- 195 | F1 & f11::× 196 | F1 & f12::÷ 197 | 198 | Esc & -::⁻ 199 | Esc & =::⁼ 200 | Esc & [::⁽ 201 | Esc & ]::⁾ 202 | 203 | 204 | ;abcd=>>ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻ 上标 superscript 205 | Esc & a::Send,ᵃᵅ ;'a' and 'α' in one place is due to we don't have much combination of keys to use. 206 | Esc & b::ᵇ 207 | Esc & c::ᶜ 208 | Esc & d::ᵈ 209 | Esc & e::ᵉ 210 | Esc & f::ᶠ 211 | Esc & g::ᵍ 212 | Esc & h::ʰ 213 | Esc & i::ⁱ 214 | Esc & j::ʲ 215 | Esc & k::ᵏ 216 | Esc & l::ˡ 217 | Esc & m::ᵐ 218 | Esc & n::ⁿ 219 | Esc & o::ᵒ 220 | Esc & p::ᵖ 221 | Esc & r::ʳ 222 | Esc & s::ˢ 223 | Esc & t::ᵗ 224 | Esc & u::ᵘ 225 | Esc & v::ᵛ 226 | Esc & w::ʷ 227 | Esc & x::ˣ 228 | Esc & y::ʸ 229 | Esc & z::ᶻ 230 | ;-------------₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ 下标 subscript 231 | F1 & 0::₀ 232 | F1 & 1::₁ 233 | F1 & 2::₂ 234 | F1 & 3::₃ 235 | F1 & 4::₄ 236 | F1 & 5::₅ 237 | F1 & 6::₆ 238 | F1 & 7::₇ 239 | F1 & 8::₈ 240 | F1 & 9::₉ 241 | ; 很难去按组合热键, 三个键的组合键,f1+ shift + = 不等于 f1+ "+", doesn't work 242 | F1 & \::₊ 243 | F1 & -::₋ 244 | F1 & =::₌ 245 | F1 & [::₍ 246 | F1 & ]::₎ 247 | 248 | ;abcd=>>ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓ 下标 subscript 249 | F1 & a::ₐ 250 | F1 & e::ₑ 251 | F1 & h::ₕ 252 | F1 & i::ᵢ 253 | F1 & j::ⱼ 254 | F1 & k::ₖ 255 | F1 & l::ₗ 256 | F1 & m::ₘ 257 | F1 & n::ₙ 258 | F1 & o::ₒ 259 | F1 & p::ₚ 260 | F1 & r::ᵣ 261 | F1 & s::ₛ 262 | F1 & t::ₜ 263 | F1 & u::ᵤ 264 | F1 & v::ᵥ 265 | F1 & x::ₓ 266 | F1 & z::Send,ᴬ ᴮ ᴰ ᴱ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴼ ᴾ ᴿ ᵀ ᵁ ⱽ ᵂ ᵅ ᵝ ᵞ ᵟ ᵋ ᶿ ᶥ ᶲ ᵠ ᵡ ᵦ ᵧ ᵨ ᵩ ᵪ ;三个组合键的代码不好写,请各位自己铺开快捷键。 267 | 268 | 269 | 270 | ;→ ←↑↓ ┷ ┯⟾⟹⟺ ⟸ 271 | Esc & Up::↑ 272 | Esc & Down::↓ 273 | Esc & Left::← 274 | Esc & Right::→ 275 | F1 & Up::⟺ 276 | F1 & Down::≝ 277 | F1 & Left::⟸ 278 | F1 & Right::⟾ 279 | F1 & /::⁄ 280 | Esc & /::⁄ 281 | F2 & l::Send,ℒ ; laplace transform 282 | F2 & f::Send,ℱ ; Fourier transform 283 | F2 & z::Send,𝒵 ; Z transform 284 | ;see more A𝐀𝐴𝑨𝖠𝗔𝘈𝘼𝒜𝓐𝕬𝙰𝔸 curly letters, calligraphy script, Bold Italic at wiki : https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols 285 | F2 & x::Send,X̅ ; capital X bar 286 | F2 & Left::Send,⟷ 287 | F2 & Right::Send,⟷ 288 | 289 | F3 & a::Send,Ā 290 | F3 & b::Send,B̅ 291 | F3 & c::Send,C̅ 292 | F3 & d::Send,D̅ 293 | F3 & x::Send,x̅X̅ ; x bar 294 | F3 & y::Send,y̅Ȳ ; y bar 295 | F3 & u::Send,∪ ;union 296 | F3 & i::Send,∩ ;intersection 297 | 298 | :ok10:bars::A̅ B̅ C̅ D̅ a̅ b̅ c̅ d̅ α̅ β̅ γ̅ δ̅ ε̅ x̅ X̅ y̅ ĀāḆḇḎḏĒēḠḡH̱ẖĪīḴḵḺḻṈŌōṞṟṮṯŪūX̱x̱ȲȳẔẕ 299 | 300 | 301 | 302 | 303 | ;------------------------------------------------------------------------------------------------------------- 304 | Insert & Tab::Send,{Home}{Space 4}{Down} ;code indent 305 | Insert & delete::func_wordpress_change_to_soft_enter() 306 | Insert & End::Send,{Down}{End} ;配合上一个函数使用 307 | Insert & ]::SetTimer, Right_func, 1500 308 | Insert & [::SetTimer, Left_func, 1500 309 | Insert & Space:: 310 | Esc & Space::Send,{⠀} ;insert blank that you can't see, but still can be underlined. 311 | :ok10:fx::f(x) 312 | :ok10:Fx::F(x) 313 | :ok10:fx'::f'(x) 314 | :ok10:fx''::f⁽²⁾(x) 315 | :ok10:fx2::f(x)² 316 | :ok10:shuyu:: x ∈ (0,∞) ;belong 属于 317 | :ok10:nb::🐮🍺 318 | 319 | 320 | Insert & s:: ;求和 双行 Summation double line formula prefab 321 | Send, ⎲ ∞ xⁿ⁺² +{Enter}⎳n=0 n ᐧ (n{+}2) 322 | Sleep,600 323 | Send,{Up} 324 | Sleep,100 325 | Send,{Space 12}{⠀} 326 | Sleep,100 327 | Send,{Home}{Right 8}{Shift down}{End}{Shift up} 328 | Sleep,500 329 | Send ^u 330 | return 331 | 332 | Insert & i::Send, ⌠x f(u) du =+{Enter}⌡0 x ᐧ (x{+}2) ;积分 integral formula prefab 333 | Insert & 1:: ;下划线 underline formula prefab 334 | Send,{Space 6}{1}{Space 6}{⠀} ;insert blanks . finally I can underline in Onenote, thank god. 335 | Sleep,100 336 | Send,{Home}{Right 8}{Shift down}{End}{Shift up} 337 | Sleep,500 338 | Send ^u 339 | return 340 | 341 | ; 一个比较对齐了的双行分式 342 | Insert & f::Send, 1 ᐧ 1 = 1 ᐧ 1 ⠀ +{Enter} 1{-}u² u{+}1 (u{+}1)² u{-}1⠀ 343 | ; onenote 没有置中的快捷键,所以我弄几个置中、置左、置右的 alt 组合快捷键。 344 | Insert & w:: 345 | func_onenote_center() 346 | Send,{Enter} 347 | return 348 | Insert & e:: 349 | func_onenote_center() 350 | Send,{right} 351 | sleep, 200 352 | Send,{Enter} 353 | return 354 | Insert & r:: 355 | func_onenote_center() 356 | Send,{right} 357 | sleep, 200 358 | Send,{right} 359 | sleep, 200 360 | Send,{Enter} 361 | return 362 | 363 | ;√ ∞ Σ ∫ ⇑ ⇒ ⇓ ⇐ ↔⇔→⇒ 364 | ;≠≡≈≝≤≥ ∂ 365 | ;∞∘∫∫∂∮∯∇ ◠◡ 366 | ;__⭜ ‾‾⭝ ⮨⮪⮩⮫⮬⮭⮮⮯ some arraw donesn't show in text editor, but it's ok in web browser and notebook. 367 | ;🠬 🠮 🠭 🠯 ⇐⇑⇒⇓⇔⇕⇖⇗⇘⇙ 368 | ;⯬⯭⯮⯯ ⬎⬏⬐⬑ ⟹ ⇑ 369 | ;;⮠ ⮢ ⮡ ⮣ ⮥⮤ ⮧ ⮦ ◜◟◝◞ 370 | ;↑↓←→↖↙↘↗ → ←↑↓ 371 | ;⟵⟶⟷⟸⟹⟺⟻⟼⟽⟾┷┯┠ ┨ ╋ ━ ┃ 372 | ; ╲╱╱╲ 373 | ;​ ←←here is zero-width space, is it cool? it's there but you can't seem it. 374 | ;∫   x²   ∫   x²     ∫  a²                 375 | ;∫━━━━━━━━━━ =∫━━━━━━━━━━━  +∫ ━━━━━━━━━━━  376 | ;∫   x²   ∫√(x²+a²)   ∫ √(x²+a²) 377 | ;:sets::϶∀∁∃∄∅∈∉∵∴ ⎲⎳⌠⌡ 378 | 379 | Esc::Send,{Esc} ; keep basic functions 380 | F2::Send,{F2} ; 381 | F1::Send,{F1} ; 382 | 383 | 384 | 385 | ;-------------------------------------------------------------------------------------------------------------------------------------------------- 386 | ~CapsLock:: ; 使用cap 瞬间短按是轮流切换、较短是英文、长按对应中文。同时,还支持指定切换: 387 | BlockInput, On 388 | isCaps_pressing := false 389 | isSpace_pressing := false 390 | 391 | Start_time := A_TickCount 392 | Pressing_Caps_TimeLength := 0 393 | threshold_time := 150 394 | Loop 395 | { 396 | Sleep, 50 397 | func_record_keys() 398 | check_is_there_double_tap() 399 | 400 | isCaps_pressing := GetKeyState("CapsLock", "P") 401 | Pressing_Caps_TimeLength := A_TickCount - Start_time 402 | isSpace_pressing := GetKeyState("Space", "P") 403 | ;ToolTip, In the loop of CAPSLOCK!!`npriorKey = %A_PriorKey% `t number =%A_Index% `nisCaps_pressing = %isCaps_pressing% isSpace_pressing = %isSpace_pressing%`n`n Start_time =%Start_time% Pressing time = %Pressing_Caps_TimeLength%`n K123= %K1% %K2% %K3% `n time span = %K12_T_span%` Double Tap is happening : %is_double_tap_happening% , 100, 150 404 | ;----------------- Caps +Space + wasd.. to select ---------------------------- 405 | if(isSpace_pressing){ 406 | if( GetKeyState("A", "P")) 407 | CSa() 408 | if( GetKeyState("S", "P")) 409 | CSs() 410 | if( GetKeyState("D", "P")) 411 | CSd() 412 | if( GetKeyState("W", "P")) 413 | CSw() 414 | if( GetKeyState("R", "P")) 415 | CSr() 416 | if( GetKeyState("F", "P")) 417 | CSf() 418 | if( (isCaps_pressing = 0) and (isSpace_pressing = 1)) 419 | dont_select_anymore(A_PriorKey) 420 | continue 421 | } 422 | ;----------------- Caps + wasd.. to move ↑←↓→ ----------------------------; caps a = jump to left, like the controller in the game, double tap is run and pressing is walk. 423 | if( GetKeyState("A", "P") && is_double_tap_happening) 424 | Ca_double() 425 | else if (GetKeyState("A", "P")) 426 | Ca() 427 | if( GetKeyState("D", "P") && is_double_tap_happening) 428 | Cd_double() 429 | else if(GetKeyState("D", "P")) 430 | Cd() 431 | if( GetKeyState("F", "P")) 432 | Cf() 433 | if( GetKeyState("W", "P")) 434 | Cw() 435 | if( GetKeyState("S", "P")) 436 | Cs() 437 | if( GetKeyState("R", "P")) 438 | Cr() 439 | 440 | ;if(A_PriorKey = "Capslock" and Pressing_Caps_TimeLength >threshold_time ) 441 | ;ToolTip, Now release for CHN , 100, 150 ; It should be short, so don't need this tip. 442 | } 443 | Until (isCaps_pressing = 0) ; AHK don't use "==" to compare boolean. 444 | 445 | ;----------------- Switching language ---------------------------- 446 | if( A_PriorKey = "Capslock" ){ ;filter other combination of keys. 447 | 448 | ; toggle logic 翻转中英文。 parameter 2 = 中,1 = ENG, "9" = toggle 449 | ;if (Pressing_Caps_TimeLength < 500) { 450 | ; Function_Set_Language(9) ; 451 | ;} 452 | 453 | ;designate logic : tap for Eng, long pressing for Chinese. 454 | if (Pressing_Caps_TimeLength < threshold_time) { 455 | Function_Set_Language(1) ;Eng 456 | ;SoundBeep, 1560, 100 ; sound frequency 3000hz,duration 100ms 457 | } 458 | else if (Pressing_Caps_TimeLength < 1500) { 459 | Function_Set_Language(2) ;Chn 460 | } 461 | else { 462 | Send,{LButton} 463 | } 464 | } 465 | 466 | if(Current_IME_State==1){ 467 | ToolTip, The IME is English `n You have been holding CapsLock %Pressing_Caps_TimeLength%ms 。`n , 100, 300 468 | } 469 | else{ 470 | ToolTip, 输入法为中文状态 `n 您按住大写锁定键时长%Pressing_Caps_TimeLength% 毫秒 。`n , 1660, 750 471 | } 472 | 473 | 474 | SetTimer, RemoveToolTip, -1000 475 | BlockInput, Off 476 | return 477 | 478 | CapsLock & e::Ce() 479 | CapsLock & q::cq() 480 | CapsLock & B::SetCapsLockState, AlwaysOn ;cap+[、]、B是中、英、大写指定切换。 481 | CapsLock & 6::SetCapsLockState, On 482 | CapsLock & 7::SetCapsLockState, Off 483 | CapsLock & F1::Function_Set_Language(2) ;切换并指定为中文 para in : Current_IME_State "9" to toggle, "1" to English, "2" to Chinese, 484 | CapsLock & F2::Function_Set_Language(1) ;切换并指定为英文 485 | CapsLock & N::Func_flip_Full_width() ;全半角切换 486 | 487 | CapsLock & Tab::Send,{Enter} 488 | CapsLock & `:: 489 | CapsLock & 1:: 490 | CapsLock & 2:: 491 | CapsLock & 3::Send,{Space} 492 | CapsLock & 4::Send,+{Enter} 493 | CapsLock & 5::Send,+{Enter} 494 | CapsLock & [::Send,{{} 495 | CapsLock & ]::Send,{}} 496 | CapsLock & -::Send,{_} 497 | CapsLock & =::Send,{+} 498 | CapsLock & SC027::Send,{:} 499 | CapsLock & '::Send,{"} 500 | CapsLock & ,::Send,{<} 501 | CapsLock & .::Send,{>} 502 | CapsLock & /::Send,{?} 503 | CapsLock & SC02B::Send,{|} ;backslash and | 504 | CapsLock & Backspace::Send,{Backspace} 505 | CapsLock & Enter::Send,{Enter} 506 | CapsLock & Up::Send,{Up} 507 | CapsLock & Down::Send,{Down} 508 | CapsLock & Left::Send,{Left} 509 | CapsLock & Right::Send,{Right} 510 | ;上标 superscript ;wordpress enchance 增强富文本上下标功能。 511 | CapsLock & T:: 512 | SC027 & T:: 513 | Send,{Shift down}{Left}{Shift up} 514 | Send,{Ctrl down}{Shift down}={Shift up}{Ctrl up} 515 | Send,{Left} 516 | return 517 | CapsLock & G:: 518 | SC027 & G:: 519 | Send,{Shift down}{Left}{Shift up} 520 | Send,{Ctrl down}{=}{Ctrl up} 521 | Send,{Left} 522 | return 523 | 524 | 525 | 526 | +SC027::Send,{:} ;保护";"原来的功能 ;分号不是常用按键,需要一个特殊的编码 semicolon is "SC027"。 527 | *SC027::Send,{SC027} ;保护";"原来的功能 528 | 529 | 530 | 531 | ;------------------------------ functions ----------------------- 532 | ;wordpress 文字修改,这个是添加软回车,wordpress 需要一整块的文字, 533 | func_wordpress_change_to_soft_enter(){ 534 | Send,{End} 535 | Sleep, 50 536 | Send,{delete} 537 | Sleep, 50 538 | Send,{Shift down}{Enter}{Shift up}{End} 539 | return 540 | } 541 | Right_func: 542 | Send,{Right} 543 | return 544 | Left_func: 545 | Send,{Left} 546 | return 547 | 548 | ;Abandoned 549 | ;CapsLock & c:: 550 | ;using_shift_to_help_typing_in_Chinese:=using_shift_to_help_typing_in_Chinese=1?0:1 551 | ;ToolTip, 开关shift功能,用 shift 组合键帮忙打中文。`n 当前状态%using_shift_to_help_typing_in_Chinese%, 100, 150 552 | ;SetTimer, RemoveToolTip, -5000 553 | ;return 554 | 555 | ;clipboard text replace, failing function. 暂时放弃,处理剪切板里的文字挺麻烦的。 556 | ;SC027 & m::replace_enter_to_soft_enter() ; 557 | ;replace_enter_to_soft_enter(){ ;这个有点问题,字符串替换不行,函数不能用。 558 | ;SoundBeep, 3000, 100 ;频率3000hz,时长100ms 559 | ;Send {Ctrl Down}c{Ctrl Up} 560 | ;Clipboard := StrReplace(Clipboard, "`r`n", "xxxxx") 561 | ;Send {Ctrl Down}v{Ctrl Up} 562 | ;return 563 | ;} 564 | ;最后两点忠告:1)千万不要修改tab的功能,很影响使用! 分号和大写锁定,insert 这几个键平常都不太用,比较好改。 2) space 改完以后也会变得软绵绵的,(弹起后才会触发,反应非常慢,找了很多地方都解决不了),千万不要改这个按键。 565 | ;大写锁定复用了很多次:1)短按重映射大写锁定为切换语言;较长按下去 caps (200-400 ms) ,用来指定切换到英文(而不是轮流切换),长按 caps (400-1000 ms) 是切换到中文。caps + B 指定切换到英文大写 CAPITAL .
566 | ;toggle insert mode with notification. But insert mode in win 10 is not usable; only old software support it. In Office Word you need to go to option and turn it on. 567 | Capslock & Insert:: 568 | GetKeyState, InsertState, Insert, T 569 | If InsertState = U ;If insert is off 570 | { 571 | MsgBox, 260, , Are you sure you want to enable insert?, 5 572 | } 573 | If InsertState = D ;If insert is on 574 | { 575 | MsgBox, 4, , Are you sure you want to disable insert?, 5 576 | } 577 | IfMsgBox No 578 | return 579 | else IfMsgBox Timeout 580 | return 581 | Else 582 | Send {Insert} 583 | return 584 | 585 | 586 | delete_one_line(){ 587 | Send,{Home}{Shift down}{End}{Shift up} 588 | Sleep,1 589 | Send,{BackSpace} ;删除一行,而不是删除所有文字,功能挺顺手的。 590 | return 591 | } 592 | 593 | Func_flip_IME_state(){ 594 | ;Send,{Alt down}{Shift}{Alt up} 595 | Send,{Ctrl down}{Shift}{Ctrl up} 596 | ;Send,{Ctrl down}{Space}{Ctrl up} 597 | ;Send,{Ctrl} 598 | } 599 | 600 | ;全角半角切换。 601 | Func_flip_Full_width(){ 602 | Send, +{Space} 603 | return 0 604 | } 605 | 606 | 607 | 608 | 609 | ;para in : Current_IME_State "9" to toggle, "1" to English, "2" to Chinese, 610 | ;para out: no output, everything is stored in global varibles. 611 | 612 | Function_Set_Language(target_state) { 613 | SetCapsLockState, AlwaysOff ;turn off Captitals 614 | Current_IME_State := check_CODE_AHK() 615 | if ( target_state <>Current_IME_State ){ ; 9 ≠ 1 and 9 ≠ 2 ,一定会接环只有想要切换的语言和当前语言不同的时候才切换。 616 | Func_flip_IME_state() 617 | Current_IME_State := 3-Current_IME_State 618 | } 619 | else{ ;nothing changes 620 | } 621 | Return 0 622 | ;manully record language state, " jump between 1,2" it's primative and not useful. better use language code. 623 | } 624 | 625 | ;Abandoned, it's primative and not useful. 626 | ;para in : Current_IME_Is_half_width: "0" for normal and "1" to Full-width Unicode . 627 | ;para out: no output, everything is stored in global varibles. 628 | ;Func_toggle_Full_half_width(target_HF){ ;(for ascii art) 629 | ; if ( target_HF <>Current_IME_Is_half_width ){ 630 | ; Func_flip_Full_width() 631 | ; Current_IME_Is_half_width := 1-Current_IME_Is_half_width ;jump between 0,1 632 | ; } 633 | ; else{ ;nothing changes 634 | ; } 635 | ;Return 0 636 | ;} 637 | 638 | 639 | RemoveToolTip: 640 | ToolTip 641 | return 642 | 643 | function_my_mouse_momentum(x,y){ ;↑ y<0 ← x<0 ↓ y>0 → x>0 644 | if(A_TimeSincePriorHotKey<150){ 645 | n_mouse_move_momentum += 15 646 | } 647 | else{ 648 | n_mouse_move_momentum=32 649 | } 650 | MouseMove, x*n_mouse_move_momentum, y*n_mouse_move_momentum, 100, R 651 | 652 | ;GetKeyState, state, Capslock 653 | ;vari_a:=GetKeyState("Up") 654 | ;ToolTip, %vari_a% , 100, 150 655 | ;if (state = "D") 656 | ; ToolTip, %state% , 100, 150 657 | 658 | } 659 | 660 | type(speed, str){ 661 | SetKeyDelay, %speed% 662 | Send, %str% 663 | } 664 | 665 | func_onenote_center(){ 666 | Send,{Alt} 667 | sleep, 200 668 | Send,{Down} 669 | sleep, 200 670 | Send,{Left} 671 | sleep, 200 672 | Send,{Left} 673 | sleep, 200 674 | Send,{Left} 675 | sleep, 200 676 | Send,{Left} 677 | sleep, 200 678 | Send,{Left} 679 | sleep, 200 680 | Send,{Left} 681 | sleep, 200 682 | Send,{Left} 683 | sleep, 200 684 | Send,{Enter} 685 | sleep, 200 686 | } 687 | 688 | ;------------------------- 689 | ; ^ = Ctrl + = Shift +{Enter} {Home} {End} {Left} {Up} Send,{Left} {Backspace} {Delete} ^{Z} ^{Delete} 690 | ;^+{Left} ^+{Right} delete_one_line() 691 | Ca(){ 692 | Send,{Left} 693 | } 694 | Ca_double(){ 695 | Send,^{Left} 696 | } 697 | 698 | Cs(){ 699 | Send,{Down} 700 | } 701 | Cd_double(){ 702 | Send,^{Right} 703 | } 704 | Cd(){ 705 | Send,{Right} 706 | } 707 | Cf(){ 708 | Send,{End} 709 | } 710 | Cr(){ 711 | Send,{Home} 712 | } 713 | Cq(){ 714 | Send,{Backspace} 715 | } 716 | Cw(){ 717 | Send,{Up} 718 | } 719 | Ce(){ 720 | Send,{Delete} 721 | } 722 | 723 | CSq(){ 724 | Send,{Backspace} 725 | } 726 | CSw(){ 727 | Send,{Shift down}{Up}{Shift up} 728 | } 729 | CSe(){ 730 | Send,{Delete} 731 | } 732 | CSr(){ 733 | Send,{Shift down}{Home}{Shift up} 734 | } 735 | CSa(){ 736 | Send,{Shift down}{Ctrl down}{Left}{Ctrl up}{Shift up} 737 | } 738 | CSs(){ 739 | Send,{Shift down}{Down}{Shift up} 740 | } 741 | CSd(){ 742 | Send,{Shift down}{Ctrl down}{Right}{Ctrl up}{Shift up} 743 | } 744 | CSf(){ 745 | Send,{Shift down}{End}{Shift up} 746 | } 747 | dont_select_anymore(Last_key){ ;if you know how the windows decide where the insertion point will be after selecting texts, you will know this is simplified. 748 | if( Last_key = "a" or Last_key = "w" or Last_key = "r") 749 | Send,{Left} 750 | if( Last_key = "s" or Last_key = "d" or Last_key = "f") 751 | Send,{Right} 752 | 753 | } 754 | 755 | 756 | 757 | 758 | func_record_keys(){ 759 | abcd_xyz := "a" 760 | global K1 761 | global K2 762 | global K3 763 | global K1_T 764 | global K2_T 765 | global K3_T 766 | global K12_T_span 767 | Loop 26{ 768 | abcd_xyz := Chr(A_Index+96) 769 | if(GetKeyState( abcd_xyz, "P")){ ; if any char in alphabet pressed, record the time and which. 770 | K3:= K2 771 | K2:= K1 772 | K1:= Chr(A_Index+96) 773 | 774 | K3_T:=K2_T 775 | K2_T:=K1_T 776 | K1_T:=A_TickCount 777 | 778 | K12_T_span := K1_T - K2_T 779 | } 780 | 781 | } 782 | } 783 | check_is_there_double_tap(){ 784 | global is_double_tap_happening 785 | global K1 786 | global K2 787 | global K3 788 | global K1_T 789 | global K2_T 790 | global K3_T 791 | global K12_T_span 792 | if( ( K1 = K2) && ( K12_T_span > 120) && ( K12_T_span <400)){ ;This depend on your setting, keyboard repeat delay and repeat rate has something to do with it, however I totally changed the way it works. 793 | is_double_tap_happening = 1 794 | } 795 | if( ( K12_T_span > 500 || K1<> K2) ){ 796 | is_double_tap_happening = 0 797 | 798 | } 799 | 800 | 801 | } 802 | 803 | 804 | ;languageCode_0404 := "Chinese_Taiwan Chinese_PRC Chinese_Hong_Kong" 805 | ; languageCode_0409 := "English_United_States" languageCode_0809 := "English_United_Kingdom" languageCode_0c09 := "English_Australian" languageCode_1009 := "English_Canadian" languageCode_1409 := "English_New_Zealand" languageCode_1809 := "English_Irish" languageCode_1c09 := "English_South_Africa" languageCode_2009 := "English_Jamaica" languageCode_2409 := "English_Caribbean" languageCode_2809 := "English_Belize" languageCode_2c09 := English_Trinidad" languageCode_3009 := "English_Zimbabwe" languageCode_3409 := "English_Philippines" 806 | 807 | 808 | 809 | check_CODE_AHK(){ 810 | if !LangID := GetKeyboardLanguage(WinActive("A")) 811 | { 812 | MsgBox, % "GetKeyboardLayout function failed " ErrorLevel 813 | return 814 | } 815 | 816 | if (LangID = 0x0409) 817 | { 818 | ;ToolTip, Language is EN 819 | return 1 820 | 821 | } 822 | else if (LangID = 0x080C) 823 | ToolTip, Language is FR 824 | else if (LangID = 0x0813) 825 | ToolTip, Language is NL 826 | else if (LangID = 0x0804) 827 | { 828 | ;ToolTip, Language is CHN 829 | return 2 830 | } 831 | 832 | 833 | 834 | } 835 | 836 | 837 | GetKeyboardLanguage(_hWnd=0) 838 | { 839 | if !_hWnd 840 | ThreadId=0 841 | else 842 | if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", _hWnd, "UInt", 0, "UInt") 843 | return false 844 | 845 | if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt") 846 | return false 847 | 848 | return KBLayout & 0xFFFF 849 | } 850 | -------------------------------------------------------------------------------- /MAIN.ahk: -------------------------------------------------------------------------------- 1 | #SingleInstance 2 | 3 | A_HotkeyInterval := 2000 ; This is the default value (milliseconds). 4 | A_MaxHotkeysPerInterval := 200 5 | SetCapsLockState("AlwaysOff") 6 | ; SetWorkingDir(A_ScriptDir) 7 | CoordMode("Mouse", "Screen") 8 | ; init_pixel_find() 9 | ScriptStartModTime := FileGetTime( A_ScriptFullPath) 10 | SetTimer(CheckScriptUpdate,100,0x7FFFFFFF) ; 100 ms, highest priority 11 | SetTimer(WatchCursor,100) ;这个设置了获取鼠标信息的频率,数值越小边缘热区越灵敏 12 | InstallKeybdHook 13 | InstallMouseHook 14 | 15 | 16 | ; 函数最好直接放在第一个本体,后面的细节再慢慢添加。 17 | ; 多个文件看得清楚,功能相当于复制到这里。 vscode 装了 ahkv2-lsp 插件以后,在文件名上点击 F12 可以直接跳转过去。 18 | #Include "%A_ScriptDir%\Modifiers.ahk" 19 | #Include "%A_ScriptDir%\Basic_Remap.ahk" 20 | #Include "%A_ScriptDir%\HotStrings.ahk" 21 | #Include "%A_ScriptDir%\Mouse.ahk" 22 | 23 | ; vscode 拆分两列用菜单进行选择就行了: alt+v; 编辑器布局 L ;双列 T; 而传统软件 Obsidian 需要 alt + shift + ijkl 切换, n/m 新建分列。 24 | ; 切换直接用 ctrl +1/2 就能切换 25 | ; C:\Users\c1560\scoop\apps\autohotkey\1.1.33.09\v2.0-beta.7 26 | 27 | A_TrayMenu.Add() ; 创建分隔线. 28 | A_TrayMenu.Add("虚拟桌面1 Ctrl+Win+←→", MenuHandler1) ; 创建新菜单项. 29 | A_TrayMenu.Add("虚拟桌面2", MenuHandler2) 30 | A_TrayMenu.Add("虚拟桌面3", MenuHandler3) 31 | A_TrayMenu.Add("Pomodoro Timer", MenuHandler4) 32 | A_TrayMenu.Add("End Pomodoro", MenuHandler5) 33 | 34 | I_Icon := A_ScriptDir . "\open-book.png" 35 | if FileExist(I_Icon) 36 | TraySetIcon(I_Icon) 37 | 38 | 39 | 40 | 41 | 42 | cn(mode := "两次切换Ctrl+Shift", smart_half:=0){ 43 | switch mode{ 44 | ; 通过两次 ctrl+shift 切换,利用中文输入法的默认状态变成中文。(假设平时只使用 shift,并且默认状态是 chn) 45 | case "两次切换Ctrl+Shift": 46 | Func_flip_IME_state("^+") 47 | Sleep 30 48 | Func_flip_IME_state("^+") 49 | 50 | 51 | ;1 2 两种中文输入法 52 | case "set win hotkey": Send("!+{2}") 53 | case "强制通过 postmessage 切换输入法": PostMessage 0x0050, 0, 0x8040804,, "A" 54 | ; 0x4040404 是繁体中文!,简体中文的编号是什么 0x8040804 55 | 56 | 57 | ;下面切换的方法都不太靠谱 58 | case "TrackingByMyself": Function_Set_Language_by_tracking(2) 59 | case "flip_toogle": Func_flip_IME_state() 60 | case "讯飞输入法的特殊逻辑Ctrl+. space": Send("^.^{Space 2}") ; 利用 全角半角切换一定是中文内这个特性进行切换。 61 | case "讯飞输入法的特殊逻辑Ctrl+. shift": Send("^.{Shift 2}") ; 利用 全角半角切换一定是中文内这个特性进行切换。 62 | 63 | } 64 | clear_mouse_flag_altered() 65 | if( smart_half == 1) 66 | Other_things_when_toggling_IME() ; vscode 之中使用半角中文. 67 | } 68 | 69 | 70 | ; 只是 set language 的快捷入口,不要做派发! 71 | en(mode := "两次切换Ctrl+Shift"){ 72 | switch mode{ 73 | ; 通过两次 ctrl+shift 切换,利用中文输入法的默认状态变成中文。(假设平时只使用 shift,并且默认状态是 chn) 74 | case "两次切换Ctrl+Shift": 75 | Func_flip_IME_state("^+") 76 | Sleep 30 77 | Func_flip_IME_state("^+") 78 | Func_flip_IME_state("Shift") 79 | 80 | case "set win hotkey": Send("!+{3}") ; win11 快捷键丢失的 bug 更严重了,甚至不是重启后丢失?? 设置丢失只是看不见,但还能用 81 | case "强制通过 postmessage 切换输入法": PostMessage 0x0050, 0, 0x4090409,, "A" ; 0x0050 is WM_INPUTLANGCHANGEREQUEST. 82 | 83 | ;下面切换的方法都不太靠谱 84 | case "TrackingByMyself": Function_Set_Language_by_tracking(1) 85 | case "flip_toogle": Func_flip_IME_state() 86 | case "讯飞输入法的特殊逻辑Ctrl+. space": Send("^.^{Space 1}") ; 利用 全角半角切换一定是中文内这个特性进行切换。 87 | case "讯飞输入法的特殊逻辑Ctrl+. shift": Send("^.{Shift 1}") ; 利用 全角半角切换一定是中文内这个特性进行切换。 88 | 89 | } 90 | clear_mouse_flag_altered() 91 | Sleep(100) 92 | ; Other_things_when_toggling_IME() 93 | } 94 | 95 | 96 | 97 | ; switch IME 98 | Func_flip_IME_state(mode:="Shift"){ 99 | 100 | switch mode 101 | { 102 | case "Shift": Send("{Shift down}{Shift Up}") 103 | case "ctrl+space": Send("^{Space}") 104 | case "tilde": Send("{sc029}") ; ctrl+shift , alt+shift, grave 这三个是一组 105 | case "^": Send("{Ctrl Down}{Ctrl Up}") ; ctrl,ctrl+space,shift 这三个是一组 106 | case "shift": Send("{Shift Down}{Shift up}") 107 | case "^+" : Send("{Ctrl Down}{Shift Down}{Shift up}{Ctrl Up}") ; 正常是 ctrl + shift,但其实你可以先按shift再按control,这样就没有操作界面了。 没有 GUI 界面反应会快一点。 ; 或者说。使用 alt 加shift切换语言。 shift + ctrl works in onenote, meanwhile ctrl + shift won't work. I guess it's OSD lagging the windows. 108 | case "^space": Send("^{Space}") 109 | 110 | } 111 | ; ToolTip("wait to release") 112 | ; KeyWait("Shift") 113 | ; KeyWait("Alt") 114 | ; KeyWait("Ctrl") 115 | 116 | ToolTip() 117 | } 118 | 119 | 120 | 121 | !+8::cn("set win hotkey") 122 | !+9::en("set win hotkey") 123 | 124 | ; Obsidian 切换搜索时候进入中文(必须要清楚或者等待之前的快捷键松开。 125 | ~^p::TagAlongEN() 126 | ~^!l::TagAlongCN() 127 | 128 | TagAlongCN() 129 | { 130 | 131 | KeyWait "ctrl" 132 | KeyWait "alt" 133 | KeyWait "shift" 134 | cn() 135 | } 136 | TagAlongEN() 137 | { 138 | 139 | KeyWait "ctrl" 140 | KeyWait "alt" 141 | KeyWait "shift" 142 | en() 143 | } 144 | checkCurrentKeyboardLayout() { 145 | ThreadId := DllCall("User32.dll\GetWindowThreadProcessId", "Ptr", WinExist("A"), "Ptr", 0, "UInt") 146 | 147 | hCurrentKBLayout := DllCall("User32.dll\GetKeyboardLayout", "UInt", ThreadId, "Ptr") 148 | msgbox(hCurrentKBLayout) 149 | return 150 | } 151 | 152 | 153 | MenuHandler1(ItemName, ItemPos, MyMenu) { 154 | Send("^#{left}") 155 | Send("^#{left}") 156 | } 157 | MenuHandler2(ItemName, ItemPos, MyMenu) { 158 | Send("^#{left}") 159 | Send("^#{Right}") 160 | } 161 | MenuHandler3(ItemName, ItemPos, MyMenu) { 162 | Send("^#{Right}") 163 | Send("^#{Right}") 164 | } 165 | 166 | 167 | 168 | ; 主要功能 169 | ; 输入αωκλ 希腊字符、上下标、特殊符号。 ; The hotstring and and formula typing Greek letters example is in the readme on the website. (superscripts and undersccripts) 170 | 171 | 172 | 173 | ; keywait 等待然后一起返回 更方便一个快捷键重复使用多次。 第二个参数,字符串以逗号隔开,自行确保很选相对应。 174 | ; 不等待模式: immediateMode 从 1 到 n 175 | updateSharedRepeat( NeedToBeDisplay := "", immediateMode_length := 0){ 176 | global repeatTime 177 | 178 | if( A_PriorHotkey != A_ThisHotKey or A_TimeSincePriorHotKey > 1000) 179 | repeatTime := 0 ;list 从0 到 maxindex() 180 | 181 | if( immediateMode_length > 0){ 182 | len := immediateMode_length 183 | if( A_PriorHotkey == A_ThisHotKey ) 184 | repeatTime += 1 ;immediateMode_length 从 1 到 inf 手动归零。 185 | if (repeatTime >= len) 186 | repeatTime -= len ;归零。 187 | 188 | return repeatTime 189 | } 190 | 191 | ToolTip( repeatTime ,,999,8 ) 192 | 193 | result_key := Trim(A_ThisHotKey, "$") 194 | result_key := Trim(result_key, "~") 195 | result_key := Trim(result_key, "#") 196 | result_key := Trim(result_key, "!") 197 | ; 如果还有别的修饰键就不行了。 198 | Array := StrSplit(result_key , " ", ">$~+^< &", 3) ; a & b 会返回三个值,两个空格之间的符号也算上了,手动跳过。 199 | 200 | first_key := Array[1] 201 | latter_key := Array[Array.Length] 202 | 203 | options := StrSplit(NeedToBeDisplay , ",") ;",," 不能同时有两个 delimiter 204 | len := options.length 205 | flag := 1 206 | while (flag ){ 207 | display := "" 208 | if (repeatTime >= len) 209 | repeatTime -= len 210 | if (NeedToBeDisplay =="") 211 | display := "repeatTime= " repeatTime "latter_key " latter_key 212 | else{ 213 | 214 | For Index, Value in options{ 215 | ; Send(Value) 216 | if( Index == repeatTime + 1) 217 | display .= repeatTime . " " 218 | else 219 | display .= "  " 220 | display .= Value "`n" 221 | } 222 | } 223 | 224 | ToolTip(display,,999,8 ) 225 | KeyWait(latter_key) ;等待松开然后再按下 226 | flag1 := KeyWait(latter_key , "T.75D") ; 超时返回 0 这里不能用 A_ThisHotkey,这里还在等待,但下一个 key 已经把全局变量替换掉了。 227 | flag2 := GetKeyState(first_key,"p") ; 松开时 = 0 228 | flag := flag1 229 | if( flag == 1){ 230 | repeatTime += 1 231 | } 232 | 233 | sleep(50) 234 | } 235 | SetTimer () => ToolTip(,,,8), -1750 236 | SoundBeep() 237 | return repeatTime 238 | } 239 | 240 | 241 | 242 | 243 | 244 | Other_things_when_toggling_IME(){ 245 | name := WinGetProcessName("A") 246 | ; Sleep(1000) 247 | ; tooltip, %name% 248 | ; ;---------------------------------------------- 249 | ; 希望默认英文的环境 Code.exe ← VSCODE, Obsidian.exe OneCommander.exe 250 | if( name == "Code.exe" or name == "OneCommander.exe") 251 | { 252 | ; Send("^.") ;bug!? ctrl + 句号 在讯飞输入法竟然能从英文切换到中文!! 253 | Send("^{sc034}") ;还是存在?!?! 原来是因为shift 还没有松手…… 254 | } 255 | 256 | ; msedge.exe WeChat.exe 。但是 onenote 和 系统设置区分不开、的 ahk——exe 都是这个 ApplicationFrameHost.exe ,区分不开 257 | else if( name == "msedge.exe" or name == "Obsidian.exe" or name == "ApplicationFrameHost.exe" or name == "WeChat.exe" ) 258 | { 259 | ;not change 260 | } 261 | 262 | ;soundbeep,1000,100 263 | ; send,{ctrl up}{shift up}{alt up} 264 | ; Func_Heads_up_using_scrollLock(num) 265 | ; Func_Mouse_Indicator(num) 266 | ; func_head_up_sound_ime() 不切换 267 | } 268 | 269 | Function_Set_Language_by_tracking(target_state) { 270 | global Current_IME_State 271 | 272 | return_IME_state_from_pixel() 273 | if ( target_state != Current_IME_State or true) ; 加一点“智能”,只有想要切换的语言和当前语言不同的时候,才切换语言。 9 ≠ 1 and 9 ≠ 2 , 274 | { 275 | Current_IME_State := 3 - Current_IME_State ;" jump between 1,2" 276 | Func_flip_IME_state() 277 | } 278 | } 279 | 280 | 281 | 282 | 283 | 284 | 285 | ; 根据周围字符判断语言环境,有点影响使用,需要复制文本,最终放弃 286 | ; 测试: IsAlpha("按", "Locale") IsAlpha("ddddddd", "Locale") IsAlpha(" ", "Locale") IsAlpha("111", "Locale") 287 | ; 四个结果是 1 1 0 0, 也就是说不分中文英文,是文字返回1,数组、空格返回0. 288 | ; ~LButton:: 289 | ; { 290 | ; global MpositionX, MpositionY 291 | ; global LastX, LastY 292 | ; global flag_idle_space 293 | ; LastX := MpositionX 294 | ; LastY := MpositionY 295 | ; global moveFar 296 | ; global threshold_idle 297 | ; MouseGetPos(&MpositionX, &MpositionY, &id, &control) 298 | ; ; ToolTip( MpositionX MpositionY ) 299 | 300 | ; ; guess := GetAcharactor_and_return_language_clipboard() 301 | ; ; ToolTip(guess) 302 | ; if ( Abs(MpositionY - LastY) > 500 or Abs(MpositionX - LastX) > 500 ){ 303 | ; moveFar := 1 304 | ; ; threshold_idle := 别耦合了,想不出来,直接做一个 keywait 等待就完事了。 305 | ; } 306 | ; else 307 | ; moveFar := 0 308 | 309 | 310 | ; if (A_Cursor = "IBeam" and moveFar == 1) ;Unknown ; cursor is on link 311 | ; { 312 | 313 | ; en() 314 | ; ; change_this_program_perfer() ;根据程序名称判断。 315 | ; } 316 | ; ; SetTimer(RemoveToolTip,-1000) ; ; guess := GetAcharactor_and_return_language_clipboard() ; 直接根据 ascii 码判断。有点影响使用。放弃 317 | ; ; ToolTip(guess) 318 | 319 | ; } 320 | 321 | if_temp_toggle_IME_is_ture_then_change_it_back() 322 | { 323 | global temporal_change_IME 324 | if( temporal_change_IME == 1) 325 | { 326 | en() 327 | temporal_change_IME := 0 328 | } 329 | } 330 | 331 | 332 | 333 | global XwhereMwas := 0 334 | global YwhereMwas := 0 335 | global M_altered_wait_click:=0 336 | global Ts:= A_TickCount 337 | global height_PDF := 1300 338 | global threshold_idle:= 6000 339 | global Current_IME_State :=1 340 | global TimeIdleKeyboardArray:= [] 341 | global flag_mouse_wheel_change:=0 342 | global W := A_ScreenWidth - 1 ; 1920 如果屏幕是竖过来的,这个值 AHK 会帮你改变。(但是第一段只执行一次,可能需要重载。) 343 | global H := A_ScreenHeight - 1 ; 1080 344 | global index_Time := 0 345 | global maxValue_Time := 10 346 | global repeatTime := 0 347 | 348 | global using_shift_to_help_typing_in_Chinese:=1 349 | global n_mouse_move_momentum:=0 350 | global StartTime:= 0 351 | global idle_time_number:=0 352 | 353 | global Stop_Sitting_counter:=0 354 | global Stop_Sitting_Lastime_triggered:= A_TickCount 355 | 356 | global Press_Start_time 357 | global now_language :=0 358 | global repeat_key:=0 359 | global exclude_apps_string := [] 360 | global MpositionX :=0 361 | global MpositionY :=0 362 | WatchCursor() 363 | { 364 | global Current_IME_State 365 | global flag_mouse_wheel_change 366 | global TimeIdleKeyboardArray 367 | global index_Time 368 | global maxValue_Time 369 | global threshold_idle 370 | global flag_idle_space 371 | global moveFar 372 | global M_altered_wait_click 373 | global XwhereMwas 374 | global YwhereMwas 375 | MouseGetPos(&xpos, &ypos, &id, &control) 376 | W := A_ScreenWidth 377 | ; ToolTip(A_TimeIdlePhysical) 378 | 379 | global XwhereMwas := xpos 380 | global YwhereMwas := ypos 381 | 382 | ;------------------------ Pomodoro -------------- 383 | ; AutoMaticPomodoro() 384 | 385 | ; ;------------------------移动距离足够大以后,改变键盘的逻辑--------------- 386 | ; if( Abs( XwhereMwas - xpos) + Abs(YwhereMwas - ypos) > 100 and (A_TimeIdleKeyboard >200)) 387 | ; { 388 | 389 | ; M_altered_wait_click := 1 390 | ; CoordMode("ToolTip" , "Screen") 391 | ; ToolTip(" " ,0 , 9200,9 ) 392 | ; ; SetTimer ()=> ToolTip(,0,9999,9 ) ,-1000 393 | ; ; if_temp_toggle_IME_is_ture_then_change_it_back() 394 | ; } 395 | 396 | 397 | 398 | ; ;------------------------移动距离足够大以后,改变键盘的逻辑--------------- 399 | 400 | 401 | ; if( Abs( XwhereMwas - xpos) > 700 and !GetKeyState("LButton")) ;相对移动甚至不需要区分副屏幕。 402 | ; { 403 | 404 | ; } 405 | 406 | 407 | 408 | 409 | 410 | ; ----------------------- 闲置足够长时间就清除 modifer--------------------- 411 | ; t := Mod(A_TimeIdleKeyboard, threshold_idle) ; 鼠标切换的话 keyboard idle 时间不更新. ; 取余是最简单的,不用记录之前是哪个程序,和现在比较. 取余一定要用 后面的 100 ms,而不是开始的 100 ms,不然总是重置 IME. 412 | 413 | ; if( t > 300 ){ 414 | ; ; change_this_program_perfer() 415 | ; global modifier 416 | ; modifier := "" 417 | ; ; showIMEstateRIME() 418 | ; } 419 | 420 | 421 | ; if( A_TimeIdleKeyboard > 1600 ) 422 | ; { 423 | ; M_altered_wait_click := 0 424 | ; ToolTip( ,0 , ypos+ 200,9 ) 425 | 426 | ; } 427 | 428 | 429 | ; if( t > threshold_idle - 100 ){ 时间过长修改输入就太影响输入思路了,鼠标、换程序时修改最好。 430 | ; en() 431 | ; } 432 | ; if( A_TimeIdleKeyboard > threshold_idle - 100 ){ 433 | ; flag_idle_space := 1 434 | ; } 435 | ; else { 436 | ; flag_idle_space := 0 437 | ; } 438 | ; ----------------------- 闲置足够长时间就清除 modifer------------------- 439 | 440 | 441 | 442 | ; ToolTip(A_ScreenHeight ypos xpo ) 443 | if( GetKeyState("Ctrl","P")) 444 | if( (xpos = 0 )) ;and ypos = A_ScreenHeight -1 往左拖动(同时按住 ctrl)触发删除,这样鼠标可以直接拖动文字复制、移动、删除。 445 | { 446 | Send("{LButton Up}") 447 | Send("{BackSpace}") 448 | Sleep(2000) 449 | } 450 | 451 | 452 | ; 大部分程序都不会汇报 caret 的位置,所以不可能知道键盘输入点在哪。 追踪鼠标更加合理。 453 | ; ToolTip, X%A_CaretX% Y%A_CaretY%, A_CaretX, A_CaretY - 20 454 | ; 但是数组从 0 开始。对于 1920*1080 的电脑来说, 左上角 0,0 ;右上角 1919,0 ;左下角 0,1079; 右下角1919 1079。 455 | 456 | ;若要重设边缘热区的范围请,把下一行的 ; 号去掉,就会在鼠标位置显示鼠标的坐标,根据坐标修改以下数值 457 | ; ToolTip,x:%xpos% y:%ypos% :%% `t Hei = %Hei% Wei =%Wei% 458 | 459 | ; ----------------------- 460 | ; tooltip, %A_ScreenWidth% 461 | 462 | ; 根据鼠标在 screen 的位置修改鼠标滚轮的功能。 ; 副屏幕坐标是负的,整个屏幕的基准不是 0;副屏幕左上角是 -1440,661 463 | ; if(GetKeyState("LButton")){ ;没有按下鼠标才触发。 464 | if(GetKeyState("``")){ ;没有__`__才触发。 但是这个规则没有用?和上条不一样? 465 | ; if(GetKeyState("SC029")){ ;没有__`__才触发。 但是这个规则没有用?和上条不一样? 466 | return 467 | } 468 | 469 | 470 | 471 | ; 滚轮控制音量 else if ↓↓↓ ypos < H * 0.25 or 472 | if( xpos = 0 and ( ypos > H * 0.75 ) or ( xpos = -1440 and ypos < 900)){ ;屏幕左上角, 左下角,副屏幕。 473 | flag_mouse_wheel_change :=3 474 | ToolTip("滚轮控制音量" xpos , A_ScreenWidth,,15) 475 | ToolTip() 476 | } 477 | 478 | ; 左上角 ;切换上一个任务 alt+Tab 479 | ; else if(xpos = 0 and ypos = 0){ 480 | ; Sleep( 1000) 481 | ; ;if still here 482 | ; MouseGetPos(&xpos, &ypos, &id, &control) 483 | ; if(xpos < 50 and ypos < 50){ 484 | ; Send("!{Tab}") 485 | ; Sleep( 1000) 486 | ; } 487 | ; } 488 | 489 | ; ; 右上角 F11 或者切换任务 已经设置了『全面屏手势』,就不用这个了。 490 | ; else if(xpos + 1 = A_ScreenWidth and ypos = 0){ 491 | 492 | ; Sleep( 1000) 493 | ; ;if still here 494 | ; MouseGetPos(&xpos, &ypos, &id, &control) 495 | ; if( Abs( A_ScreenWidth - xpos) < 50 and ypos < 50){ 496 | ; Send("#{Tab}") ;切换任务 任务管理器 497 | ; ; Send("{F11}") 498 | ; Sleep( 1000) 499 | ; } 500 | ; } 501 | 502 | ; ;屏幕右边直接控制翻页 条件较小的一定要放右边!! 503 | else if( xpos = A_ScreenWidth - 1 ){ 504 | flag_mouse_wheel_change := 4 505 | ToolTip("PG", A_ScreenWidth,,15) 506 | } 507 | 508 | else { ;重置状态 ,必须要 509 | if( flag_mouse_wheel_change != 0){ 510 | flag_mouse_wheel_change :=0 511 | ToolTip(,,,15) 512 | } 513 | } 514 | ; ----------------------------------放弃--------------------------------- 515 | ; 浏览器标签,上方,快速切换。 稍微往下,第二行,第三行,屏幕左侧 75% 调音量,右侧控制翻页,功能都有。 516 | ; if ( (xpos > 250 and xpos < W-250 )) { 517 | ; ; 屏幕中央,去除两侧,避免 bug 518 | ; if ( ypos < 50 ){ 519 | ; flag_mouse_wheel_change :=1 520 | ; ToolTip("屏幕左上方 1 滚轮控制翻页 `n 右键打开 ↑任务菜单全部任务↑ " ,A_ScreenHeight,,15) 521 | ; } 522 | ; else if( ypos > 50 and ypos < 100){ 523 | ; flag_mouse_wheel_change :=2 524 | ; ToolTip("屏幕左上方 2 滚轮控制22 左右", A_ScreenWidth,,15) 525 | ; } 526 | 527 | ; else if( ypos > 100 and ypos < 150){ 528 | ; flag_mouse_wheel_change := 4 529 | ; ToolTip("屏幕左上方 3 滚轮控制上下", A_ScreenWidth,,15) 530 | ; } 531 | 532 | ; else if( flag_mouse_wheel_change != 0){ 533 | ; flag_mouse_wheel_change :=0 534 | ; ToolTip(,,,15) 535 | ; } 536 | ; } 537 | ; 538 | ; else if(xpos <-50 and ypos = 603) { 539 | ; flag_mouse_wheel_change :=1 540 | ; ToolTip("屏幕左上方 1 滚轮控制翻页 `n 右键打开 ↑任务菜单全部任务↑ ", A_ScreenWidth,,15) 541 | ; } 542 | ; mousinc 这个鼠标手势软件有很多功能,https://zhuanlan.zhihu.com/p/400590907 绿色, 543 | ; 手写识别,carnac 按键回显,边缘滚动,有意思的音响效果,甚至 altsnap 移动窗口(只不过是 alt + 鼠标滚轮,而我这个鼠标没有滚轮。)、 ditto 的画中画都有! 544 | ; ----------------------------------放弃--------------------------------- 545 | 546 | 547 | ;--------------------------------------------------------- 548 | 549 | ; else if(xpos = 0 and ypos = H){ 550 | ; tooltip, 屏幕左下角 如果还在这里 still here `n 那么触发。。。左下角 0 1079 W L 551 | ; Sleep, 1000 552 | 553 | ; MouseGetPos, xpos, ypos, id, control 554 | ; if(xpos < 50 and ypos > H -50){ 555 | ; ;WinMinimizeAll 556 | ; Sleep, 1500 557 | ; ;WinMinimizeAllUndo 558 | ; } 559 | 560 | 561 | 562 | 563 | ; 564 | ; if( flag_mouse_wheel_change != 0) 565 | ; flag_mouse_wheel_change :=0 566 | ; 567 | ; } 568 | 569 | 570 | } 571 | 572 | AutoMaticPomodoro() 573 | { 574 | 575 | if( A_TimeIdlePhysical < 60000 ) ;1 minutes = 60*1000 ms 函数里面自动过滤掉太远的输入,只需要进入的时候过滤一下。 576 | { 577 | My_automatic_Pomodoro_Stop_Sitting_function_couting_up() 578 | } 579 | 580 | else if( A_TimeIdlePhysical > 300000) 581 | { 582 | Pomodoro_Kill() ; 太长的空闲,重置计数器。 583 | global Stop_Sitting_block_once 584 | Stop_Sitting_block_once := 1 585 | ToolTip("Clear",0,0) 586 | } 587 | } 588 | ; ~Tab:: 589 | ; ~LButton::showIMEstateRIME() 陈饭FDSFshUIFFDSFhsDhui 590 | 591 | ; LCtrl:: 592 | ; ; ~Shift:: 593 | ; LAlt:: 594 | ; { 595 | ; if_temp_toggle_IME_is_ture_then_change_it_back() 596 | ; global temporal_change_IME 597 | ; temporal_change_IME :=0 598 | ; ; showIMEstateRIME(1000) 599 | ; Send("{A_ThisHotkey}") 600 | ; } 601 | 602 | 603 | ; RIME 和手心输入法切换的时候屏幕上有提示,非常方便。我只需要触发它就行了。 604 | showIMEstateRIME(time := 100) 605 | { 606 | Sleep(time) 607 | Send("{LShift 2}") 608 | } 609 | 610 | 611 | 612 | 613 | ;0 is normal ; 位置修改功能 614 | WheelUp:: 615 | { 616 | global flag_mouse_wheel_change 617 | switch flag_mouse_wheel_change 618 | { 619 | case 1: Send("+{tab}") 620 | case 2: Send("{Left}") 621 | case 3: Send("{Volume_Up}") 622 | case 4: Send("{PgUp}") 623 | default: Send("{WheelUp}") 624 | 625 | } 626 | } 627 | WheelDown:: 628 | { 629 | global flag_mouse_wheel_change 630 | switch flag_mouse_wheel_change 631 | { 632 | case 1: Send("^{tab}") 633 | case 2: Send("{Right}") 634 | case 3: Send("{Volume_Down 3}") 635 | case 4: Send("{PgDn}") 636 | default: Send("{WheelDown}") 637 | 638 | } 639 | } 640 | 641 | #HotIf flag_mouse_wheel_change=4 642 | ; 全面屏手势,鼠标在屏幕右侧时,唤出任务菜单。(按住显示,松手选择) 643 | RButton:: 644 | { 645 | Send("#{Tab}") 646 | KeyWait("RButton") 647 | Click() 648 | 649 | } 650 | 651 | #HotIf 652 | 653 | delete_a_word(){ 654 | Send("^{backspace}") 655 | } 656 | 657 | adds_two_space_before_and_after(){ 658 | Send("^{left}") 659 | Send("{space}") 660 | Send("^{right}") 661 | Send("{space}") 662 | } 663 | func_delete_traling_newline_and_enter(){ 664 | Send("{end}{delete}{space}{down}{end}") 665 | } 666 | ;注意空格就可以连接字符串! 667 | showtip( string,t:=500){ 668 | ToolTip(string) 669 | SetTimer () => ToolTip( ), -300000 670 | ; SetTimer(RemoveToolTip,-%t%) 671 | } 672 | 673 | delete_one_line(){ 674 | Send("{Home}{Shift down}{End}{Shift up}") 675 | Sleep(10) 676 | Send("{BackSpace}") ;删除一行,而不是删除所有文字,功能挺顺手的。 677 | return 678 | } 679 | delete_from_here_to_end_of_the_line(){ 680 | Send("{Shift down}{End}{Shift up}") 681 | Sleep(10) 682 | Send("{BackSpace}") ;删除一行,而不是删除所有文字,功能挺顺手的。 683 | return 684 | } 685 | 686 | ; Delete & a::delete_a_word() 687 | ; Delete::Send("{Delete}") 688 | 689 | ;wordpress 文字修改,这个是添加软回车,wordpress 需要一整块的文字, 690 | func_wordpress_change_to_soft_enter(){ 691 | Send("{End}") 692 | Sleep(50) 693 | Send("{delete}") 694 | Sleep(50) 695 | Send("{Shift down}{Enter}{Shift up}{End}") 696 | return 697 | } 698 | func_superscript_text(){ 699 | Send("{Shift down}{Left}{Shift up}") 700 | Send("{Ctrl down}{Shift down}{=}{Shift up}{Ctrl up}") 701 | Send("{Left}") 702 | return 703 | } 704 | func_underscript_text(){ 705 | Send("{Shift down}{Left}{Shift up}") 706 | Send("{Ctrl down}{=}{Ctrl up}") 707 | Send("{Left}") 708 | return 709 | } 710 | 711 | 712 | ; ~ki 713 | ~k:: 714 | { 715 | ; check_io_pressed_in_the_same_time() 716 | ; if( GetKeyState("j") and GetKeyState("i") and GetKeyState("o")dededeededeeedede 717 | if( GetKeyState("i")){ 718 | Send("{bs 2}") 719 | Sleep(200) 720 | cn() 721 | 722 | 723 | } 724 | 725 | } 726 | ; ~ed 727 | ~d:: 728 | { 729 | ; check_ew_pressed_in_the_same_time() 730 | if( GetKeyState("e") and GetKeyState("d") ){ 731 | Send("{bs 2}") 732 | Sleep(200) 733 | en() 734 | } 735 | } 736 | 737 | 738 | 739 | 740 | ;这个功能需要一个 exe,很小,是封装的微软“讲述人”功能: https://elifulkerson.com/projects/commandline-text-to-speech.php 741 | 742 | voice_text_to_speach( lan := "en"){ 743 | ; BackUpClip := ClipboardAll 744 | Send("^{c}") 745 | ; Send("{Media_Play_Pause}") 746 | Sleep(50) ; 必须有,确保 clipboard 数据更新。 747 | ; say PowerShell "C:\Users\Administrator\OneDrive\代码\voice.exe /n 'Microsoft David Desktop' 'output'" , ,Hide 748 | ; ↑↑ 749 | ; 若要在单引号字符串中包含单引号,请使用第二个连续单引号。 750 | ; 若要使双引号显示在字符串中,请将整个字符串括在单引号中。 详情见 https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2 751 | 752 | textRaw := A_Clipboard 753 | ; 里面的单引号会出 bug, 指令里面有单引号,还是 shell 不许参数有引号? 那我直接做一个替换也许就可以了。 754 | textraw := StrReplace(textraw, "'", "''") 755 | textraw := StrReplace(textraw, "’", "''") 756 | textraw := StrReplace(textraw, "‘", "''") 757 | 758 | ; ToolTip(A_NowUTC "`n" textraw) 759 | switch lan 760 | { 761 | ; 用 voice.exe --list 查看可用的语音源。 762 | ; PS C:\Users\Administrator\OneDrive\代码\AHK> ./voice.exe --list 763 | ; "Microsoft Huihui Desktop" - Adult,Female,zh-CN ;中英都可以念,但是英文有点卡。 764 | ; "Microsoft Zira Desktop" - Adult,Female,en-US ; 英文流畅但是完全念不了中文 765 | ; "Microsoft David Desktop" - Adult,Male,en-US 766 | case "en": command := A_ScriptDir . "\voice.exe /n 'Microsoft Zira Desktop' '" . textRaw . "'" 767 | case "cn": command := A_ScriptDir . "\voice.exe /n 'Microsoft Huihui Desktop' '" . textRaw . "'" 768 | } 769 | try 770 | ExitCode :=RunWait("PowerShell `" " command "`"", , "Min") 771 | catch 772 | MsgBox(ExitCode) 773 | 774 | ; MsgBox(ExitCode) 775 | ; Send("{Media_Play_Pause}") 776 | 777 | ; Clipboard := BackUpClip 778 | ;test 779 | ; such as Tchaikovsky's Symphony No. 6, are not placed in quotes, but if the work also has a title, the title is placed in quotes. (Tchaikovsky's Symphony No. 6, "Pathetique.") 780 | } 781 | CheckScriptUpdate() { ;自动更新功能,来自于例子:https://www.it1352.com/1954002.html 782 | global ScriptStartModTime 783 | curModTime := FileGetTime(A_ScriptFullPath) 784 | If (curModTime != ScriptStartModTime) { 785 | SetTimer(CheckScriptUpdate,0) 786 | Loop 787 | { 788 | reload 789 | Sleep(300) ; ms 790 | msgResult := MsgBox("Reload failed.", A_ScriptName, 2) ; 0x2 = Abort/Retry/Ignore 791 | if (msgResult = "Abort") 792 | ExitApp() 793 | if (msgResult = "Ignore") 794 | break 795 | } ; loops reload on "Retry" 796 | } 797 | } 798 | 799 | 800 | maximizeORrestore(){ 801 | global Title 802 | 803 | if( A_PriorHotkey != A_ThisHotKey) 804 | { 805 | Title := WinGetTitle("A") 806 | ToolTip("new window`n" Title) 807 | } 808 | else 809 | ToolTip("old window`n" Title) 810 | 811 | ; get MinMax state for the given title and save it to variable MX 812 | MX := WinGetMinMax(Title) 813 | ; -1: The window is minimized (WinRestore can unminimize it). 814 | ; 1: The window is maximized (WinRestore can unmaximize it). 815 | ; 0: The window is neither minimized nor maximized. 816 | ; if it is maximized, minimize it 817 | if (MX!=1) 818 | WinMaximize(Title) 819 | ; if it is minimized, maximize it 820 | else 821 | ; WinMaximize, %Title% 822 | WinRestore(Title) 823 | ; else 824 | ; WinMinimize, A 825 | ; Tooltip 826 | return 827 | } 828 | 829 | 830 | 831 | minimizeORrestore(){ 832 | if WinExist("ahk_id " lastWindow) 833 | { 834 | WinState := WinGetMinMax("ahk_id " lastWindow) 835 | if (WinState = -1) 836 | WinActivate() 837 | else 838 | WinMinimize() 839 | } 840 | else 841 | { 842 | lastWindow:= WinExist("A") 843 | WinMinimize("ahk_id " lastWindow) 844 | } 845 | return 846 | } 847 | take_notes( program){ 848 | ; freeze_clipboard() 849 | 850 | the_clipboard:= A_Clipboard 851 | Send("^{c}") 852 | Sleep(100) 853 | switch_to_a_program( program ) 854 | Sleep(200) 855 | Send("{Enter}") 856 | Send("^{v}") 857 | Sleep(100) 858 | Send("!{Tab}") 859 | 860 | A_Clipboard := the_clipboard 861 | 862 | } 863 | ;这是一个单独的模式,不能输入,某些功能需要管理员权限,来重新实现键盘逻辑。 864 | Func_Heads_up_using_scrollLock(num){ 865 | if(num = 1){ 866 | SetScrollLockState("Off") 867 | } 868 | 869 | else { 870 | SetScrollLockState("On") 871 | } 872 | return 873 | } 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | ; 不允许模拟 ctrl + alt + del,Send,^!{Del}。 但是你可以发送 win+x,t 来唤出任务管理器 882 | ; onenote 2016 shortkeys , 新旧 OneNote 都有 bug,放弃了. 883 | Lshift & WheelDown::Send("{WheelRight}") 884 | Lshift & WheelUp::Send("{WheelLeft}") 885 | 886 | 887 | 888 | ; pomodoro 889 | F3 & p:: 890 | { 891 | repeatTime:= updateSharedRepeat(" pomodoro 开始,关闭时钟 并清空自动时钟") 892 | switch repeatTime 893 | { 894 | case 0: PomodoroStart() 895 | case 1: Pomodoro_Kill() 896 | 897 | } 898 | return 899 | 900 | 901 | 902 | } 903 | MenuHandler4(ItemName, ItemPos, MyMenu) { 904 | PomodoroStart() 905 | } 906 | 907 | MenuHandler5(ItemName, ItemPos, MyMenu) { 908 | Pomodoro_Kill() 909 | global blockPomodoro:= 1 910 | } 911 | 912 | PomodoroStart() 913 | { 914 | global StartTime 915 | StartTime := A_TickCount 916 | SetTimer(pomodoro_tips,1000) ; 每秒更新 917 | ; t := "1000*60*25" = 1500000 918 | SetTimer(endPomodoro,-1500200) ;负数是倒计时关闭。 正数是周期提示。 25分钟是 1,500,000 ms 919 | } 920 | 921 | Pomodoro_Kill() 922 | { 923 | SetTimer(pomodoro_tips,0) ; 删除 Pomodoro 时钟 924 | global Stop_Sitting_counter ;把另一个自动的重置 925 | Stop_Sitting_counter :=0 926 | } 927 | 928 | pomodoro_tips() 929 | { 930 | global StartTime 931 | ElapsedTime := A_TickCount - StartTime 932 | sec := Floor(ElapsedTime/1000) 933 | minute := Floor(sec / 60) 934 | CoordMode("ToolTip" , "Screen") 935 | ToolTip(minute ":" sec, 9990 , 0, 16) 936 | 937 | } 938 | 939 | endPomodoro() 940 | { 941 | SetTimer(pomodoro_tips,0) 942 | Send("{Media_Play_Pause}") ;pause_play_beep: 943 | SoundBeep(1204, 300) 944 | ;write to file 945 | FileObj := FileOpen("Pomodoro.txt", "a") 946 | strings := "🍅 completed Year Week:" . A_YWeek . "day " . A_DD 947 | FileObj.WriteLine(strings) 948 | Send("^#{c}") ; windows color filter 949 | ; MsgBox("🍅 end. Rest 5 Min") 950 | SetTimer () => MsgBox(" Back to Work"), -300000 951 | SetTimer () => Send("^#{c}") , -300000 952 | 953 | return 954 | } 955 | 956 | ; zxcv 是几个最好用的快捷键了。我放进去了,窗口最小化、关闭、浏览器搜索所选文字,还有。。 957 | ; !x::WinRestore("A") 958 | ; !z::WinMinimize("A") 959 | ; #z::Send("!{Esc}") ; Sends a window to the bottom of stack; that is, beneath all other windows. The effect is similar to pressing Alt+Esc. 960 | 961 | 962 | 963 | 964 | 965 | Send_with_delay( retype_text ){ 966 | ToolTip( StrLen(retype_text) ) 967 | loop(StrLen(retype_text)) 968 | { 969 | char := SubStr(retype_text, A_Index , 1) 970 | Send( char ) 971 | Sleep 10 972 | } 973 | 974 | } 975 | 976 | ; 还不如我自己主动占用掉它:输入法根本不会考虑到这个问题,键位不能改,所以不如自己抢先占用掉最好用的快捷键。 977 | ; vscode 如何改 hotkey ctrl k/s 如果实在输入法和软件冲突,倒不如改软件的快捷键, 978 | ; 非常常见的问题,这多个组合键之间本来就不应该触发别的功能。 例如你要使用格式刷,它的快捷键是 ctrl + shift + C/V。 但是ctrl加shift会触发更换语言的快捷键。 979 | 980 | Clip(Text) 981 | { 982 | SoundBeep() 983 | Send(Text) 984 | } 985 | ClipL(Text) 986 | { 987 | Send(Text) 988 | Send("{Left}") 989 | } 990 | ;^LAlt 欠考虑了,不能用这个。 例如 ctrl + alt + h ,会提前触发本组合。 991 | ;^RAlt:: 欠考虑了,不能用这个。 992 | ; ^Shift::return 欠考虑了,不能用这个。 993 | 994 | F8 & N::take_notes("OneNote") 995 | F8 & O::take_notes("Obsidian") 996 | 997 | 998 | F9 & u::Send("^{u}") 999 | F9 & r::Send("^{r}") 1000 | F9 & q::Send("^{q}") 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | ; 切换到一组程序的首个,(如果能找到)。 这个程序有记忆,重复按键可以跳过第一个程序。 1007 | 1008 | switch_to_a_program(titile_names, custom_behavior := False){ 1009 | SetTitleMatchMode(2) 1010 | global n_time 1011 | global exclude_apps_string 1012 | global repeat_key 1013 | this_search_start_number :=1 1014 | 1015 | ; WinActivate, % array[1] ,,2 1016 | 1017 | ;if this hotkey is same as last hotkey, which means double taps, then jump to last "jump number". 1018 | ; else reset the "jump number" 1019 | 1020 | if( A_PriorHotkey != A_ThisHotKey) 1021 | { 1022 | ; showtip( A_PriorHotkey "新的按键" A_ThisHotKey) 1023 | repeat_key:= 0 1024 | this_search_start_number := 1 1025 | exclude_apps_string := [] 1026 | } 1027 | else{ 1028 | repeat_key := repeat_key+1 1029 | ; showtip("多次点击" A_PriorHotkey A_ThisHotKey repeat_key) 1030 | this_search_start_number := n_time 1031 | } 1032 | 1033 | if (custom_behavior){ 1034 | if ( titile_names[1] = "Edge"){ 1035 | if (repeat_key = 0){ 1036 | WinActivate("Edge") ;←← 不用加引号! 1037 | } 1038 | else{ 1039 | Send("^{Tab}") 1040 | } 1041 | } 1042 | else if ( titile_names[1] = "OneNote"){ 1043 | if (repeat_key = 0){ 1044 | WinActivate("OneNote") ;←← 不用加引号! 1045 | } 1046 | 1047 | else{ 1048 | ;我的 OneNote 导航页,连接到其他所有页面. 1049 | { 1050 | ; Run("`"onenote:https://d.docs.live.net/ff64712bc759b896/文档/雨爽/快速笔记.one#ToDo_FrontPage§ion-id={C25FCCD8-1E30-460B-94D4-356C742E9CD6}&page-id={C2166799-8231-A942-9101-C8A5CDBE9172}&end`"", , "", ) 1051 | } 1052 | } 1053 | } 1054 | 1055 | 1056 | else{ 1057 | showtip("wrong" ) 1058 | } 1059 | return 1060 | } 1061 | 1062 | is_found :=0 1063 | for index, element in titile_names ; Enumeration is the recommended approach in most cases. 1064 | { 1065 | if ( index < this_search_start_number) 1066 | { 1067 | Continue 1068 | } 1069 | if WinExist(element) 1070 | { 1071 | WinActivate() 1072 | Title := WinGetTitle("A") 1073 | ; tooltip, "foundit" "`n1" WinExist("A") "`n2" Title "`n3" exclude_apps_string 1074 | ; showtip( "foundit" "`n3" ExcludeTitle_string) 1075 | 1076 | n_time := index 1077 | is_found :=1 1078 | Break 1079 | } 1080 | else 1081 | { 1082 | 1083 | } 1084 | ; 1085 | ; MsgBox % "Element number " . index . " is " . element 1086 | } 1087 | if (is_found = 0 ) 1088 | { 1089 | n_time := 1 1090 | ; showtip( "not found any programs in" titile_names A_ThisHotKey) 1091 | SoundBeep(1200, 100) 1092 | ; Send,#{m} 1093 | } 1094 | 1095 | } 1096 | 1097 | 1098 | 1099 | global temporal_change_IME :=0 1100 | 1101 | 1102 | 1103 | Capslock::Func_flip_IME_state() 1104 | Shift::Send("{Shift}") ; 通过多余的一次, 屏蔽 shift. dfdf 1105 | ; Capslock::Send("^{Space}") 1106 | ; ~Capslock:: 1107 | ; { 1108 | ; SetCapsLockState("AlwaysOff") 1109 | 1110 | 1111 | ; count:=0 1112 | ; while(getkeystate("Capslock","p")) 1113 | ; { 1114 | ; count++ 1115 | ; ; ToolTip(count) 1116 | ; sleep 50 1117 | ; } 1118 | ; if(count<5) 1119 | ; en() 1120 | ; else 1121 | ; cn() 1122 | 1123 | ; BlockInput("Off") 1124 | ; ; SoundBeep() 1125 | ; } 1126 | 1127 | 1128 | ; Shift::smartVimCN() 1129 | ; Shift::smartVimCN() 1130 | ; /sc033 逗号 sc034 句号 1131 | ; $^sc033::cn() 1132 | ; $^,::en() bug 没用 1133 | ; RAlt::cn() 1134 | Esc:: 1135 | { 1136 | Send("{Esc}") 1137 | ; en() 1138 | ToolTip() 1139 | } 1140 | ; Pause::Send("{Delete}") ;下面的语法才是完全重映射。 1141 | Pause::Delete 1142 | 1143 | ; #HotIf WinActive("ahk_exe msedge.exe") 1144 | ; #HotIf 1145 | 1146 | IMEtoggle(){ 1147 | en("ctrl+space") 1148 | } 1149 | 1150 | ; $Space:: 1151 | ; { 1152 | ; Send("{Space}") 1153 | ; ret := KeyWait("Space","Up T1") 1154 | ; if( ret := 0) 1155 | ; Send("{BackSpace}") 1156 | ; ; KeyWait("Space","Up") 1157 | ; } 1158 | 1159 | ; 按住 shift 太长时间,不小心切换输入法 。 但是 shift+↑←↓→ 也会统计进去。 1160 | ; ~$Shift:: 1161 | ; { 1162 | ; count:=0 1163 | ; while(getkeystate("Shift","p")) 1164 | ; { 1165 | ; count++ 1166 | ; sleep 50 1167 | ; } 1168 | ; if(count>5) 1169 | ; { 1170 | ; ToolTip(A_TimeSincePriorHotKey) 1171 | ; Send("{Shift}") ; 把它切回来,但不能阻止他 1172 | ; } 1173 | ; } 1174 | 1175 | 1176 | ; // 第二种写法也不能提前进入计时器。 1177 | ; *LShift:: 1178 | ; { 1179 | ; global shift_press_time 1180 | ; while(getkeystate("Shift","p")) 1181 | ; { 1182 | ; shift_press_time++ 1183 | ; sleep 50 1184 | ; ToolTip(shift_press_time) 1185 | ; } 1186 | 1187 | ; } 1188 | ; global shift_press_time :=0 1189 | ; *LShift UP:: 1190 | ; { 1191 | ; global shift_press_time 1192 | ; if(shift_press_time<5) 1193 | ; { 1194 | ; ToolTip(shift_press_time) 1195 | ; Send("{Shift}") ; 把它切回来,但不能阻止他 1196 | ; } 1197 | 1198 | ; } 1199 | 1200 | 1201 | 1202 | 1203 | ; global shiftTick :=0 1204 | ; $LShift Up:: 1205 | ; { 1206 | ; global shiftTick 1207 | 1208 | ; ToolTip(A_TickCount - shiftTick ) 1209 | ; ; if(shiftTick - A_TickCount < 200) 1210 | ; ; ToolTip("ffff") 1211 | ; } 1212 | 1213 | 1214 | ; LCtrl::cn() 这个不能要 1215 | 1216 | smartVimCN(){ 1217 | if WinActive("ahk_exe Obsidian.exe"){ ; 这个笔记本里才生效,其他软件不生效。 encn 切换及时 vim 状态错了也会被冲刷掉。 1218 | en() 1219 | Send("{i}") 1220 | cn() 1221 | } 1222 | else { 1223 | cn() 1224 | } 1225 | } 1226 | 1227 | 1228 | ; 清除鼠标滚轮打上的标记。 1229 | clear_mouse_flag_altered() 1230 | { 1231 | global M_altered_wait_click 1232 | M_altered_wait_click := 0 1233 | ToolTip(,0,0,9 ) 1234 | } 1235 | ; ^space::Func_flip_IME_state() 1236 | ~BackSpace::clear_mouse_flag_altered() 1237 | 1238 | 1239 | ; 模仿不 burst 的行为,但是还是不顺手。 1240 | ; Space:: 1241 | ; { 1242 | ; ret := KeyWait("Space","T.85") 1243 | ; if( ret == 1) ; 提前到达,松开 1244 | ; Send("{Space}") 1245 | ; else 1246 | ; { 1247 | ; xxxx(9) 1248 | ; KeyWait("Space") ; 不加的话,会进入 “if”,多一个空格。 1249 | ; } 1250 | ; } 1251 | 1252 | 1253 | 1254 | RemoveToolTip() 1255 | { 1256 | ToolTip() 1257 | return 1258 | } 1259 | array2string(titile_names) 1260 | { 1261 | length := titile_names.MaxIndex() 1262 | ret :="" 1263 | for entry in titile_names 1264 | { 1265 | ret := ret titile_names[A_Index] 1266 | } 1267 | return ret 1268 | } 1269 | temp_search(){ 1270 | Send("^{c}") 1271 | Sleep(100) 1272 | Send("!{Tab}") 1273 | Sleep(100) 1274 | Send("^{f}^{v}") 1275 | Sleep(1000) 1276 | ; Send("!{Tab}") 1277 | ; Sleep(100) 1278 | } 1279 | 1280 | temp_source() 1281 | { 1282 | Send("^{u}") 1283 | Sleep(100) 1284 | Send("^{f}") 1285 | Sleep(100) 1286 | ; Send("单选题, 1.5分)") 1287 | ; Send("(多选题, 2.0分)") 1288 | Send("(判断题, 1.0分)") 1289 | Sleep(100) 1290 | Send("{enter}") 1291 | 1292 | } 1293 | 1294 | GetAcharactor_and_return_language_clipboard() ; 有点影响使用。放弃 1295 | { 1296 | global Current_IME_State 1297 | Send("+{Left}") 1298 | 1299 | ClipSaved := ClipboardAll() ; Save the entire clipboard to a variable of your choice. 1300 | A_Clipboard := "" ; Start off empty to allow ClipWait to detect when the text has arrived. 1301 | Send("^c") 1302 | Errorlevel := !ClipWait() ; Wait for the clipboard to contain text. 1303 | 1304 | 1305 | c := A_Clipboard 1306 | ; ... here make temporary use of the clipboard, such as for pasting Unicode text via Transform Unicode ... 1307 | A_Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll). 1308 | ClipSaved := "" ; Free the memory in case the clipboard was very large. 1309 | 1310 | 1311 | 1312 | ascii := Ord(c) 1313 | FoundPos := RegExMatch(c, "[a-zA-Z]") 1314 | ToolTip(c " " ascii) 1315 | 1316 | 1317 | ;sleep, 150 1318 | Send("{Right}") 1319 | 1320 | if (FoundPos =1 ) ; found! if it is Eng 1321 | { 1322 | ;Tooltip, Found! Eng! %FoundPos%`n%c% 1323 | return_val:= 1 1324 | } 1325 | else if ( ascii > 256) ; is Chn, not found 1326 | { 1327 | ;Tooltip, Chn found %FoundPos%`n%c%`n%ascii% 1328 | return_val:= 2 1329 | } 1330 | else 1331 | return_val:= Current_IME_State 1332 | ; if(c = "`n" or c = " "){ 1333 | ; return Current_IME_State 1334 | ; } 1335 | 1336 | return return_val 1337 | 1338 | } 1339 | ; 返回的是 1 0 ,是否被按下。 如果用 BlockInput 功能,那么必须加 “P” 表示物理按键,而不是逻辑按键。 1340 | key(a){ 1341 | return GetKeyState(a,"P") 1342 | } 1343 | 1344 | 1345 | change_this_program_perfer(){ 1346 | name := WinGetProcessName("A") 1347 | ; tooltip, %name% 1348 | ; 希望默认英文的环境 Code.exe ← VSCODE, Obsidian.exe OneCommander.exe 1349 | if( name == "Code.exe" or name == "Obsidian.exe" or name == "OneCommander.exe") 1350 | { 1351 | en() 1352 | } 1353 | 1354 | ; msedge.exe WeChat.exe ApplicationFrameHost.exe onenote 和 系统设置的 ahk——exe 都是这个,区分不开 1355 | else if( name == "msedge.exe" or name == "ApplicationFrameHost.exe" or name == "WeChat.exe" ) 1356 | { 1357 | cn() 1358 | } 1359 | else { 1360 | ;not change 1361 | } 1362 | 1363 | } 1364 | 1365 | 1366 | 1367 | ;交给 ditto 复制粘贴就行了。有更多的文本处理选择。 1368 | Text_only_paste(){ ; Text–only paste from ClipBoard. 1369 | Clip0 := ClipboardAll() 1370 | A_Clipboard := A_Clipboard 1371 | Send("^v") 1372 | Sleep(50) ; Don't change clipboard while it is pasted! (Sleep > 0) 1373 | A_Clipboard := Clip0 ; Restore original ClipBoard 1374 | VarSetStrCapacity(&Clip0, 0) ; Free memory ; V1toV2: if 'Clip0' is NOT a UTF-16 string, use 'Clip0 := Buffer(0)' 1375 | Return 1376 | } 1377 | 1378 | 1379 | 1380 | RunWaitOne(command) { 1381 | ; WshShell 对象: http://msdn.microsoft.com/en-us/library/aew9yb99 1382 | shell := ComObject("WScript.Shell") 1383 | ; 通过 cmd.exe 执行单条命令 1384 | exec := shell.Exec(A_ComSpec " /C " command) 1385 | ; 读取并返回命令的输出 1386 | return exec.StdOut.ReadAll() 1387 | } 1388 | 1389 | RunWaitMany(commands) { 1390 | shell := ComObject("WScript.Shell") 1391 | ; 打开 cmd.exe 禁用命令显示 1392 | exec := shell.Exec(A_ComSpec " /Q /K echo off") 1393 | ; 发送并执行命令,使用新行分隔 1394 | exec.StdIn.WriteLine(commands "`nexit") ; 保证执行完毕后退出! 1395 | ; 读取并返回所有命令的输出 1396 | return exec.StdOut.ReadAll() 1397 | } 1398 | 1399 | 1400 | 1401 | search_with_edge( need_to_copy := 1){ 1402 | 1403 | if ( need_to_copy == 1){ 1404 | Send("^{c}") 1405 | Sleep(200) 1406 | } 1407 | ErrorLevel := "ERROR" 1408 | Try ErrorLevel := Run("msedge.exe `"https://www.google.com/search?q=" A_Clipboard "`"", , "", ) 1409 | 1410 | } 1411 | 1412 | url_go(string){ ; url_go("") 1413 | { ErrorLevel := "ERROR" 1414 | Try ErrorLevel := Run("msedge.exe `"" string "`"", , "", ) 1415 | } 1416 | } 1417 | 1418 | ; 个人资料-南昌航空大学统一身份认证 (nchu.edu.cn) ; url_go("http://passport.nchu.edu.cn/main.aspx?action=Srun_Login") 1419 | go_school_online() 1420 | { 1421 | ; url_go(" http://login.network.nchu.edu.cn/srun_portal_pc?ac_id=1&theme=pro") ; 这个网址总是加载不出来! 1422 | url_go("http://10.1.88.4/srun_portal_pc?ac_id=1&theme=pro") 1423 | SS() 1424 | SS("f") 1425 | SS("e") 1426 | } 1427 | 1428 | go_school_offline(){ 1429 | ; url_go(" http://login.network.nchu.edu.cn/srun_portal_pc?ac_id=1&theme=pro") ; 这个网址总是加载不出来! 1430 | ; url_go("http://10.1.88.4/srun_portal_pc?ac_id=1&theme=pro") ; 这两都行,下面这个是已经成功的,少一个跳转。 1431 | url_go("http://10.1.88.4/srun_portal_success?ac_id=1&theme=pro") 1432 | SS() 1433 | SS("f") 1434 | SS("a") 1435 | SS("f") 1436 | SS("s") 1437 | 1438 | 1439 | ; http://login.network.nchu.edu.cn/srun_portal_pc?ac_id=1&theme=pro 1440 | ; url_go("http://passport.nchu.edu.cn/logout.aspx") ; 两套学校的认证网页. 1441 | } 1442 | 1443 | ;sleep and send key 1444 | SS( a:="" ){ 1445 | Sleep(1000) 1446 | Send(a) 1447 | 1448 | } 1449 | 1450 | 1451 | 1452 | CapsLock & F8::recorder() 1453 | recorder(){ 1454 | ; Hotkey, Capslock, Off 1455 | ; Input, keystrokes, V, {Capslock} 1456 | ; ClipBoard := keystrokes 1457 | ; SetCapsLockState, Off 1458 | ; Hotkey, Capslock, On 1459 | ; Return 1460 | ih := InputHook( ,"`n") 1461 | ih.Start() 1462 | ih.Wait() 1463 | ToolTip(ih.Input ) 1464 | 1465 | 1466 | ; 记录所有按键只需要加一个 keyopt。 1467 | 1468 | ; hook := InputHook() 1469 | ; hook.KeyOpt("{All}", "NS") 1470 | ; hook.OnKeyDown := Func("spam") 1471 | ; hook.Start() 1472 | ; spam(hook, vk, sc) 1473 | ; { 1474 | ; loop 3 1475 | ; SendInput % "{sc" Format("{:03X}", sc) "}" 1476 | ; } 1477 | 1478 | } 1479 | 1480 | return_last_combined_key() 1481 | { 1482 | Array := StrSplit(A_ThisHotKey , " ", ">$~+^< &", 3) ; a & b 会返回三个值,两个空格之间的符号也算上了,手动跳过。 1483 | first_key := Array[1] 1484 | latter_key := Array[Array.Length] 1485 | if( Array.Length == 1) 1486 | return first_key 1487 | else 1488 | return latter_key 1489 | 1490 | } 1491 | 1492 | ; 等待并返回按键 ; but don't block the key. KeyWaitAny("V") 1493 | KeyWaitAny(Options:="") 1494 | { 1495 | ih := InputHook(Options) 1496 | if !InStr(Options, "V") 1497 | ih.VisibleNonText := false 1498 | ih.KeyOpt("{All}", "E") ; End 1499 | ih.Start() 1500 | ih.Wait() 1501 | return ih.EndKey ; Return the key name 1502 | } 1503 | 1504 | Pause5Seconds(){ 1505 | Suspend(-1) 1506 | Pause() 1507 | Sleep(5000) 1508 | Reload 1509 | return 1510 | } 1511 | 1512 | 1513 | ; ebebeb 灰色, zotero 页面直接的分割线,用于找到一页的开始。 1514 | ; ffffff 白色,000000 黑色。 1515 | ; find the bar, then decede the size, wheel up/down to the page beginning. 1516 | check_calc_space_and_skip_bar( direction := "↓↓" ){ 1517 | 1518 | CoordMode("Mouse", "Screen") 1519 | CoordMode("Pixel", "Screen") 1520 | if( direction == "↓↓" ){ 1521 | Send("{Space}") 1522 | } 1523 | else{ 1524 | Send("+{Space}") 1525 | } 1526 | Sleep(200) 1527 | if (WinExist("A")){ 1528 | Title := WinGetTitle() 1529 | Class := WinGetClass() 1530 | Proc := WinGetProcessName() 1531 | ; ToolTip(Title "`n" Title "`n" Proc) 1532 | if( Proc == "zotero.exe" ){ 1533 | while (true){ 1534 | found := PixelSearch( &outx,&outy, 25 ,164, 25,250,0xebebeb,1) 1535 | if( found == 1){ ; 在 合适的地方找到了页面的开始。 1536 | ; ToolTip( " Found at x:=" outx " y:= " outy "`n color = " PixelGetColor(outx,outy) , 999,outy) 1537 | break 1538 | } 1539 | else 1540 | flag := 0 1541 | if( direction == "↓↓") 1542 | Send("{Up}") 1543 | else 1544 | Send("{Down}") 1545 | Sleep(50) 1546 | } 1547 | } 1548 | } 1549 | } 1550 | 1551 | 1552 | 1553 | ; 去除 PDF 文字复制时候多余的回车。 粘贴到沙拉查词里面。 1554 | thesis_remove_enter_saladict(){ 1555 | Send("^{c}") 1556 | Sleep(100) 1557 | textRaw := A_Clipboard 1558 | t2 := StrReplace(textRaw, "`n") 1559 | t2 := StrReplace(t2, "`r") 1560 | textWithout_enter := t2 1561 | Sleep(100) 1562 | Send("!{d}") ; 查词软件快捷键 1563 | Sleep(100) 1564 | A_Clipboard:= textWithout_enter 1565 | Send("^{v}") 1566 | Send("{enter}") 1567 | } 1568 | F7 & 7::init_pixel_find() 1569 | 1570 | ; 根据 像素的位置 找到 第一次搜索是 eng,第二次是 cn 1571 | 1572 | init_pixel_find(){ 1573 | global true_position:= [ 885,17,0xD9D8E5,887,16,0x76767A] ;enXYColor_cnXYColor 1574 | CoordMode("Mouse", "Screen") 1575 | CoordMode("Pixel", "Screen") 1576 | 1577 | startX := 870 1578 | sY := 0 1579 | endX:=900 1580 | eY:=50 1581 | flag := 1 1582 | while (flag == 1){ 1583 | PixelSearch( &a, &b , startX,sY,endX,eY,0x000000,150) 1584 | Sleep(400) 1585 | Send("{Shift}") 1586 | PixelSearch( &c, &d , startX,sY,endX,eY,0x000000,150) 1587 | if(a != c){ 1588 | flag := 0 1589 | } 1590 | else{ 1591 | ; startX := a+1 1592 | sY := b+1 1593 | if( startX >= endX or sY > eY){ 1594 | MsgBox("can't find!") 1595 | break 1596 | } 1597 | continue 1598 | } 1599 | } 1600 | if( a > c){ ;第一次搜索是 eng,第二次是 cn 1601 | true_position[1]:= a 1602 | true_position[2] := b 1603 | true_position[3] := PixelGetColor(a, b,"Alt") 1604 | true_position[4]:= c 1605 | true_position[5] := d 1606 | true_position[6] := PixelGetColor(c, d,"Alt") 1607 | } 1608 | else{ ;第一次搜索是 cn 1609 | true_position[4]:= a 1610 | true_position[5] := b 1611 | true_position[6] := PixelGetColor(a, b,"Alt") 1612 | true_position[1] := c 1613 | true_position[2] := d 1614 | true_position[3] := PixelGetColor(c, d,"Alt") 1615 | } 1616 | ToolTip( return_IME_state_from_pixel()) 1617 | } 1618 | 1619 | return_IME_state_from_pixel(){ 1620 | CoordMode("Mouse", "Screen") 1621 | CoordMode("Pixel", "Screen") 1622 | global Current_IME_State 1623 | startX := 870 ; 任务栏长度不固定,最好搜索范围大一些 870 1624 | sY := 0 1625 | endX:= 950 ;900 1626 | eY:=42 1627 | ImageSearch( &outa, &outb,startX,sY, endX,eY,"*5 *TransBlack C:\Users\Administrator\OneDrive\代码\AHK\eng1.png") 1628 | ImageSearch( &c, &d,startX, sY, endX, eY,"*5 *TransBlack C:\Users\Administrator\OneDrive\代码\AHK\cn1.png") 1629 | ; ToolTip( "outa" outa " outb" outb "`n" c "cd" d,,,4) 1630 | ; if ( outa =="" or c == "" ) { 1631 | ; MsgBox("没找到!") 1632 | ; } 1633 | if( outa !=""){ 1634 | Current_IME_State := 1 1635 | } 1636 | else if(c !=""){ 1637 | Current_IME_State := 2 1638 | } 1639 | } 1640 | 1641 | ; 根据颜色找到 IME 状态。 1642 | return_IME_state_from_pixel_failed(){ 1643 | CoordMode("Mouse", "Screen") 1644 | CoordMode("Pixel", "Screen") 1645 | MouseGetPos(&MouseX, &MouseY) 1646 | global Current_IME_State 1647 | global true_position 1648 | 1649 | if( A_UserName == "Administrator"){ 1650 | 1651 | posi1x := 862 1652 | posi1y := 30 1653 | cursorColor := PixelGetColor(MouseX, MouseY,"Alt") ;学校的电脑 1654 | 1655 | 1656 | ; group1 := [862,30,0xD9D8E5,0x6e6e75,0x6d6d74,0xdbdae8] ;学校的电脑 1657 | ; group2 := [898,26,0x76767A,0xEDEDF4,0x6d6d74,0xdbdae8] ;还是学校的电脑,但是位置怎么变了? 1658 | ; 日历控件的长度是不一样的,得写一个初始化函数,自动寻找位置。 1659 | engX :=true_position[1] 1660 | engY :=true_position[2] 1661 | EngColor:=true_position[3] 1662 | cnX :=true_position[4] 1663 | cnY :=true_position[5] 1664 | cnColor :=true_position[6] 1665 | realColorEn := PixelGetColor(engX, engY,"Alt") 1666 | realColorCN := PixelGetColor(cnX, cnY,"Alt") 1667 | char := "" 1668 | 1669 | 1670 | if( realColorEn == EngColor ){ ; ime 图标在选中的时候会偏亮, 色彩不对,后两个才是平常状态的色彩 1671 | Current_IME_State := 1 ;eng 1672 | char := "1" 1673 | } 1674 | else if( realColorCN == cnColor){ 1675 | Current_IME_State := 2 ;chn 1676 | char := "2" 1677 | } 1678 | else{ 1679 | ToolTip("没找到!") 1680 | } 1681 | } 1682 | 1683 | ; ----------------------dbug 1684 | ToolTip( char "position is " "`t" 1685 | " MouseX=" MouseX " MouseY=" MouseY " cursorColor :=" PixelGetColor(MouseX,MouseY,"Alt") "`n" 1686 | A_UserName "`n" 1687 | true_position[1] " " true_position[2] " " true_position[3] " " true_position[4] " " true_position[5] " " true_position[6] 1688 | "`n" Current_IME_State 1689 | ,862,30,7) 1690 | 1691 | 1692 | return Current_IME_State 1693 | } 1694 | 1695 | ; 发送,切换,回车。 1696 | change_to_en_and_put_stringSpace(){ 1697 | Send("{Enter}") 1698 | en() 1699 | Send("{Space}") 1700 | } 1701 | 1702 | ; 把之前的字退回,重新送给 IME。 1703 | change_to_chn_and_retype(){ 1704 | Send("{Ctrl Up}{Shift down}{Shift Up}") ; 提前发一个 ctrl 抬起避免 ctrl+shift; shift to flip IME_state 1705 | Sleep(50) 1706 | Send("^+{Left}") ; eng 向左,剪切,切换 chn,发送。Send(“Left”) ; English向左,剪切,切换 chn 1707 | ClipSaved := ClipboardAll() ; Save the entire clipboard to a variable of your choice. ToolTip(ClipSaved) 1708 | A_Clipboard := "" ; Empty the clipboard 1709 | Send("^{x}") 1710 | ClipWait() ; 等待剪切板有东西. 必须保留. 1711 | 1712 | stringRetype := Trim(A_Clipboard," ") 1713 | ; Send( ) ; ; 手心输入法有问题,最后发送一定会丢失第二个字符串。需要单独发送每个字母这里有问题 ; 手心输入法有问题,最后发送一定会丢失第二个字符串。需要单独发送每个字母 1714 | ; 自己实现延迟发送 clipboard 里面的数据 ↓ 1715 | loop parse stringRetype ; each character of the input string will be treated as a separate substring. 1716 | { 1717 | if( A_LoopField == "`n") 1718 | break 1719 | Send(A_LoopField) 1720 | Sleep(50) 1721 | } 1722 | 1723 | A_Clipboard := ClipSaved ; Restore the original clipboard. Note the use of A_Clipboard (not ClipboardAll). 1724 | ClipSaved := "" ; Free the memory in case the clipboard was very large. 1725 | } 1726 | 1727 | ; if(StrLen(A_Clipboard) >30) return 0 1728 | ; SetKeyDelay(150,150,) ; 这种写法没用,感觉是在最后加了一个延迟 ,而不是每个字符之间加了一个延迟。 1729 | ; 1730 | regretChangeIME_EtC(){ 1731 | ; ClipSaved := ClipboardAll() 1732 | Send("^+{Left}{sleep 550}^{x}") 1733 | Sleep(500) 1734 | retype_text := A_Clipboard ; Convert to text 1735 | retype_text := RTrim(retype_text , " ") 1736 | 1737 | cn() 1738 | ; ToolTip("A_Clipboard = " A_Clipboard ) 1739 | SendMode "Input" 1740 | ;手心输入法有 bug , 怎么调都没用一定会丢失第二个字符,不如 自己实现一个 send 函数。 1741 | ; SetKeyDelay(100) 1742 | ; Send(retype_text) 1743 | ; ; SetKeyDelay, 1000, 50 1744 | ; SetKeyDelay(0) 1745 | 1746 | Send_with_delay( retype_text ) 1747 | 1748 | 1749 | 1750 | ; A_Clipboard := ClipSaved ; Restore original ClipBoard 1751 | ClipSaved := "" ; Free the memory in case the clipboard was very large. 1752 | 1753 | } 1754 | global VyVi := 0 1755 | global Iivi := 0 1756 | 1757 | ; ~k:: 1758 | ; ~d:: 1759 | ; { 1760 | ; global VyVi 1761 | ; VyVi := A_TickCount 1762 | ; checkforce(1) 1763 | ; } 1764 | ; ~f:: 1765 | ; ~j:: 1766 | ; { 1767 | ; global Iivi 1768 | ; Iivi := A_TickCount 1769 | ; checkforce(2) 1770 | ; } 1771 | ; checkforce( num:=1){ 1772 | 1773 | ; global VyVi 1774 | ; global Iivi 1775 | ; if( Abs(VyVi - Iivi) <135 ){ 1776 | ; Send("{BackSpace 2}") 1777 | ; if( VyVi < Iivi ) ;fdjkkjfdfdfsfs放大df叫 1778 | ; cn() 1779 | ; if( VyVi > Iivi ) 1780 | ; en() 1781 | 1782 | ; } 1783 | 1784 | ; } 1785 | 1786 | 1787 | ; ~^s:: 1788 | ; { 1789 | ; if( A_PriorHotkey == A_ThisHotKey ) 1790 | ; Reload ;;;; f 1791 | ; } 1792 | 1793 | ; 记录 stopsitting 小工具的时间,并显示在屏幕右上角 1794 | ; 函数内过滤太近的输入 1795 | global Stop_Sitting_block_once := 0 1796 | global blockPomodoro:= 0 1797 | My_automatic_Pomodoro_Stop_Sitting_function_couting_up(){ 1798 | global blockPomodoro 1799 | if(blockPomodoro == 1) 1800 | return 1801 | global Stop_Sitting_counter 1802 | global Stop_Sitting_Lastime_triggered 1803 | global Stop_Sitting_block_once 1804 | total_minius := 20 ; pomodoro 时长; 1805 | time_gap := 15 * 1000 ; 最小检测时长,推荐 15s 到一分钟。如果间隔太短一次检测的话,工作的时间没有被记录上。 20Min 需要 35 Min 触发。 1806 | dt := A_TickCount - Stop_Sitting_Lastime_triggered 1807 | jigger := A_TimeIdlePhysical 1808 | if( dt > time_gap ) 1809 | { 1810 | if( dt > 300000) 1811 | Stop_Sitting_counter:=0 ; 太长的空闲,重置计数器。 1812 | if( Stop_Sitting_block_once == 1){ 1813 | Stop_Sitting_block_once := 0 1814 | return 1815 | } 1816 | Stop_Sitting_Lastime_triggered:= A_TickCount 1817 | Stop_Sitting_counter += dt 1818 | ; ToolTip("+" Stop_Sitting_Lastime_triggered "`n" Stop_Sitting_counter , 200,,3) 1819 | ElapsedTime := Stop_Sitting_counter 1820 | sec := Floor(ElapsedTime/1000) 1821 | minute := Floor(sec / 60) 1822 | CoordMode("ToolTip" , "Screen") 1823 | MouseGetPos(&xpos, &ypos, &id, &control) 1824 | ; ToolTip(minute ":" sec, A_ScreenWidth , 0, 16) 1825 | ToolTip(minute ":" sec, A_ScreenWidth , ypos, 16) 1826 | } 1827 | 1828 | 1829 | if( Stop_Sitting_counter > total_minius * 60 * 1000 ){ 1830 | 1831 | result := MsgBox("Get Up! `n Yes to End this work & take a walk `n No to clear remind me short after",, "Y/N ") 1832 | if(result == "Yes"){ 1833 | clear_and_wait_for_new_run_automatic_Pomodoro_Stop_Sitting_function_Reset() 1834 | Send("#^{c}") 1835 | } 1836 | else if(result == "No"){ 1837 | Stop_Sitting_counter := Stop_Sitting_counter * 0.9 1838 | Stop_Sitting_Lastime_triggered:=A_TickCount 1839 | } 1840 | } 1841 | 1842 | 1843 | } 1844 | 1845 | 1846 | clear_and_wait_for_new_run_automatic_Pomodoro_Stop_Sitting_function_Reset(){ 1847 | global Stop_Sitting_counter 1848 | global Stop_Sitting_Lastime_triggered 1849 | Stop_Sitting_counter:= 0 1850 | Stop_Sitting_Lastime_triggered:=A_TickCount 1851 | ToolTip( , 100,,2) 1852 | SetTimer () => tooltip("rest enough for 5 min") , -30*10 *1000 ; 5 minus Good to Sit Back. 1853 | SetTimer () => Send("#^{c}") , -30*10 *1000 1854 | SetTimer () => tooltip("rest enough for 10 min"), -60*10 *1000 ; 10 minus Good to Sit Back. 1855 | SetTimer () => Pomodoro_Kill() , -60*10 *1000 1856 | } 1857 | 1858 | 1859 | global cVE:=1 1860 | ; singal hand virgo like virtual desktop currentVirtualEnvironment 1861 | VirgoRight(){ 1862 | global cVE 1863 | cVE := Mod(cVE + 1,4) 1864 | if( cVE = 0 ) 1865 | cVE := 4 1866 | ToolTip(cVE) 1867 | Send("!{" cVE "}") 1868 | 1869 | } 1870 | 1871 | 1872 | 1873 | virgoLeft(){ 1874 | global cVE 1875 | cVE := Mod(cVE -1,4) 1876 | 1877 | if( cVE = 0 ) 1878 | cVE := 4 1879 | ToolTip(cVE) 1880 | Send("!{" cVE "}") 1881 | 1882 | } 1883 | 1884 | 1885 | WinRotate(ver){ 1886 | 1887 | } 1888 | 1889 | 1890 | 1891 | 1892 | 1893 | 1894 | 1895 | ; 所以 1033 是英文的 windows 编号,这样能 用 2052 切换中文输入法! 1896 | ; D:\Win\Download\im-select.exe 1033 1897 | 1898 | ; D:\Win\Download\im-select.exe {im} 1899 | 1900 | ; D:\Win\Download\im-select.exe locale 1901 | 1902 | 1903 | ; void switchInputMethod(int locale) { 1904 | ; HWND hwnd = GetForegroundWindow(); 1905 | ; LPARAM currentLayout = ((LPARAM)locale); 1906 | ; PostMessage(hwnd, WM_INPUTLANGCHANGEREQUEST, 0, currentLayout); 1907 | ; } 1908 | 1909 | ; 我把这个方法摘出来,自己写一个! 1910 | ; 官网 postmessage 的例子 居然就是这个。。。 1911 | ; 切换活动窗口的键盘布局/语言为英语(US). →→→ PostMessage 0x0050, 0, 0x4090409,, "A" ; 0x0050 is WM_INPUTLANGCHANGEREQUEST. 1912 | 1913 | 1914 | ; 致谢 不再誤打,讓Windows快速切換到指定的輸入法 - TLLhttp://tll.tl › ... 1915 | ; 1916 | ; 2017年1月24日 — 這兩行的功能是將::前的按鍵,右Alt或左Alt定義成後面的功能,也就是將現在的鍵盤配置切換為中文(0x4040404)或英文(0x4090409)。同理,你也可以設定成自己 ... 1917 | --------------------------------------------------------------------------------