protected void OnKeyHookEvent(KeyHookEventArgs e) { KeyHookEvent(this, e); }
private void dispatcherTimer_Tick(object sender, EventArgs e) { short sAlt = GetAsyncKeyState(0x12); /* Check if alt is held */ if (sAlt < 0) { /* Test keys from 1 to 5, raise event if pressed */ for(short key = 0x31; key <= 0x35; key++) { if (GetAsyncKeyState(key) != 0) { KeyHookEventArgs args = new KeyHookEventArgs((short)(key - 0x30)); OnKeyHookEvent(args); break; } } } }
void hook_KeyHookEvent(object sender, KeyHookEventArgs e) { int clipboard = e.Key - 1; CloseCBViewer(); // Update clipboards to current clipboard text clipboards[currentClipboard] = Clipboard.GetText(); // Change old clipboard preview to default text color ((TextBox)FindName("clipboard" + currentClipboard)).Foreground = new SolidColorBrush(Colors.Black); // Change new clipboard preview to highlighted text color ((TextBox)FindName("clipboard" + clipboard)).Foreground = new SolidColorBrush(Colors.Red); // Load the new clipboard if (clipboards[clipboard] != null) { Clipboard.SetText(clipboards[clipboard]); } else { //Set clipboard to empty if nothing exist in saved clipboards. Clipboard.SetText(""); } currentClipboard = clipboard; showClipboardPreview(); InitCBViewer(); }