Blocking Win10 access keys also disables AHK

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Blocking Win10 access keys also disables AHK

04 Dec 2020, 23:33

I need to block the Windows 10 Access keys so that those keys combinations to be defined in AHK. I implemented the three suggestions in this article: https://www.top-password.com/blog/disable-windows-key-shortcuts-hotkeys-in-windows-10/. The first two options changed nothing. For example: The Win+G assigned in autohotkey.ahk, was still overridden by the Windows key assignment of Win+G.

The third tweak, which required an additional registry key named "Scancode Map" blocks every change or enhancement and the keyboard functions in generic mode only. No macro keys of any kind, from any app, function.

This is the header of my autohotkey.ahk

Code: Select all

; 2020-12-04 23:32

; D:\ahk\eng.ahk
; desktop version, numpad navigation keys are disabled
; laptop version, numpad navigation keys are enabled

SetWorkingDir, D:\ahk

AutoTrim, On

#Include D:\ahk\eng-pr.ahk
#installkeybdhook
#noenv
#singleinstance force
#MaxThreadsPerHotkey 1

; disable for testing
#warn unreachable, off

SetTimer, AutoReload, 50000

~lwin::vk07
~rwin::return
~appskey::return
~#bs::return
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Blocking Win10 access keys also disables AHK

05 Dec 2020, 05:47

Hallo,
try:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Try Run *RunAs "%A_ScriptFullPath%"
#InputLevel 100
LWin::vkFF
RWin::vkFF
#InputLevel 1
; type Win + Q
vkFF & q::MsgBox,% "you typed " SubStr(A_PriorHotkey,2) " + Q"
If I give the script the required rights (normally not necessary) it works everywhere here.

More universal:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Try Run *RunAs "%A_ScriptFullPath%"
#InputLevel 100
LWin::vkFF
RWin::vkFF
#InputLevel 1
#IF GetKeyState("vkFF"), Win:=SubStr(A_PriorHotkey,2)
q::MsgBox, you typed %Win% + Q
+w::MsgBox, you typed Shift + %Win% + W
#IF
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: Blocking Win10 access keys also disables AHK

05 Dec 2020, 16:34

Rohwedder wrote:
05 Dec 2020, 05:47
Many many thanks for the solution, it's really appreciated.

Just exploring the possibilities with the following question:

Is there a way to set a rule that all modifier key combinations declared in the .ahk file take precedence over any app's key same assignments?

I am referring to combinations with "Ctrl, Win, Alt, and Alt+Cr".
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Blocking Win10 access keys also disables AHK

06 Dec 2020, 03:29

I do not believe that there is such a possibility. But I am not a Windows expert!
Keyboard shortcuts which the childish Windows absolutely wants to have, it may keep with my own main script.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Blocking Win10 access keys also disables AHK

06 Dec 2020, 09:00

When you start a hotkey with a tilde, the key is "sent through". That is not a technical description, just how I describe it (documentation explains what it really does:
When the hotkey fires, its key's native function will not be blocked
).

Answer: if you remove the tilde, it should work for you (I predict).

The following worked perfectly on Win7 Pro.

Code: Select all

AppsKey::Return
LWin::Return
I might be misunderstanding what you need, but this approach essentially blocks the keys.
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: Blocking Win10 access keys also disables AHK

06 Dec 2020, 16:02

mikeyww wrote:
06 Dec 2020, 09:00
Thanks for the advice. I tried it and it blocks all Windows keyboard assignments, including AHK. The hope was that my key combinations will override the same combinations used by Windows to gain a few more easily accessible key combinations for my macro scheme.
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Blocking Win10 access keys also disables AHK

06 Dec 2020, 16:14

You can reassign those keys as you like. An example is below.

Code: Select all

LWin::MsgBox, TEST
AppsKey::SoundBeep, 1000, 50
User avatar
ineuw
Posts: 172
Joined: 11 Sep 2014, 14:12

Re: Blocking Win10 access keys also disables AHK

07 Dec 2020, 00:41

mikeyww wrote:
06 Dec 2020, 16:14
You can reassign those keys as you like. An example is below.
The deeper I bury myself into the intricacies of AHK the more I am in awe of the complexities faced by the developers. I must read, understand, and test more, before revisiting this topic. If it's possible, I would like to keep this post open.
Win 10 Professional 64bit 21H2 16Gb Ram AHK current as of 2021-12-26 .

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], macromint, peter_ahk and 350 guests