Odd hotstring behavior. XXwholeword triggers...

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
kunkel321
Posts: 1126
Joined: 30 Nov 2015, 21:19

Odd hotstring behavior. XXwholeword triggers...

Post by kunkel321 » 06 May 2024, 17:15

An interesting thing with hotstrings... With an example like this

Code: Select all

::biz::wap
If you type "xxbiz" then an end char, it doesn't replace. This is because there is no ? in the options :?:biz::wap, thus allowing it to be a word-ending match.

However, it appears that if you start with two capitals, like "XXbiz", then it does do the replacement --> "XXwap"

Tagging @Descolada and @Jasonosaj, because they might find it interesting...
ste(phen|ve) kunkel

gregster
Posts: 9081
Joined: 30 Sep 2013, 06:48

Re: Odd hotstring behavior. XXwholeword triggers...

Post by gregster » 06 May 2024, 17:23

On v2.0.14?
On v2.0.13, I don't see it. Edit: Correction: I just discovered that I am still on v2.0.12 on this computer. Will update later.
lexikos fixed a hotstring bug on the latest version - perhaps it has side effects...

User avatar
kunkel321
Posts: 1126
Joined: 30 Nov 2015, 21:19

Re: Odd hotstring behavior. XXwholeword triggers...

Post by kunkel321 » 06 May 2024, 19:31

Strange... I'm getting inconsistent results with v2.0.2. With v2.0.1.0 it happens consistently. That's my main master script with all my stuff in it though...
At first I assumed it was the below code, but I totally commented it out, and still saw the error. I'll get the latest AutoHotkey.exe, and try again.

Code: Select all

; ==============================================================================
;       AUto-COrrect TWo COnsecutive CApitals
; This version by forum user Ntepa. Updated 8-7-2023.
; https://www.autohotkey.com/boards/viewtopic.php?p=533067#p533067
; Minor edits added by kunkel321 2-7-2024

fix_consecutive_caps()
fix_consecutive_caps() {
; Hotstring only works if CapsLock is off.
	HotIf (*) => !GetKeyState("CapsLock", "T")
	loop 26 {
		char1 := Chr(A_Index + 64)
		loop 26 {
			char2 := Chr(A_Index + 64)
			; Create hotstring for every possible combination of two letter capital letters.
			Hotstring(":*?CXB0Z:" char1 char2, fix.Bind(char1, char2))
		}
	}
	HotIf
	; Third letter is checked using InputHook.
	fix(char1, char2, *) {
		ih := InputHook("V I101 L1 T.3")
		ih.OnEnd := OnEnd
		ih.Start()
		OnEnd(ih) {
			char3 := ih.Input
			if (char3 ~= "[A-Z]")  ; If char is UPPERcase alpha.
				Hotstring "Reset"
			else if (char3 ~= "[a-z]")  ; If char is lowercase alpha.
			|| (char3 = A_Space && char1 char2 ~= "OF|TO|IN|IT|IS|AS|AT|WE|HE|BY|ON|BE|NO") ; <--- Remove this line to prevent correction of those 2-letter words.
			{	SendInput("{BS 2}" StrLower(char2) char3)
				SoundBeep(800, 80) ; Case fix announcent. 
			}
		}
	}
}
ste(phen|ve) kunkel

User avatar
kunkel321
Posts: 1126
Joined: 30 Nov 2015, 21:19

Re: Odd hotstring behavior. XXwholeword triggers...

Post by kunkel321 » 06 May 2024, 19:49

Alright... Sorry for the false alarm. It is specific to my AutoCorrect2.ahk script. I changed the accompanying (portable) AutoCorrect.exe to the latest: v2.0.14. If I add the hotstring to my ac2 file, it happens every time. I made a test script though, with nothing but

Code: Select all

#SingleInstance
#Requires AutoHotkey v2+
::biz::Wap 
MsgBox 'ahk ver ' A_AhkVersion
That one works as expected...

So now what??? I guess I'll systematically comment-out different portions of my script and try to isolate what causes this. If anyone is brave enough... Please consider downloading the package from here:
https://github.com/kunkel321/AutoCorrect2
and add the ::biz::wap hotstring. See if typing "XXbiz" results in "XXwap."
ste(phen|ve) kunkel

User avatar
kunkel321
Posts: 1126
Joined: 30 Nov 2015, 21:19

Re: Odd hotstring behavior. XXwholeword triggers...

Post by kunkel321 » 07 May 2024, 11:31

Okey dokey.
Near the top of the HotstringsLib.ahk is this line of code:

Code: Select all

#Hotstring Z ; The Z causes the end char to be reset after each activation
Because of that, and because the CAse FIxer script works via hotstrings, any two capital letters will cause the hotkey recognizer to be reset.

In theory, removing the line of code stops the problem. In practice, the effect seems to "stick" much of the time, even after a reload. At any rate... Mystery solved.
ste(phen|ve) kunkel

Post Reply

Return to “Ask for Help (v2)”