Page 1 of 1

Triggerstring recognizer isn't reset after Hotstring() call if bind method is used

Posted: 30 Sep 2022, 15:14
by mslonik
Dear Forum,

The following script used as reference, works as expected:

Code: Select all

#NoEnv  						; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  	     				; Enable warnings to assist with detecting common errors.

Hotstring(":*:(", "(){left}")
Hotstring(":?*C:`nt", "`nT")
Example of use:
foo{Enter}(t
Output:
foo
(t)


The second script doesn't work as expected:

Code: Select all

#NoEnv  						; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  	     				; Enable warnings to assist with detecting common errors.

Options := "*", Triggerstring := "(", SendFun := "F1", TextInsert := "(){left}", Oflag := true, EnDis := true
Hotstring(":" . Options . ":" . Triggerstring, func(SendFun).bind(TextInsert, Oflag), EnDis)

Options := "?*C", Triggerstring := "`nt", SendFun := "F1", TextInsert := "`nT", Oflag := true, EnDis := true
Hotstring(":" . Options . ":" . Triggerstring, func(SendFun).bind(TextInsert, Oflag), EnDis)

F1(TextInsert, Oflag)	;Function _ Hotstring Output Function _ SendInput
{
	if (Oflag = false)
		SendInput, % TextInsert . A_EndChar
	else
		SendInput, % TextInsert
}


Example of use:
foo{Enter}(t
Output:
foo

T)
It seems that first call of Hotstring do not reset triggerstring recognizer if bind method is used. What have I missed?

Kind regards, mslonik

Re: Triggerstring recognizer isn't reset after Hotstring() call if bind method is used

Posted: 30 Sep 2022, 18:29
by lexikos
By design, auto-replace hotstrings reset the hotstring buffer to contain only the end character or nothing.

By default, non-auto-replace hotstrings only remove the trigger text from the buffer. To reset it completely, you must use the Z option.
Z: This rarely-used option resets the hotstring recognizer after each triggering of the hotstring.
Source: Hotstrings - Definition & Usage | AutoHotkey
... or Hotstring("Reset").

Keys that you send are ignored by default, so if it is not reset, the hotstring buffer will only contain the text you typed before the trigger text.

Re: Triggerstring recognizer isn't reset after Hotstring() call if bind method is used

Posted: 01 Oct 2022, 04:22
by mslonik
Thank you for your reply @lexikos :beer:

It works both ways (applying "Z" option or "Hotstring("Reset")"). Now it seems trivial...

Kind regards, mslonik