I hope to add a new built-in variable ---- A_ entirely_new_hotstring

Propose new features and changes
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

I hope to add a new built-in variable ---- A_ entirely_new_hotstring

22 Jul 2020, 10:16

In Scite Editor there is a feature that expands a word by using CTRL + B. For example, if I type “ag”, then I press CTRL + B, “ag” can becomes “abcdefghijklmn” or other anything you want.

If there is a built-in variable A_ entirely_new_hotstring, we can do this very easily.

Code: Select all

CapsLock & q::
	if (A_ entirely_new_hotstring="ag")
		Send, abcdefghijklmn
	if (A_ entirely_new_hotstring="mail")
		Send, [email protected]
	if (A_ entirely_new_hotstring="number")
		Send, 88888888
return
if i type "abc agei{backspace}{backspace}",i hope the "A_ entirely_new_hotstring" stored "ag".
swagfag
Posts: 3972
Joined: 11 Jan 2017, 17:59

Re: I hope to add a new built-in variable ---- A_ entirely_new_hotstring

22 Jul 2020, 15:23

Code: Select all

#Requires AutoHotkey v1.1.33.02

global A_EntirelyNewHotstring := "" ; where input is collected

for each, endChar in ["-", "(", ")", "[", "]", "{", "}", "'", ":", ";" , """", "/", "\", ",", ".", "?", "!", "Enter", "Space", "Tab"]
	Hotkey % "~" endChar, eraseAllChars

eraseAllChars() {
	A_EntirelyNewHotstring := ""
}

; visible & disable char limit/input collection,
; since we're managing the collection ourselves
ih := InputHook("V L0")
ih.OnChar := Func("appendChar")
ih.Start()

appendChar(ih, char) {
	A_EntirelyNewHotstring .= char
}

CapsLock & q::
tryExpand() {
	; obj keys are case insensitive
	static Expansions := { ag: "abcdefghijklmn"
						 , mail: "[email protected]"
						 , number: 88888888 }

	eraseLastChar() ; this hotkey's char, ie q

	; the abbreviation matches
	if Expansions.HasKey(A_EntirelyNewHotstring)
	{
		Send % "{BackSpace " StrLen(A_EntirelyNewHotstring) "}" ; erase the abbreviation
		Send % "{Text}" Expansions[A_EntirelyNewHotstring] ; send the replacement
		eraseAllChars() ; reset input collection
	}
}

~BackSpace::
eraseLastChar() {
	A_EntirelyNewHotstring := SubStr(A_EntirelyNewHotstring, 1, -1)
}
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: I hope to add a new built-in variable ---- A_ entirely_new_hotstring

23 Jul 2020, 03:57

@swagfagthank you so much!!!!!!!!!!!
I'll continue to modify this code and add some mouse click judgment to make it look like autohotkey's own hotstring recognizer.
thank you so much again!!!!
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: I hope to add a new built-in variable ---- A_ entirely_new_hotstring

27 Jul 2020, 10:34

@swagfag
i have a new question.
If I've used "-", "(", ")", "[", "]" as a hotkey, how can I resolve the hotkey conflict?
swagfag
Posts: 3972
Joined: 11 Jan 2017, 17:59

Re: I hope to add a new built-in variable ---- A_ entirely_new_hotstring

27 Jul 2020, 12:05

if theyre also meant to act as endchars, change their subroutines to also call eraseAllChars() once at some point
if theyre not, u can just delete them from my code

or u can also think about making them context sensitive, if it makes sense
tuzi
Posts: 44
Joined: 27 Apr 2016, 23:40

Re: I hope to add a new built-in variable ---- A_ entirely_new_hotstring

28 Jul 2020, 03:25

@swagfag
I see. Thank you.

In the beginning, considering the possible conflict with hotkeys,so i hope to add this built-in variable.

I know that the possibility of adding a built-in variable for this is very small, so this code is still very helpful to me, thank you again!

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 9 guests