My application registers a hot key for PrtScr using the RegisterHotKey() WinAPI function.
In most cases, it works correctly and is caught by my application. But, if some applications become active on the screen then this hot key is not caught. At the same time, if I switch to another application, it works.
I observed such a problem in Task Manager, Chrome browser, and a few others. Sometimes it even doesn't work on one Chrome app window but works fine at the same time on another Chrome window.
I also observed the same problem with other applications which use PrtScr as a hot key, so it seems the problem is not in my application. But I still can't figure out the logic behind that.
If somebody knows what the reason is of PrtScr being blocked in such cases, I would appreciate if you share your knowledge.
It should work on Chrome(unless you run Chrome with elevated privilege? no idea if it works on one window then fails on another). Failing on Task Manager is by design because of User Interface Privilege Isolation (UIPI). And with UIPI, both
RegisterHotKeyandLowLevelKeyboardProcwill fail on task manager, or any other programs with higher privilege.Please read Microsoft document. You can either run your app as administrator, or properly configure the
UIAccessflag by signing the app and put it in a protected location.