keystroke

What is the difference between registerKeyboardAction(…) and getInputMap().put(…) + getActionMap().put(…)?

落花浮王杯 提交于 2021-02-07 18:46:29
问题 What is the difference between these two methods: getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke( "pressed F10"), "someAction"); getActionMap().put("someAction", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //Do something } }); and: registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Do something } }, KeyStroke.getKeyStroke("pressed F10"), JComponent.WHEN_FOCUSED); 回答1: There is no difference,

Why clipboard.setdataobject doesn't copy object to the clipboard in C#

女生的网名这么多〃 提交于 2021-01-29 18:21:55
问题 I have a win app (C#) that use clipboard to send and receive data to/from other applications. for example I want to use Word app in windows, I copy a text using c# to the clipboard, but when i want to simulate paste key (Stroke Ctrl+v) in c# , the clipboard is empty and i just got "v" as result. To copy to the clipboard i use the following code: public static void CopyToClipboard(string textForCopyToClipBoard) { Clipboard.Clear(); Clipboard.SetDataObject( textForCopyToClipBoard, true, 5, 200)

converting a string to Keys in C#

拜拜、爱过 提交于 2021-01-27 14:56:57
问题 Lets say we store KeyCode value as a string. How do you convert it back to KeyCode? For example, I've captured a key on keydown event: string modifier = e.Modifiers.ToString(); // Control string key_string = e.KeyCode.ToString(); // D1 How to do the following ? Keys old_key_restored = (Keys)key_string; Code above doesn't work. EDIT: Daniel is a life savior ;) Keys key_restored = (Keys) Enum.Parse(typeof(Keys), key_key); 回答1: Its just an enum so you can use Enum.TryParse 来源: https:/

converting a string to Keys in C#

倖福魔咒の 提交于 2021-01-27 14:35:53
问题 Lets say we store KeyCode value as a string. How do you convert it back to KeyCode? For example, I've captured a key on keydown event: string modifier = e.Modifiers.ToString(); // Control string key_string = e.KeyCode.ToString(); // D1 How to do the following ? Keys old_key_restored = (Keys)key_string; Code above doesn't work. EDIT: Daniel is a life savior ;) Keys key_restored = (Keys) Enum.Parse(typeof(Keys), key_key); 回答1: Its just an enum so you can use Enum.TryParse 来源: https:/

AppleScript Application is not allowed to send keystrokes

感情迁移 提交于 2020-12-29 10:55:23
问题 I made an app with AppleScript called FRIDAY. When I tell it to 'open chrome', it opens google chrome, this is working on Script Editor and out side of script editor. I can also tell it to 'open a new tab' and it opens a new tab using keystrokes: -- this boolean is the reason this script keeps runing set condition to false say "Welcome sir" set commands to {"what is todays date", "what time is it", "what is the time", "what day is it", "what month is it", "which month is it", "friday you up",

Simulate keystroke in Linux with Python

非 Y 不嫁゛ 提交于 2020-03-07 07:12:26
问题 How can I simulate a keystroke in python? I also want to press multiple keys simultaneously. Something like: keystroke('CTRL+F4') or keystroke('Shift+A') 回答1: Although it's specific to X, you can install the xautomation package ( apt-get install xautomation on Debian-based systems) and use xte to simulate keypresses, e.g.: from subprocess import Popen, PIPE control_f4_sequence = '''keydown Control_L key F4 keyup Control_L ''' shift_a_sequence = '''keydown Shift_L key A keyup Shift_L ''' def

Simulate keystroke in Linux with Python

不羁岁月 提交于 2020-03-07 07:10:00
问题 How can I simulate a keystroke in python? I also want to press multiple keys simultaneously. Something like: keystroke('CTRL+F4') or keystroke('Shift+A') 回答1: Although it's specific to X, you can install the xautomation package ( apt-get install xautomation on Debian-based systems) and use xte to simulate keypresses, e.g.: from subprocess import Popen, PIPE control_f4_sequence = '''keydown Control_L key F4 keyup Control_L ''' shift_a_sequence = '''keydown Shift_L key A keyup Shift_L ''' def

Java: Use keystroke with arrow key

怎甘沉沦 提交于 2020-01-28 09:50:59
问题 I have some code that I need to modify. In the code, the original author uses KeyStroke.getKeyStroke to take user input. In this code, for example, he uses a instead of left arrow. I want to change this, but I don't know how. Here is the original code: registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { tick(RIGHT); } }, "right", KeyStroke.getKeyStroke('d'), WHEN_IN_FOCUSED_WINDOW ); I have to change it to something like this, but when run, it doesn't

Autohotkey wrong keystrokes sent to console

你离开我真会死。 提交于 2020-01-24 06:27:27
问题 I am trying to understand this bug and I am looking for a workaroud. Using this script: #NoEnv #SingleInstance force SendMode Input ;Alt+t to send keystrokes !t::Send, /[] It send the correct keystrokes / [ ] to all windows but the windows console (cmd) Additional Info: Using autohotkey v1.1.09.02 With an english US keyboard layout, it sends: ' 9 0 With a french canadian multilingual keyboard layout, it sends: é ^ ç Any idea of what can fix it? 回答1: Try this: #NoEnv #SingleInstance force

Inject a keystroke in java

妖精的绣舞 提交于 2020-01-14 10:44:12
问题 I'm looking for a way to inject a keystroke into the OS keyboard input buffer, like when you click a button the program inserts one (or more) keyboard strokes. I wanted to do this in java because I want to run this in (win,linux and osx). I guess that I'll have to make use of the JNI, do anyone have some ideas? Thanks all stackoverflowers ;) 回答1: My guess is that the java.awt.Robot class will do this for you: new Robot().keyPress(...); http://download.oracle.com/javase/6/docs/api/java/awt