From 38f83e8cc49818a9a127a7e6b2780c6d4274ff57 Mon Sep 17 00:00:00 2001 From: chen junkai <52616111@qq.com> Date: Thu, 23 May 2024 18:48:19 +0800 Subject: [PATCH] fix: keyfunc doubleChar for vscode --- language/English.ahk | 21 +++++++++++++++++++-- language/Simplified_Chinese.ahk | 23 ++++++++++++++++++++--- lib/lib_keysFunction.ahk | 20 ++++++++++++-------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/language/English.ahk b/language/English.ahk index 2686a08..79be7e7 100644 --- a/language/English.ahk +++ b/language/English.ahk @@ -206,7 +206,7 @@ cldocs=https://capslox.com/capslock-plus/en.html ;----------------------------------------------------------------; ; ## The hotstring settings of TabScript -; - Capslock + Tab will replace the string matching a key name on the left of the cursor with the corresponding value, +; - Capslock + Tab will replace the string matching a key name on the left of the cursor with the corresponding value, ; for example: ; There is "@=capslock-plus@cjkis.me" here, then you can type "@" anywhere, and press "Capslock+Tab", the "@" will be ; replaced with "capslock-plus@cjkis.me" @@ -323,7 +323,7 @@ lang_settingsDemoFileContent_2= ; Capslock + LALt + F1~F12 ; Capslock + LALt + 0~9 ; Capslock + LALt + a~z -; Capslock + LALt + `-=[]\;',./ +; Capslock + LALt + `-=[]\;',./ ; Capslock + LALt + Backspace, Tab, Enter, Space, RAlt ; Capslock + Win + 0~9 @@ -698,6 +698,23 @@ caps_win_0=keyFunc_winbind_binding(10) ;----------------Other Functions---------------- +; wrap the selected text with specified characters, or input specified characters +; examples: +; +; "..." +; caps_quote=keyFunc_doubleChar(""") +; +; (...) +; caps_9=keyFunc_doubleChar((,)) +; +; {...} +; caps_leftSquareBracket=keyFunc_doubleChar({,}) +; +; [...] +; caps_rightSquareBracket=keyFunc_doubleChar([,]) +; +keyFunc_doubleChar + ; Previous media keyFunc_mediaPrev diff --git a/language/Simplified_Chinese.ahk b/language/Simplified_Chinese.ahk index 674b2b6..81ea7b9 100644 --- a/language/Simplified_Chinese.ahk +++ b/language/Simplified_Chinese.ahk @@ -292,12 +292,12 @@ lang_settingsDemoFileContent_2= ; Capslock + F1~F12 ; Capslock + 0~9 ; Capslock + a~z -; Capslock + `-=[]\;',./ +; Capslock + `-=[]\;',./ ; Capslock + Backspace, Tab, Enter, Space, RAlt ; Capslock + LALt + F1~F12 ; Capslock + LALt + 0~9 ; Capslock + LALt + a~z -; Capslock + LALt + `-=[]\;',./ +; Capslock + LALt + `-=[]\;',./ ; Capslock + LALt + Backspace, Tab, Enter, Space, RAlt ; Capslock + Win + 0~9 @@ -372,7 +372,7 @@ caps_t=keyFunc_doNothing ;选中至行首 caps_u=keyFunc_selectHome -;独立剪贴板 1 的粘贴 +;独立剪贴板 1 的粘贴 caps_v=keyFunc_paste_1 ;backspace @@ -670,6 +670,23 @@ caps_win_0=keyFunc_winbind_binding(10) ;----------------其他功能---------------- +; 用指定的字符包裹选定的文本,或输出指定的字符 +; 例如: +; +; "..." +; caps_quote=keyFunc_doubleChar(""") +; +; (...) +; caps_9=keyFunc_doubleChar((,)) +; +; {...} +; caps_leftSquareBracket=keyFunc_doubleChar({,}) +; +; [...] +; caps_rightSquareBracket=keyFunc_doubleChar([,]) +; +keyFunc_doubleChar + ;上一首 keyFunc_mediaPrev diff --git a/lib/lib_keysFunction.ahk b/lib/lib_keysFunction.ahk index 20bd701..c238939 100644 --- a/lib/lib_keysFunction.ahk +++ b/lib/lib_keysFunction.ahk @@ -140,11 +140,11 @@ keyFunc_translate(){ global selText:=getSelText() if(selText) - { + { ydTranslate(selText) } else - { + { ClipboardOld:=ClipboardAll Clipboard:="" SendInput, ^{Left}^+{Right}^{insert} @@ -238,7 +238,11 @@ keyFunc_doubleChar(char1,char2:=""){ else { Clipboard:=char1 . char2 - SendInput, +{insert}{left %charLen%} + SendInput, +{insert} + ; prevent the left input from interrupting the paste (may occur in vscode) + ; fact: tests show that 50ms is not enough + Sleep, 75 + SendInput, {left %charLen%} } Sleep, 100 Clipboard:=ClipboardOld @@ -345,7 +349,7 @@ keyFunc_cut_1(){ CapsLock2:="" return } - + ClipboardOld:=ClipboardAll Clipboard:="" SendInput, ^{x} @@ -657,7 +661,7 @@ keyFunc_getJSEvalString(){ if(!ErrorLevel) { Clipboard:=result - + return } } @@ -806,7 +810,7 @@ keyFunc_winPin(){ ; { ; WinSet, AlwaysOnTop, Off ; WinSet, Transparent, Off - ; + ; ; return ; } WinSet, AlwaysOnTop @@ -858,7 +862,7 @@ keyfunc_wheel_down(){ Send, {Wheeldown 3} } - + ;keys functions end------------- @@ -866,7 +870,7 @@ keyfunc_wheel_down(){ ; init 初始单次移动距离 ; a 加速度 ; max 最大单次移动距离 -dynamic_speed(init:=10, a:=0.2, max:=80) +dynamic_speed(init:=10, a:=0.2, max:=80) { static N := 0 if (A_ThisHotkey = A_PriorHotkey) and (A_TimeSincePriorHotkey < 300)