bug? Hotstring using just a colon

Report problems with documented functionality
Altouch
Posts: 7
Joined: 21 Oct 2019, 15:13

bug? Hotstring using just a colon

09 Nov 2019, 09:03

:*:`;::abc It works.

:*:`:::abc It does not works.

Mod edit: Added title
User avatar
Delta Pythagorean
Posts: 567
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: bug?

11 Nov 2019, 03:25

For a single character hotstring, you can use a hotkey instead, like so:

Code: Select all

:::
MsgBox, Colon
Return

`;::
MsgBox, SemiColon
Return
Both work respective to what was pressed (individual key or shift modifier).

- [AHK].......: 1.1.33.02 Unicode 64-bit
- [OS].........: Windows 10.0.18362
- [GITHUB]...: github.com/DeltaPyth
- [PAYPAL]....: paypal.me/DelPyth
- [DISCORD]..: Delta#3324

Remember to use [code]CODE[/code] for your multi-line scripts.
Stay safe, stay inside, and remember to wash your hands for 20 seconds!
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

Re: bug?

14 Nov 2019, 12:29

hotstrings wrote: Although commas, percent signs, and single-colons within hotstring definitions do not need to be escaped, backticks and those semicolons having a space or tab to their left require it.
You can use the hotstring function, hotstring(":*::", "abc").

Cheers.
joefiesta
Posts: 381
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: bug?

14 Nov 2019, 17:46

@helgef :\
I don't get it. I don't see what explains why

Code: Select all

:*:`::: this fails
and

Code: Select all

:*::::  this fails too
both fail. I see using the HOSTRING function as just a workaround.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: bug?

14 Nov 2019, 18:42

Just FYI, by writing a function like this, you can define a hotstring anywhere in a script, versus being forced to define it in the auto-execute section.

Code: Select all

MyHotstring()
{
	static vDummy := MyHotstring()
	Hotstring(":*::", "abc")
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

Re: bug?

15 Nov 2019, 00:30

@joefiesta, it means that the attempt to escape the single colon is futile. As for,

Code: Select all

:*::::  this fails too
This has two possible interpretations, either it is a hotstring which is missing its abbreviation, with the replacement text : this fails too, or the abbreviation is a single colon with the replacement text this fails too. Clearly the first interpretation is made, although the second one is probably preferable. With the hotstring function there is no ambiguity (since the trailing :: are omitted).

@jeeswg,

Code: Select all

MyHotstring()
{
	static Dummy := Hotstring(":*::", "abc")
}
Cheers.
Helgef
Posts: 4459
Joined: 17 Jul 2016, 01:02
Contact:

Re: bug?

16 Nov 2019, 07:56

In v2, you can escape a single colon, hence, :*:`:::abc is replacing a single : with abc. This cannot happen in v1, because in v1, the backtick (`) in :*:`:::abc is escaping the following double colon, see :arrow: escape sequences. So in v1, you can do :*:`::::abc to have :: be replaced by abc, in v2 that will replace : with :abc.

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: bug? Hotstring using just a colon

23 Nov 2019, 21:41

Thanks Helgef.

So, here are 2 examples, a one-liner and a multi-liner.

Code: Select all

MyHotstrings1()
{
	static vDummy := Hotstring(":*::", "abc")
}

MyHotstrings2()
{
	static vDummy := MyHotstrings2()
	Hotkey, IfWinActive, ahk_class Notepad
	Hotstring(":*:abc-", "Notepad")
	Hotkey, IfWinActive, ahk_class WordPadClass
	Hotstring(":*:abc-", "WordPad")
	Hotkey, IfWinActive
	Hotstring(":*:abc-", "other")
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests