From 70a33be5b52bfc3cfc6d6401ac3328147c8641f2 Mon Sep 17 00:00:00 2001 From: 8LWXpg Date: Tue, 28 Feb 2023 13:33:43 +0800 Subject: [PATCH] modify send level --- RegExHotstring.ahk | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/RegExHotstring.ahk b/RegExHotstring.ahk index 971166e..48daf05 100644 --- a/RegExHotstring.ahk +++ b/RegExHotstring.ahk @@ -1,6 +1,7 @@ #Requires AutoHotkey v2.0 -RegHook := RegExHs("VI") +SendLevel(1) +RegHook := RegExHs("VI2") RegHook.NotifyNonText := true RegHook.KeyOpt("{Space}{Tab}{Enter}", "+SN") RegHook.Start() @@ -10,20 +11,20 @@ RegHook.Start() * @param {String} String RegEx string * @param {Func or String} CallBack calls function with RegEx match info or replace string * @param {String} Options - * + * * \* (asterisk): An ending character (e.g. Space, Tab, or Enter) is not required to trigger the hotstring. * use *0 to turn this option back off. - * + * * ? (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. * Use ?0 to turn this option back off. - * + * * B0 (B followed by a zero): Automatic backspacing is not done to erase the abbreviation you type. * Use a plain B to turn backspacing back on after it was previously turned off. - * + * * C: Case sensitive: When you type an abbreviation, it must exactly match the case defined in the script. * Use C0 to turn case sensitivity back off. - * + * * O: Omit the ending character of auto-replace hotstrings when the replacement is produced. * Use O0 (the letter O followed by a zero) to turn this option back off. */ @@ -79,13 +80,13 @@ class RegExHs extends InputHook { } } - ; clear input when press non-text key OnKeyDown := this.keyDown keyDown(vk, sc) { switch vk { case 8: Send("{Blind}{vk08 down}") case 9, 13, 32: + ; clear input if not match if (!this.match(this.a0, vk, SubStr(this.Input, 1, StrLen(this.Input) - 1), (*) => Send("{Blind}{vk" Format("{:02x}", vk) " down}"))) { @@ -95,6 +96,7 @@ class RegExHs extends InputHook { case 160, 161: ; do nothing default: + ; clear input when press non-text key this.Stop() this.Start() } @@ -111,8 +113,11 @@ class RegExHs extends InputHook { OnChar := this.char char(c) { vk := GetKeyVK(GetKeyName(c)) - if (vk != 9 && vk != 13 && vk != 32) - this.match(this.a, vk) + switch vk { + case 9, 13, 32: + return + } + this.match(this.a, vk) } match(map, vk, input := this.Input, defer := (*) => 0) {