سؤال

I am creating a program for taking screenshots of a game, out of the game. When I press the hotkey it works, but with the open game in fullscreen it does not detect the key.

My code:

protected override void WndProc(ref Message m)
{
    const int WM_HOTKEY = 0x0312;

    switch (m.Msg)
    {
        case WM_HOTKEY:
        {
            if ((short)m.WParam == 1)
            {
                start = DateTime.Now;
                progressBar1.Maximum = 1;
                progressBar1.Step = 1;
                progressBar1.Value = 0;

                DoRequest();
            }
            break;
        }

        default:
        {
            base.WndProc(ref m);
            break;
        }
    }
}

I register the global key using:

RegisterHotKey(this.Handle, 1, (int)KeyModifier.None, Keys.F11);

Help-me :/

SOLVED! Resolved, I managed to fix through this project: http://www.codeproject.com/Articles/19004/A-Simple-C-Global-Low-Level-Keyboard-Hook

Thank you all!

هل كانت مفيدة؟

المحلول

The problem with most games (not all of them) is that they use DirectInput (DirectX) and not windows message pump to read keystrokes. I have also written an application using voice recognition that sends keys to games and experienced the same issue which I solved by looking at DirectX keycodes. ref: DirectInput

نصائح أخرى

I had a similar problem but I solved it by running my program with Admin privileges.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top