none
Any chance on RegisterHotkey() ?

    Question

  • Hello,

    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

    co0Kie


    • Edited by co0Kie Thursday, September 20, 2012 11:12 PM
    Thursday, September 20, 2012 11:09 PM

All replies

  • Hi co0Kie,

    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.

    --Rob

    Friday, September 21, 2012 4:01 AM
  • Hi Rob,

    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...

    greets

    co0Kie

    Friday, September 21, 2012 8:10 PM
  • Hi co0Kie,

    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.

    --Rob

    Sunday, September 23, 2012 3:21 AM
  • Hi Rob,

    i understand this way of view but i think its wrong to not support such method which would enable you to snap your app side by side to another app by hotkey. If theres something big u would want it and Bill would see it the same way... The apps i meantioned are not just "some" apps , they are THE apps currently in this sector, and an investigation would show you that 99,98 % of the "Gaming-Apps" are going the hack *cough* hook and inject way...At the moment Google is only strong on mobile but the smartphones now going quad core aera and gaming there will grow by a huge margin and gaming-apps will pop up like mushrooms. So as written above , currently you are in a state where 99 % of the apps for games  are having "unsupported", "unguaranteed" behavior, this is just a mezzo-mix with some small sanctioned code and the other half hacking around...Its up to you now to change something or in 5-10 years the scene could be look different in terms of userfriendly gaming applications ( *cough* mobile ).

    regards

    co0Kie

    Monday, October 01, 2012 10:10 AM