keypress

keyPressed event slow on first repeat

冷暖自知 提交于 2020-01-04 04:27:09
问题 Okay so I am sorry for this being a really weird question but it is driving me insane. I handle my WASD movement for my game via: Action ClassWASDKeyPressed = new ClassWASDKeyPressed(); Action ClassWASDKeyReleased = new ClassWASDKeyReleased(); BitKeys movementBitKeys = new BitKeys(); //for WASD movement key pressed/releases //pressed theDesktop.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("W"), "wButtonPress"); theDesktop.getActionMap().put("wButtonPress",

PictureBox throws “Parameter is not valid” ArgumentException upon tab keypress

谁都会走 提交于 2020-01-03 17:38:06
问题 I have a form where the user can first scan to a bitmap. When scan is done, and the bitmap is loaded, I have 4 text boxes that are then enabled. Next to each text box, I have a button called "Cut from image". When the user clicks the button, they can click and drag in the bitmap to get the selected text using MODI. This works perfect except for one annoying bug: When I click a "Cut from image" button and drag a square, it gets the information nicely to the text box. Then, if i click to the

How to programmatically simulate arrow key presses in Java FX

∥☆過路亽.° 提交于 2020-01-03 09:57:12
问题 I want to make my JFX application simulate arrow key presses (when they are registered in a TextField), but I can't figure out how to send anything other than Strings or bytes. I'm imagining something like this: static EventHandler<KeyEvent> KEY() { E = new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode().equals(KeyCode.UP)) { try { //someObject.SimulateKeyPress(KeyCode.UP); //OR //coolObject.SendKey((char)KEY_UPKEY)); } catch (Exception ex) { //Teleport

Playing piano keys after delay in JavaScript

十年热恋 提交于 2020-01-02 17:15:33
问题 I was trying to write a script to 'play' some keys on this online keyboard by using JavaScript to 'click' the keys for me. The code //sample array to iterate over var keys_ = ['et', 'dst', 'et', 'dst', 'et', 'b', 'dt', 'ct', 'a', ...]; //handles the clicking only function playKey(id_) { key_ = document.getElementById(id_); key_.click(); } //iterates over the array function playKeys(keys_) { delay = 1000; for (i = 0; i < keys_.length; i++) { console.log(delay); key_ = keys_[i]; console.log(key

Help: Maximum number of clients reached - Segmentation fault

吃可爱长大的小学妹 提交于 2020-01-01 10:59:24
问题 I want to simulate many key press events. I found a solution by using XTestFakeKeyEvent , but when I simulate more than 210 times my program raises a "Maximum number of clients reached" segmentation fault. I don't known how to solve this problem. My code here: #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/extensions/XTest.h> #include <stdio.h> #define PRESS_UP 0 #define PRESS_DOWN 1 #define PRESS_LEFT 2 #define PRESS_RIGHT 3 #define PRESS_ENTER 4 #define PRESS_ESC 5 #define

Help: Maximum number of clients reached - Segmentation fault

烈酒焚心 提交于 2020-01-01 10:59:02
问题 I want to simulate many key press events. I found a solution by using XTestFakeKeyEvent , but when I simulate more than 210 times my program raises a "Maximum number of clients reached" segmentation fault. I don't known how to solve this problem. My code here: #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/extensions/XTest.h> #include <stdio.h> #define PRESS_UP 0 #define PRESS_DOWN 1 #define PRESS_LEFT 2 #define PRESS_RIGHT 3 #define PRESS_ENTER 4 #define PRESS_ESC 5 #define

How to associate pressing “enter” with clicking button?

这一生的挚爱 提交于 2020-01-01 08:47:26
问题 In my swing program I have a JTextField and a JButton. I would like for, once the user presses the "enter" key, the actionListener of the JButton runs. How would I do this? Thanks in advance. 回答1: JRootPane has a method setDefaultButton(JButton button) that will do what you want. If your app is a JFrame, it implements the RootPaneContainer interface, and you can get the root pane by calling getRootPane() on the JFrame, and then call setDefaultButton on the root pane that was returned. The

How to associate pressing “enter” with clicking button?

天涯浪子 提交于 2020-01-01 08:47:16
问题 In my swing program I have a JTextField and a JButton. I would like for, once the user presses the "enter" key, the actionListener of the JButton runs. How would I do this? Thanks in advance. 回答1: JRootPane has a method setDefaultButton(JButton button) that will do what you want. If your app is a JFrame, it implements the RootPaneContainer interface, and you can get the root pane by calling getRootPane() on the JFrame, and then call setDefaultButton on the root pane that was returned. The

Detect specific keypresses in GUI

那年仲夏 提交于 2019-12-31 07:11:30
问题 I'm looking for a way in Gtk/Python to have an app listen for keypresses and when some of the special keys are pressed, perform an action (recreate a menu with different labels, since it's an appindicator). I can't really find a way to do it though. If anyone is able to help, I'd be thankful. 回答1: You probably need to handle the "key-press-event" (and probably also "key-release-event") of GtkWidget. PyGtk knows about it. It should be inside some "windowing" widget, so you may need to use

C# p/Invoke How to simulate a keyPRESS event using SendInput for DirectX games

北城余情 提交于 2019-12-31 06:57:33
问题 I've often struggled with simulating keyboard press events for various bots, or other GUI automating programs. I've managed to simulate keydown events using: INPUT[] kInput = new INPUT[1]; kInput[j].type = SendInputEventType.InputKeyboard; kInput[j].mkhi.ki.wVk = 0; kInput[j].mkhi.ki.wScan = (ushort) MapVirtualKey((uint) Keys.D5, 0); kInput[j].mkhi.ki.dwFlags = KeyboardEventFlags.SCANCODE; kInput[j].mkhi.ki.time = 0; kInput[j].mkhi.ki.dwExtraInfo = IntPtr.Zero; SendInput(1, kInput, Marshal