Shift key stuck after firing hotstring

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omareg94
Posts: 94
Joined: 27 Jun 2016, 22:46

Shift key stuck after firing hotstring

Post by omareg94 » 11 Oct 2023, 07:55

I have a hotstring defined as following:

Code: Select all

:*SEK10:cdyy<:: ; (c)urrent (d)a(y) (format 2)
  FormatTime, CurrentDateTime, Default, dddd, dd-MMM-yyyy
  Clipboard := "⋮ " CurrentDateTime
  ClipWait
  SendEvent % "^v" ; paste content
return
On Windows 11, many times, when I type `cdyy<` hotstring on any window (more often on notepad), it stucks shift key pressed.
And when I type any letter, it gets written as Upper case unintentionally, until I press & release shift key again, it gets fixed. But it's annoying to have it some times when I fire the hotstring.

This video shows how it behaves on a notepad window:
https://youtu.be/58lJxQE9iLw
Many times the hotstring keeps Shift key pressed & doesn't get fixed until I press & release Shift key again.

Other Notes:
- Reason why I'm using SendEvent is here..
- This issue happens also on other editors like VS Code or a text input in a browser.
Last edited by omareg94 on 11 Oct 2023, 11:27, edited 1 time in total.

User avatar
boiler
Posts: 17395
Joined: 21 Dec 2014, 02:44

Re: Shift key stuck after firing hotstring

Post by boiler » 11 Oct 2023, 09:04

It is a known issue that Notepad in Windows 11 has broken many (most?) AHK scripts. A search of the forum should turn up several threads on the topic, although I haven’t seen a resolution other than to use a different text editor.

omareg94
Posts: 94
Joined: 27 Jun 2016, 22:46

Re: Shift key stuck after firing hotstring

Post by omareg94 » 11 Oct 2023, 11:26

@boiler
This issue happens also on other editors like VS Code or a text input in a browser.

omareg94
Posts: 94
Joined: 27 Jun 2016, 22:46

Re: Shift key stuck after firing hotstring

Post by omareg94 » 27 Oct 2023, 05:04

Anyone has any justification / solution?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Shift key stuck after firing hotstring

Post by mikeyww » 27 Oct 2023, 05:32

Your script has some bugs. To use the clipboard in this way, you would not need to change or set the Send mode for the hotstring itself, because the hotstring is not using auto-replace text. Sending Ctrl+V can be done normally. I believe that simply assigning the clipboard to a hard-coded string will not require a ClipWait, but if you did use ClipWait, you would clear the clipboard first, and then check the ErrorLevel to see whether an error occurred. Example. See the documentation for FormatTime.

FormatTime, OutputVar [, YYYYMMDDHH24MISS, Format]
YYYYMMDDHH24MISS: Leave this parameter blank to use the current local date and time. Otherwise, specify all or the leading part of a timestamp in the YYYYMMDDHH24MISS format.
The following worked here. Test in Notepad, with no other code in the script, and no other scripts running.

Code: Select all

#Requires AutoHotkey v1.1.33

::cc::
FormatTime ts,, dddd, dd-MMM-yyyy
Clipboard := "Date: " ts
Send ^v
Return

Post Reply

Return to “Ask for Help (v1)”