Hotstrings Shift stuck.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RubbeH
Posts: 49
Joined: 13 Jul 2020, 08:40

Hotstrings Shift stuck.

23 Sep 2020, 04:34

Hello!

I found a bug in my hotstrings and Idk what to do about it or if its solveable.

Code: Select all

:C*:TEST::This is a long ass test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
The problem occurs if I press Shift to type the capital letters "test", if I release Shift before the hotstring is completed, the shift button gets stuck in "down"-mode, If I keep Shift down until hotstring is completed it releases shift.
I can manually press Shift button to reset it.

I guess you can add a {Shift up} but is there another solution since that one isn't an option for me.
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Hotstrings Shift stuck.

23 Sep 2020, 04:55

Code: Select all

:C*:TEST::
oldClip := ClipboardAll
Clipboard := ""
Sleep, 50
Clipboard = This is a long test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
ClipWait, 2
Sleep, 100
Send ^v
Clipboard := oldClip
Return
RubbeH
Posts: 49
Joined: 13 Jul 2020, 08:40

Re: Hotstrings Shift stuck.

23 Sep 2020, 07:56

mikeyww wrote:
23 Sep 2020, 04:55

Code: Select all

:C*:TEST::
oldClip := ClipboardAll
Clipboard := ""
Sleep, 50
Clipboard = This is a long test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
ClipWait, 2
Sleep, 100
Send ^v
Clipboard := oldClip
Return
Not quite what I was looking for, sure, this is a workaround that works but I can't apply this solution to my current scripts unfortunately (that I know of).
(my current script is reading and creating hotstrings from a .txt-file and using hotstring() function, script in spoiler.
Spoiler



Is there any other solution to this matter? Or is this some kind of general akh-bug?
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Hotstrings Shift stuck.

23 Sep 2020, 08:01

It's an AHK issue.

You could probably work this if you put the code into a function.
Rohwedder
Posts: 7681
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hotstrings Shift stuck.

23 Sep 2020, 09:59

Hallo,
your problem does not occur here. But try:

Code: Select all

:C*X:TEST::SendInput This is a long ass test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Hotstrings Shift stuck.

23 Sep 2020, 10:04

Very nice! Worked for me.
RubbeH
Posts: 49
Joined: 13 Jul 2020, 08:40

Re: Hotstrings Shift stuck.

24 Sep 2020, 00:22

Rohwedder wrote:
23 Sep 2020, 09:59
Hallo,
your problem does not occur here. But try:

Code: Select all

:C*X:TEST::SendInput This is a long ass test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
Oh, yea great!
Is there a way to incorporate the SendInput into my hotstring function mentioned above? I guess it needs to go in this string someway or another

Code: Select all

Hotstring(":T*X:" Trim(arr[1]), Trim(arr[2]))
or perhaps if hotstring can be globally set to always incorporate it?
Rohwedder
Posts: 7681
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hotstrings Shift stuck.

24 Sep 2020, 04:05

Hallo,
perhaps:

Code: Select all

stringfile =
(
	q = Hallo,
	w = perhaps:
	test = This is a long ass test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
)
Hotstring := []
stringfile := Trim(stringfile, " `t`r`n")
loop, Parse, stringfile, `n, `r
{
	If Instr(A_loopfield, "=")
	{
		arr := StrSplit(A_loopfield, "=")
		Hotstring(":*X:" Trim(arr[1]), "SendText")
		Hotstring[":*X:" Trim(arr[1])] := Trim(arr[2])
	}
}
SendText:
	SendInput,% "{Text}" Hotstring[A_ThisHotkey]
Return
RubbeH
Posts: 49
Joined: 13 Jul 2020, 08:40

Re: Hotstrings Shift stuck.

24 Sep 2020, 05:15

Rohwedder wrote:
24 Sep 2020, 04:05
Hallo,
perhaps:

Code: Select all

stringfile =
(
	q = Hallo,
	w = perhaps:
	test = This is a long ass test-string just for testing purposes, we'll keep this string going for a little while, a little longer.... a little longer.... a little longer.... a little longer....
)
Hotstring := []
stringfile := Trim(stringfile, " `t`r`n")
loop, Parse, stringfile, `n, `r
{
	If Instr(A_loopfield, "=")
	{
		arr := StrSplit(A_loopfield, "=")
		Hotstring(":*X:" Trim(arr[1]), "SendText")
		Hotstring[":*X:" Trim(arr[1])] := Trim(arr[2])
	}
}
SendText:
	SendInput,% "{Text}" Hotstring[A_ThisHotkey]
Return
The code works, but unfortunately there's still the issue with Shift getting stuck :/
gregster
Posts: 9067
Joined: 30 Sep 2013, 06:48

Re: Hotstrings Shift stuck.

24 Sep 2020, 05:23

RubbeH wrote:
24 Sep 2020, 00:22
or perhaps if hotstring can be globally set to always incorporate it?
Auto-replacement Hotstrings are already using SendInput mode by default, if it's available.
https://www.autohotkey.com/docs/Hotstrings.htm#Options wrote: the default mode in [v1.0.43] and later is SendInput
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: Hotstrings Shift stuck.

24 Sep 2020, 05:49

I actually have a lot of problems with Shift in my routines. I never found a solution, but periodically need to issue Shift Up in my code. A variety of posts report the same thing, though I am unaware of any solution that works consistently. These problems can occur regardless of the send mode, though for me, the problems also sometimes occur without a pattern that I can identify.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 141 guests