Hotkeys fail to work in certain programs

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
timg11
Posts: 25
Joined: 10 Dec 2016, 14:09

Hotkeys fail to work in certain programs

Post by timg11 » 28 Jan 2022, 19:02

I'm running AHK 1.1.33.10 on Windows 10 64 bit.
I use a hotkey Alt-Win-D to insert a date string like 2022-01-28.

It is defined like this in my autohotkey.ahk file

Code: Select all

#!d:: Send %A_YYYY%-%A_MM%-%A_DD%
I've always had issues where a few programs would not accept the date string, but instead would cause the Windows calendar to pop up from the tray. It is not just this one hotkey - other hotkeys that don't have a "default" windows action like Alt-Win-E, simply do nothing in the affected applications.

I've suddenly seen many more programs start to fail to work with AHK hotkeys, including Word and Excel (where their functioning is critical for me). Outlook still works when editing an email, and PowerPoint still works properly, though. Notepad fails, but Firefox (which is a 64 bit program) works.

I've thought this was a 64 bit vs 32 bit issue, but I have confirmed that Word and Excel are still running as 32 bits after the recent update.
"Microsoft® Word for Microsoft 365 MSO (16.0.14326.20702) 32-bit "

What is the root cause of this failure and can I fix it by changing my hotkey code?

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

Re: Hotkeys fail to work in certain programs

Post by mikeyww » 28 Jan 2022, 19:09

These might actually be simple issues.

1. Microsoft Office programs enable their own hotkeys that you can change in the settings.

Word -> File -> More -> Options -> Customize Ribbon -> Customize

2. Defining a hotkey that Windows has already defined as a special Win key may yield varying results. You can select a different hotkey.

In short, if another program has already defined the same hotkey that you are defining, your hotkey might work, or it might not.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Hotkeys fail to work in certain programs

Post by amateur+ » 28 Jan 2022, 19:30

Or you might have buggy scripts that leave some of Shift, Ctrl, Alt or Win keys logically down after execution.
You may use something like this to escape from it:

Code: Select all

*~Esc::send, {Ctrl Up}{Alt Up}{Shift Up}{Win Up}{LCtrl Up}{LAlt Up}{LShift Up}{LWin Up}{RCtrl Up}{RAlt Up}{RShift Up}{RWin Up}
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

RussF
Posts: 1261
Joined: 05 Aug 2021, 06:36

Re: Hotkeys fail to work in certain programs

Post by RussF » 29 Jan 2022, 07:23

I agree with @mikeyww with regard to staying away from the Win key when defining hotkeys. That key is hooked into too many native Windows functions.

I also have a hotkey defined to insert the current date, Ctrl-Alt-d. I don't have any problems with in in any program other than Excel, when on occasion, Excel just wouldn't take the string. I discovered, however, that the order in which I actually press the keys seems to make a difference. If I press Ctrl-Alt-d in that order, about 50% of the time, Excel won't take it. If I press Alt-Ctrl-d, in that order, I have yet for it to fail. I've now just gotten used to pressing the keys in that order and have no problems. Your mileage may vary.

Russ

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

Re: Hotkeys fail to work in certain programs

Post by mikeyww » 29 Jan 2022, 07:26

That is interesting about Ctrl+Alt+D, as I have a similar hotkey and a similar problem at various times. I will give your idea a try, RussF. By habit, I almost always press Ctrl first. I thought that the order would never matter for a hotkey like this.

RussF
Posts: 1261
Joined: 05 Aug 2021, 06:36

Re: Hotkeys fail to work in certain programs

Post by RussF » 29 Jan 2022, 07:41

I discovered that quite by accident one day when the cell wouldn't accept the date. I kept pressing Ctrl first (habit, like you) with no joy. Just happened to press Alt first and it worked.

Note - I have my Ctrl and CapsLock keys switched in the registry, putting Ctrl next to "A" where it belongs (again, dating myself). That "shouldn't" make a difference, but you never know.

Russ

timg11
Posts: 25
Joined: 10 Dec 2016, 14:09

Re: Hotkeys fail to work in certain programs

Post by timg11 » 29 Jan 2022, 11:12

Thanks for the feedback. I guess this is a serious problem - no quick fixes.

"Not using the Windows Key" as a hotkey modifier is not a viable option. I have almost every letter mapped to Alt-Win-something, and the Ctrl-Alt and ctrl-shift shortcuts are already widely used by other applications.

I tried the order of the modifiers, and it has no effect.

I looked at the Word shortcuts. The dialog does not provide any way to see what keys are already mapped. The only way I can see to inspect is to select "All Commands" under categories, then scroll one by one through several thousand "Commands" in the right list, looking for any that have a keyboard shortcut defined.

I don't think it is conflict with the Word shortcuts, since it is a Windows function that is triggered.
Win-Alt-D is a Windows shortcut for calendar, but my AHK shortcut for the same key code has worked in most programs until this week.

Since my other AHK shortcuts that do not have a Windows shortcut function simply fail and do nothing, I don't think it specifically related to the Win-alt-D key, but something more general is blocking the AHK Send command in certain applications. When blocked, the key is passed on to Windows and will perform the Windows shortcut function (such as Win-Alt-D) if defined.

What is blocking AHK from working in these applications? What is the common aspect of the working and non-working applications?

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

Re: Hotkeys fail to work in certain programs

Post by mikeyww » 29 Jan 2022, 11:22

If all Send is blocked, then you can try running as admin. Otherwise, I think that this would be difficult to determine, because programs can do what they like!

Run as Administrator

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Hotkeys fail to work in certain programs

Post by amateur+ » 29 Jan 2022, 15:05

You should use a mask key to prevent some events with Alt or Win when you use "sendish" commands . You should do it manually because of this:
AltUp.png
AltUp.png (6.68 KiB) Viewed 2678 times
So you need to manually control that you release Ctrl first or use another mask key like vkFF.
You may remember that issue with Ctrl+Shift that I had (this combination switches keyboard layout by OS on my PC): such issues always take place with sendish commands only and are absent with others.
So you have two solutions: Ctrl Up first or use another mask key:

Code: Select all

^!d::send derCool page header ; This command causes a problem in Excel
^!d::ToolTip, derCool page header  ; will never cause a problem.
^!d::send {Blind}{Ctrl Up}{Alt Up}derCool page header ; solution №1. We release Ctrl first.
^!d::send {Blind}{vkFF}{Alt Up}{Ctrl Up}derCool page header ; solution №2. vkFF is a mask key instead of Ctrl.
And with Win key everything is the same, read the documentation: MenuMaskKey
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Post Reply

Return to “Ask for Help (v1)”