Skip to content

Commit

Permalink
modify send level
Browse files Browse the repository at this point in the history
  • Loading branch information
8LWXpg committed Feb 28, 2023
1 parent 0a51cc8 commit 70a33be
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions RegExHotstring.ahk
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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}"))) {
Expand All @@ -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()
}
Expand All @@ -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) {
Expand Down

0 comments on commit 70a33be

Please sign in to comment.