static void Main(string[] args) { KeyboardHook kb = new KeyboardHook(); kb.Hook(); ImgurUploader upper = new ImgurUploader(); while (true) { Image img = ThreadMsgQueue <Image> .Dequeue(); Uri res = upper.UploadImage(img, ImageFormat.Jpeg); System.Windows.Forms.Clipboard.SetText(res.AbsoluteUri); } }
private IntPtr LowLevelKeyboardHook(int nCode, IntPtr wParam, IntPtr lParam) { WindowsMessage msg = (WindowsMessage)wParam; bool cntrlPressed = (Win32ApiWrapper.GetAsyncKeyState((int)VirtualKeyCode.VK_CONTROL) & 0x8000) != 0; if (nCode >= 0 && msg == WindowsMessage.WM_KEYUP) { KBDLLHook d = (KBDLLHook)Marshal.PtrToStructure(lParam, typeof(KBDLLHook)); if (d.vkCode == (int)VirtualKeyCode.VK_INSERT && cntrlPressed) { ThreadMsgQueue <Image> .Enqueue(generator.GetFocusedWindowImage()); } } return(Win32ApiWrapper.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)); }