1

Basically what I want done is the ability to set a hotkey and then check if it is being pressed at a later date.

I would use the Keyboard.iskeydown() method, however there is no way to check if a mousebutton is held down.

The Keys enum from System.Windows.Forms contains definitions for mouse buttons however you can't pass a Keys enum value into the isKeyDown method as it only accepts a Key enum value from System.Windows.Input. Is there any way to check if a Keys value is being pressed in the same way?

I must be able to use the hotkey while the form is out of focus.

also, my KeyDown event doesn't detect mouse-presses

private void textBox_AimBotKey_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    hotkey = e.KeyCode;
    textBox_SetHotKey.Text = Convert.ToString(e.KeyCode);
}
Nino
  • 6,931
  • 2
  • 27
  • 42
  • What about the MouseDown event? Note that these events only work when the form has focus. – Haytam Jul 13 '18 at 11:44
  • Are there any alternatives that work without focus, I know the isKeyDown method works but like I've said, it dones't include support for mouse buttons – MouseAndKeyboard Jul 13 '18 at 11:48
  • capturing keys without focus is possible, take a look at [this](https://stackoverflow.com/questions/15428566/capturing-a-key-without-focusing-the-window), and maybe [this](https://msdn.microsoft.com/en-us/library/system.windows.input.mouse.leftbutton%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396) can help you with mouse button – Nino Jul 13 '18 at 11:51
  • Preventing the mouse buttons from working correctly in other programs is rather a bad idea. Google "c# setwindowshookex wh_mouse_ll" if you want to do this anyway. – Hans Passant Jul 13 '18 at 11:53

0 Answers0