maybe somebody already encountered the problem with establishing a systemwide hotkey in a Metro stlye app. Before someone says that i should try an external project or library, i did and after coding around like over 4 routes between different projects and librarys i nearly made it to 99 % of final but then... when tryed linking the last reference a window popped up and said : Do you realy want to link to this ? Your Project can not pass certification then for the Windows Store...
So...in older OS it was easy peasy, but it seems that RegisterHotkey() for Metro will not work anylonger, at least if you still want to keep compliance for Windows Store.
When i posted my VirtualKey Question yesterday i was already astonished about how the key description from Windows Forms was abandoned and left is only a numeric value. And now with RegisterHotkey it goes further, i mean these 2 functions are the essence of Game programming over all. I know that in DirectX games mostly use DirectInput or so but these days we are in a more browser oriented space and games can popup anywhere in any form ( even in simple Textform ). I think the Scenario of letting a user set his keys for lets say movement, weapons etc etc etc in a game is under the important functions. So showing a user what he pressed and what key now is set for Fire-Mode or whatever needs definitly a key description value in form of a string. My Cent here
Getting back the plain key description as a string plus the numeric value and ofc the possibility of registering any key as systemwide hotkey is very important, and i think that the Gaming Industry do agree on this.
Maybe theres a way for Systemwide hotkey in Metro Store App i didnt found past 1-2 days, if someone knows more about it please share or post your thoughts about it here too so that M$ maybe gives us some co0Kies in the future.
with friendly regards
- Edited by co0Kie Thursday, September 20, 2012 11:12 PM
You are correct. RegisterHotKey is not available to Windows Store apps.
I'm not sure why you would want RegisterHotKey for a game. Games care about keystrokes when they are being used, but generally don't need to accept keystrokes when the user is in another application. Hotkeys are more appropriate to pop up utilities, which are not feasible for Windows Store apps.
For the typical game scenario listen for CoreWindow.KeyUp and KeyDown events to change your input state machine or call CoreWindow.GetAsyncKeyState in your game loop.
As far as VirtualKey descriptions are concerned, this isn't something that C++ ever had. As you mention .Net provides a conversion from the enum value to the named value, and that conversion still exists for Windows Store apps using managed code. If you want to use native code you will need to provide it yourself. It is fairly trivial to create a localizable table with the mapping.
considering games your scenario building right. I was just meantion Games as an example at some edge, i am not programming on a game atm and my questions above and from past days has nothing to do with running functions by hotkey in self written program at all, were just meantioned them because they could make use of these functions very well too.
Do you know the program FRAPS ? I did build a similar app in C# this year with SlimDX and it works fine for DirectX 9, 10 and 11 with also all functions FRAPS has and even a few more. But when i came to a comparison to Fraps and other kinda apps the managed programming using some exposed functions by a wrapper failed in terms of performance so i turned back to c++ now because on DirectX the way to go is c++. I very appreciate the new Direct 3D and Direct 2D templates for Metro style and i have already a breaketrough Vision for new kind of app which not exist today but... and here we go...
If i use the frontbuffer to get the rendered scene instead of injecting code and dig in the backbuffers i would have a) less Performance on getting the Frame, b) i would not be able to implement an overlay for lets say the Fps and c) i would not be to able show my app as an overlay on key press or click ( my C# app is using inject way ). If you are now saying ok you wouldnt be able to make your app appear as an overlay with registerhotkey either when you would go the frontbuffer way, then you are rigth ofc :) But i was thinking more of a way i could possibly snap an app to left or right side of screen and still have the game in view, this would work even with frontbuffer method. But...consider if the game has focus and not the app, then it wouldnt be able to still snapping or drag it in suspend when going the frontbuffer way. So only way is the inject way and paint it as an overlay...
In the above scenario with frontbuffer the system hotkey is the only way when another app has the focus, mainly a game in my case. In the next years gaming on mobile will having great growth, especialy with Haswell and Kaveri but definitly will go wild when 14nm. Imagine a capture app which can be spapped and draged to suspend even when the game has Focus but the app is still snapped to left or right so that u can fast access the capture Settings...
Normaly i wouldnt go deep like this and telling you all here about my plans, but i think you wouldnt even make it that far because of all the barriers Metro store apps have currently. Ofc you could build such an app i descriped with hook and inject way and try sell it outside of the Windows app store like FRAPS guys doing but...wouldnt it be more the fine english way if it would be possible with some bless and stable way ? And with stable i mean all the hacking, hooking, injecting etc etc. FRAPS for example makes a systemwide hook into every process running on your machine which makes these other processes/programms more unstable ofc and is not the right way in my opinion. I found another way which i think will be better, but i still have to paint my app as overlay and go the hooking/inject way now. I think snapping apps like a capture software or teamspeak or other apps to as screen side while still have the view on your game can be very potential and is worth a Investigation by M$. But as said, to snapp your app to left or right side while gaming theres a claim for a systemhotkey...
Windows Store apps interact with each other only through well defined methods (e.g. Contracts). An app such as FRAPS or the app you describe could only be written as a desktop app. Even then it would rely on unsupported and unguaranteed behavior: definitely not blessed or stable.