Windows Hotkey Overriding AHK Hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Windows Hotkey Overriding AHK Hotkey

Post by AlFlo » 01 Jun 2023, 16:27

I'm using AHK v1 and Windows 11.

I have a script to help display commonly-used information as menu items, so I can paste them into documents. (The script is at the end of this post).

But the built-in Windows 11 hotkeys are firing instead, messing up my AHK script. Is there any way to disable the specific Windows 11 hotkey associated with win-z, without disabling ALL Windows hotkeys?

Win-z is launching Microsoft's snap dialogue. But when I try using other hotkeys, they launch other Windows' hotkeys (e.g. Win-c launches a Microsoft Teams dialog).

Here's my script:

Code: Select all

Gui, Add, MonthCal, vVar2
Gui, Add, Button, xm w400, Done
Gui, Show,, Transaction
 
Return

ButtonDone:

    Gui, Submit, Hide

#z::

FormatTime, Var2, %Var2%, M/d/yyyy

 Menu scripts, Add, %Var2%, Execute
 Menu scripts, Add, Postage, Execute
Menu scripts, Add, Stamps.com, Execute
 Menu scripts, Add, Copies, Execute
 Menu scripts, Add, Filing Fees, Execute
 
Loop Files, C:\Clients\Clip Box.txt, R
{ FileRead txt, % A_LoopFilePath
Menu scripts, Add, % StrSplit(txt, "`r")[10], Execute
}

Menu, scripts, Show
Return

Execute:
SendInput {Text}%A_ThisMenuItem%
Return

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

Re: Windows Hotkey Overriding AHK Hotkey

Post by mikeyww » 01 Jun 2023, 19:10

It worked here. Is the script running? If you change the hotkey to something like F3, does it work?

AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Re: Windows Hotkey Overriding AHK Hotkey

Post by AlFlo » 01 Jun 2023, 20:29

mikeyww, I forgot to mention that I'm experiencing this problem when I'm working in a TABLE in Microsoft Word, as that is where I need to frequently insert this information.

For some odd reason, the different hotkeys I've tried work (i.e. AHK hotkeys, and not Windows hotkeys, control) in most Word documents, but not within tables.

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

Re: Windows Hotkey Overriding AHK Hotkey

Post by mikeyww » 01 Jun 2023, 20:51

It worked here, but different Windows configurations might yield different results. The bottom line is that if two programs use the same hotkey, you might not have great control over which has priority, at least not without more advanced efforts. My suggestion is that when you identify conflicting hotkeys such that the AHK hotkey does not work, resolve the conflict by changing one of the hotkeys.

AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Re: Windows Hotkey Overriding AHK Hotkey

Post by AlFlo » 01 Jun 2023, 23:13

Thanks, mikeyww. I got it working by deleting the MonthCal and FormatTime lines, which weren't essential. I think what happened is that the script paused just long enough to process the FormatTime that it let the Windows hotkey slip in there and take priority.

Post Reply

Return to “Ask for Help (v1)”