1
void gkh_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == System.Windows.Forms.Keys.LControlKey) && (e.KeyCode == System.Windows.Forms.Keys.O))
            {
                Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect;
                CaptureConfig cc = new CaptureConfig()
                {
                    Direct3DVersion = direct3DVersion,
                    ShowOverlay = cbDrawOverlay.Checked
                };
            }
        }

When i press on left ctrl + o i want that the first time cbDrawOverlay will be checked: cbDrawOverlay.Checked but if i press on it same keys again then make it unchecked how can i do it ?

Jenny Mchammer
  • 95
  • 1
  • 2
  • 9

1 Answers1

1
void gkh_KeyDown(object sender, KeyEventArgs e)
{
  if (ModifierKeys.HasFlag(Keys.Control) && e.KeyCode == System.Windows.Forms.Keys.O)
    cbDrawOverlay.Checked = !cbDrawOverlay.Checked;
}
Zer0
  • 7,191
  • 1
  • 20
  • 34
  • ZerO the problem is that even if i click only the Ctrl button it's getting to the IF i used a breakpoint on it and it's not waiting for the O key to be pressed to so it's never get inside. Tried it with your IF and with my original IF same problem it's not waiting for the O to be pressed. And since only ctrl pressed it won't get inside. – Jenny Mchammer Sep 12 '14 at 18:48
  • @JennyMchammer the event should be raised twice, once with `Keys.LControlKey` and that call will skip over the `if` statement, then once again with `Keys.O` with the modifier `Keys.Control`. – Scott Chamberlain Sep 12 '14 at 18:54