protected override void exec() { if (help_option) { return; } Console.WriteLine("Sending a synthetic KeyPress..."); KeyPress key_event = new KeyPress(display); key_event.set_window(window); key_event.set_detail(display.input.keysym_to_keycode('t')); window.send_event(false, Event.NO_EVENT_MASK, key_event); Console.WriteLine("Sending a synthetic ButtonPress to exit..."); ButtonPress button_event = new ButtonPress(display); key_event.set_window(window); window.send_event(false, Event.NO_EVENT_MASK, button_event); while (!exit_now) { dispatch_event(); Console.WriteLine("Received: " + evt); } display.close(); }
public void send_key(Window window, int keysym) { bool capital = keysym >= 'A' && keysym <= 'Z'; // keysym of corresponding small letter int small_keysym = !capital ? keysym : keysym + ('a' - 'A'); KeyPress key_event = new KeyPress(display); key_event.set_window(window); key_event.set_detail(display.input.keysym_to_keycode(small_keysym)); if (capital) { key_event.set_state(gnu.x11.Input.SHIFT_MASK); } window.send_event(false, Event.NO_EVENT_MASK, key_event); }