private IntPtr HookCallback( int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); KeyboardHookEventArgs keyHookArgs = new KeyboardHookEventArgs(vkCode); KeyIntercepted(keyHookArgs); } return(CallNextHookEx(_hookID, nCode, wParam, lParam)); }
private void KeyboardHookInstance_KeyIntercepted(KeyboardHookEventArgs keyboardEvents) { skImage myImage = null; Bitmap i; if (keyboardEvents.PressedKey == Keys.PrintScreen) { switch (CurrentMode) { case mode.FullScreen: i = skImageCapture.GetDesktopWindowCaptureAsBitmap(); myImage = new skImage(i); break; case mode.CameraMode: this.Hide(); if (!instanceCreated) { mc = new WindowLayer(); instanceCreated = true; mc.Show(); } else { WindowFrameToCapture = mc.GetWindowFrame(); i = skImageCapture.CaptureDeskTopRectangle(WindowFrameToCapture, WindowFrameToCapture.Width, WindowFrameToCapture.Height); myImage = new skImage(i); mc.Dispose(); mc = null; instanceCreated = false; } break; case mode.HighlightMode: this.Hide(); if (!instanceCreated) { mc = new WindowLayer(); instanceCreated = true; mc.Show(); } else { WindowFrameToCapture = mc.GetWindowFrame(); i = skImageCapture.GetDesktopWindowCaptureAsBitmap(); myImage = new skImage(i, WindowFrameToCapture); mc.Dispose(); mc = null; instanceCreated = false; } break; default: MessageBox.Show("unable to capture screen"); break; } if (myImage != null) { Common.ShowToastForm(myImage); } } }
void KeyboardHookInstance_KeyIntercepted(KeyboardHookEventArgs keyboardEvents) { Console.WriteLine(keyboardEvents.PressedKey); }
private IntPtr HookCallback( int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { int vkCode = Marshal.ReadInt32(lParam); KeyboardHookEventArgs keyHookArgs = new KeyboardHookEventArgs(vkCode); KeyIntercepted(keyHookArgs); } return CallNextHookEx(_hookID, nCode, wParam, lParam); }