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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

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

Post by mslonik » 30 Sep 2022, 15:14

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

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:

lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

Post by lexikos » 30 Sep 2022, 18:29

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.

User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

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

Post by mslonik » 01 Oct 2022, 04:22

Thank you for your reply @lexikos :beer:

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

Kind regards, mslonik

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:

Post Reply

Return to “Ask for Help (v1)”