hotkeys global in win11

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
armin889
Posts: 96
Joined: 02 Nov 2021, 15:11

hotkeys global in win11

Post by armin889 » 26 Jun 2022, 20:57

Hello community
I want to use this hotkeys global in win11

Code: Select all

$XButton2::Click 2
$XButton1::Click
well it is working but not everywhere
for example, it not works in osk.exe where I mainly need it

hope some expert knows a solution
thanks a lot

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: hotkeys global in win11

Post by gregster » 26 Jun 2022, 21:00


lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: hotkeys global in win11

Post by lexikos » 27 Jun 2022, 03:38

Why is that the go-to solution for problems like this? Running as admin has consequences that should be avoided if possible.

OSK.exe is manifested to run with UI access, which allows it to send keystrokes to programs that run as admin, without OSK itself running as admin. This also protects OSK from automation by less-privileged programs, which would otherwise be able to use OSK to circumvent security restrictions.

Do the same for the script - run with UI access - and it should work.
How do I work around problems caused by User Account Control (UAC)?

By default, User Account Control (UAC) protects "elevated" programs (that is, programs which are running as admin) from being automated by non-elevated programs, since that would allow them to bypass security restrictions. Hotkeys are also blocked, so for instance, a non-elevated program cannot spy on input intended for an elevated program.
...
Common workarounds are as follows:
  • Enable the Add 'Run with UI Access' to context menus option in AutoHotkey Setup. This option can be enabled or disabled without reinstalling AutoHotkey by re-running AutoHotkey Setup from the Start menu. Once it is enabled, launch your script file by right-clicking it and selecting Run with UI Access, or use a command line like "AutoHotkeyU32_UIA.exe" "Your script.ahk" (but include full paths).
  • ... [other less ideal workarounds, including run as admin] ...
Source: Frequently Asked Questions (FAQ) | AutoHotkey

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

Re: hotkeys global in win11

Post by mikeyww » 27 Jun 2022, 06:08

I learned something here.

If this will not work with a portable instance of AHK, then it may help to note this on AHK's download page.

armin889
Posts: 96
Joined: 02 Nov 2021, 15:11

Re: hotkeys global in win11

Post by armin889 » 27 Jun 2022, 12:37

Running as admin on compiled .exe is the only thing I got it to work atm

Post Reply

Return to “Ask for Help (v1)”