Reenable (windows)keys after another program has disabled it - winapi

Quake3 has disabled the alt and windows keys.
Is there any way to reenable them even while quake3 is running? I need those keys even while I have the game open.
They way I think it works is that the game registers a hotkey using RegisterHotKey and then sets the handled property to true every time the key is pressed.
So if you use UnRegisterHotkey on these keys on the quake3-window I guess the keys will start working again. The problem is that you have no idea what hotkey-id the disabled keys have.
Is there any way to enumerate the hotkeys that a window has registered to get all the hotkey-ids?

It's quite likely that Quake3 doesn't bother with RegisterHotKey at all, but instead uses DirectInput. In that case, it quite likely holds the keyboard in exclusive mode, which explains why the Windows key doesn't work - it's the OS which disables it. Quoting MSDN : "In exclusive mode, the Windows logo key is always disabled."

Related

Win32 - How do I catch key event in background, without using global key hook or RegisterHotKey?

I made a program that takes a screenshot of a game window when a specific key is pressed. I am using RegisterHotKey(). It works well, but there is a problem: when the game window is on focus, my program can't receive that key event. To take a screenshot, I have to click the desktop to move the focus to desktop, then press that key. Only in that way can my program receive the key event and take a screenshot. (the game itself provides an in-game camera to take screenshots, but the camera can't take screenshots of UI, inventory, etc. That's why I made this program.)
It's a easy fix to use global key hook, but if I use global key hook, my program will be prone to be identified as a malware (that steals password, for example.) by anti-malware softwares, meaning that I can't share it with other players. (After all, for players that are not good at computer, it is tiring to convince Windows Defender that my program is not malware.)
Is there any idea to catch the key event, but won't make my program identified as a malware?
You can set up a global key monitor by using Raw Input. To do so you need to set the RIDEV_INPUTSINK flag in the RAWINPUTDEVICE structure passed into the RegisterRawInputDevices call.

Caps Lock does not seem to work as modifier key (Insert) with NVDA running inside a virtual machine (macOS VMware Fusion)

I'm running NVDA inside a virtual machine on my macOS using VMware Fusion. I do that since many years, and it's generally a very smooth experience, except that I need to map a keyboard key to Insert. I use Karabiner-Elements to do just that: it maps my right option key to Insert. This runs just fine, but it is quite a complex installation/configuration, and when asking clients to do the same, they are quickly overwhelmed. (Sadly, while VMware Fusion offers a feature to map certain keyboard combos to different ones, it does not allow to just change a single key's [ie. right option to insert] mapping.)
So I tried to go the route of activating the NVDA option to use caps lock as modifier key, too. But this just does not seem to work - or do I do something wrong?
Would I need to keep holding caps lock while hitting (for instance) N (to show the NVDA menus)
Or would pressing and releasing caps lock trigger some special "I am on Insert now" mode, so I could just hit another key like N? And then press and release caps lock again to deactivate the "special mode" again?
Neither option works for me. What I can say though is that the "real" caps lock functionality does not get activated anymore with the option checked, unless I hit it twice in a row quickly. So it at least seems to have some effect...
Am I doing something wrong? Any help is highly appreciated.

How to change the functionality of PrtSc (PrintScreen) key?

I wrote a little program that uses the PrtSc key as a replacement for pressing / clicking the middle mouse key.
My program uses the GetAsyncKeyState API function to scan the PrtSc.
It works fine.
The problem is that the original functionality of PrtSc continues to work also.
So, as long as PrtSc is pressed, screenshots of the desktop are being made.
After a brief moment, this leads to some hickups and delays in my screen repainting.
So I would like to turn off the 'screenshot function' of PrtSc.
I tried this method of adding a registry key to change the scan code.
disable the printscreen keyboard option from windows
But this makes the PrtSc key pretty much 'disappear' for Windows.
In the sense that GetAsyncKeyState also does not see the keypresses anymore.
Does anybody know of a way to 'detach' the screenshot functionality from PrtSc, but in such a way that pressing PrtSc still generates keycodes ...?
I have a work-around for now.
Still interested in the answer to my question though...
Work-arounds (two):
I am using the Tab key instead of the PrtSc key in my program. Not entirely happy with this, since it messes with the Tab action when entering text.
Using key remapping in AutoHotkey (that I was already using)
I remap the Tab key to Middle Mouse Button, but only for the program for which I need this:
#IfWinActive "My CAD software"
*Tab::MButton
#IfWinActive

Key repeat on Windows

When you hold a key on the keyboard under Windows XP, the keyboard seems to send Key Down, Key Up repeatedly. However I am developing for a device where holding a key generates a "proper" key repeat, that is, lots of Key Down and then one Key Up when you release the button.
I want to get the same behaviour under Windows to get our emulator to work as on he device. Is there anyway to acheive this? Do I need to get another keyboard driver? Thanks!
Problem in an internal API as stated in the comment

How to programmatically detect a system hotkey?

I'm looking for a way to programmatically detect hotkeys in the system. My app supports configurable hotkeys to do different things, and I'd like to be able to tell if another app has snagged one already or it's a built-in Windows hotkey (like Win-L to lock the workstation).
And if it is another app that owns the hotkey, I'd like to be able to show that to the user. At least the name of the exe.
I'm aware of three ways to do hotkeys:
System hook using standard API's
Using the hotkey feature in the properties dialog for a shortcut
Polling async key state and responding
I doubt I can detect the third type, but what about the other two? And are there any other situations I need to know about?
I can think of three ways to do it with Standard API:
RegisterHotkey
SetWindowsHookEx(WH_KEYBOARD)
SetWindowsHookEx(WH_LL_KEYBOARD)
With the first approach, you will get in the return value whether another application already registered the very same hotkey (or whether a shortcut uses this hotkey, or Explorer.exe registered the hotkey because it is Win+E or win+R). You don't get the application name this way, though.
Using Windows Hooks or async key states for "hotkeys": I don't think it is possible to detect hotkeys there, since you might use hotkeys in a context (like replace "t" by "irst" if the last four keystrokes were "Fris") that way. You could inject the hotkey using keybd_event (with your window focused) and test if the event "gets through"; on the other hands, some cases of "hotkeys" that are implemented via hooks do not consume the keystroke so it will still get through.
The approach I would use: First make sure that for entering a shortcut, you have to type that exact shortcut into your shortcut box (if that fails, the user will see which application uses it). Then use RegisterHotkey, so you will notice (in future sessions) if another "well-behaving" application tried to steal this shortcut from you.

Resources