CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    266

    GetAsyncKeyState alternative for a process hotkey.

    Well here's the situation I have injected a dll into a process, I want for example when I press F5 something to happen. I could use GetAsyncKeyState without a problem for that but that is system-wide i could press F5 in my VS and still the dll will toggle. I could make checks for foreground windows but I'm asking whether there is a sexier alternative that is process-wide ( accelerators won't work since I don't own a window except a message-only window and since windows only process keystrokes if focused my hidden window doesnt help me ). Something that could tell me whether a key is pressed within my process without mapping the windows messages I guess ( or a workaround to using accelerators with a message-only window).
    Thanks in advance.

  2. #2
    Join Date
    May 2000
    Location
    Armenia
    Posts
    201

    Re: GetAsyncKeyState alternative for a process hotkey.

    It is not clear why you are avoiding to use windows messages approach (for example SetWindowsHookEx function).

  3. #3
    Join Date
    Jul 2005
    Posts
    266

    Re: GetAsyncKeyState alternative for a process hotkey.

    Quote Originally Posted by Armen View Post
    It is not clear why you are avoiding to use windows messages approach (for example SetWindowsHookEx function).
    Well let me clarify this. My injected DLL has a console ( AllocConsole-ed), now the original application has its own window. I want my hotkey to be active whether the console has focus or the main window has focus. Consoles don't have a message queue so that's why I have made a message-only window ( to show a system tray icon for the console window etc ) but if it's not focused it won't receive any keystrokes notification or translate any accelerators and since it's hidden it can't be focused.

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: GetAsyncKeyState alternative for a process hotkey.

    Use RegisterHotKey. This hotkey will work everywhere in windows, your windows doesn't need focus for it.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured