How to achieve the lowest level of access to keys?

Ask gaming related questions (AHK v1.1 and older)
unleashed7
Posts: 6
Joined: 26 Feb 2019, 20:11

How to achieve the lowest level of access to keys?

26 Feb 2019, 20:44

Hello,

I'm using AHK for a while and I love it! But today I noticed something weird. I tend to use scripts to automate things like task switching, audio mute/unmute on applications, etc.
I started playing the game Call of Duty: Black Ops 4 and my hotkeys were acting weird. They did what they should, but with a few "extra" actions I didn't want. The problem was, that AHK couldn't block access to any keys which was bound to an action in the settings of the game.

Step by step I tried to fix this and narrow down what the specific problem could be. I tried things like:

Code: Select all

F1::
  Send, f
Return

F1::Return

VK70::Return

SC03B::Return
None of these worked. Yes, the first one wrote the character "f" when the chat was open, but all of them did the action what it should for the game.
And another example of this control of the game is the Caps Lock key, which can't be used in some situations, because it toggles the Map in-game. And to prevent confusion when using the chat, the developers disabled it when it can be used as a map toggle. Because of this, I can't bind any AHK hotkey to Caps Lock, because it won't fire when it is blocked by the game.

I'd like to ask if I could "catch" these keys earlier somehow, before it reaches the applications? How could I implement my script lower, than it is by default?


Thanks in advance!

Regards,
Devvie
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: How to achieve the lowest level of access to keys?

26 Feb 2019, 22:56

Using the keyboard hook should be good enough.

Code: Select all

#installKeybdHook
; or
$F1::
I've never had an in-game keybind take precedence over AHK with the hook active.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
unleashed7
Posts: 6
Joined: 26 Feb 2019, 20:11

Re: How to achieve the lowest level of access to keys?

27 Feb 2019, 01:40

Thanks for the answer! But it didn't work, sadly..

I tried both of them, and this too in the auto-exec section:

Code: Select all

#UseHook On
Any other suggestion?
If I unbind the keys in the game's settings, it won't interfere, but I'd need those functions too, while I can activate/deactivate my script whenever I want.

Just a wild guess, but isn't there any other type of hook in AHK? Or I saw other scripts using DLLs (although, it was some mouse script, I think), wouldn't that help? I'm clueless about this right now.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to achieve the lowest level of access to keys?

27 Feb 2019, 02:21

no, ahks hooks wont do if the game is reading raw input
ull need to use autohotkeyInterception: https://github.com/evilC/AutoHotInterception
unleashed7
Posts: 6
Joined: 26 Feb 2019, 20:11

Re: How to achieve the lowest level of access to keys?

27 Feb 2019, 04:51

I'll look into this. Thanks!
_3D_
Posts: 277
Joined: 29 Jan 2014, 14:40

Re: How to achieve the lowest level of access to keys?

28 Feb 2019, 02:13

Your problem must be separated in 2 parts:
1. Catch hotkey F1::
2. Send method Send 1

Pre. First of all you need to check:
1 Windows 32/64
2 Game 32/64
3 AutoHotkey.exe 32/64
The worst combination W32 + G32 + A32. This case will torch you.
The best combination W64 + G32 + A64. Game is encapsulated into WoW and even dont understand that there AHK.

1. In most cases in games catching hotkeys start to work when AutoHotkey.exe start "As Administrator". (if not you need evilC low level library)
How to check if hotkey work?

Code: Select all

F1::tooltip("F1 pressed")
F1 up::tooltip("F1 released")
Here only hotkey registration. If it works then you can use hotkeys in game.
If NOT then:
1 Change AutoHotkey.exe properties to run As Administrator.
2 #InstallKeybdHook
3 Try when hotkey stop to work before game start / when game start. In this case try run script before game start / when game start.

2. Most games need SendEvent mode that is default to AHKv1.0 but not for AHKv2.0 SendMode("Event").

Code: Select all

F1::Send(1)
Send event mode 1 to game - If it works you've done.
If NOT then:
1 Check all send modes.
2 Use evilC low level library.

In short use Windows x64 and AutoHotkey.exe x64, run AutoHotkey.exe As Administrator, run script before game start.
AHKv2.0 alpha forever.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 29 guests