keystroke

Generate keystrokes in Linux from Python3

筅森魡賤 提交于 2019-12-24 11:37:32
问题 I need to generate keystrokes in Linux (Raspbian) from Python3. Something like uinput but for Python3. I'd prefer not to use subprocess for this. Easier to install (apt-get) the better as it will be used in a guide to show others. Any ideas? Thomas 回答1: Found PyUserInput that works. https://github.com/SavinaRoja/PyUserInput/wiki/Installation https://github.com/SavinaRoja/PyUserInput sudo apt-get install python3-pip sudo pip-3.2 install python3-xlib sudo pip-3.2 install PyUserInput And the

Capture keystrokes for a game (python)

你离开我真会死。 提交于 2019-12-23 19:17:51
问题 Does anyone know how to capture keystrokes for a game (i.e. using the keypad to navigate a simple ascii based game where 8 = up, 2 = down, 4 left, etc... and pressing return is not necessary, moving in a single keystroke is the goal.)? I found this code, which looks like a good idea, but is over my head. Adding comments, or sending me to an article on the subject etc, would be great help. I know a lot of people have this question. Thanks in advance? try: from msvcrt import kbhit except

Cocoa: Accepting and responding to keystrokes

♀尐吖头ヾ 提交于 2019-12-23 04:53:08
问题 Hey everyone, I'm a newbie and I have what I anticipate will be a pretty easy question to answer. In order to learn a bit about event handling and drawing, I'm attempting to write a program that draws a black rectangle that increases in length every time the user hits the 'c' key. So far it just draws a black rectangle on a blue background without responding to keystrokes. Here is what I have so far: Input.h #import <Cocoa/Cocoa.h> @interface Input : NSView { int length; } - (void)keyDown:

C# keystroke interceptor when minimized

笑着哭i 提交于 2019-12-22 10:08:30
问题 Ok, so I am trying to write a program that will track my keystrokes while playing a game so that I can analyze the data later to help me improve my game. What I have been trying to do was implement a Global Hotkey Hook using user32.dll's RegisterHotKey. but this captures the keystroke completely, and the game no longer receives the keystroke. I don't know where to go from here and any pointers would be much appreciated. Here is some additional info: I am using C# .NET 4 Using Visual Studio

Java Swing KeyStrokes: how to make CTRL-modifier work

那年仲夏 提交于 2019-12-22 04:38:26
问题 In the following program, why does hitting the a key print "hello, world" while hitting CTRL + a doesn't? import java.awt.event.*; import javax.swing.*; public class KeyStrokeTest { public static void main(String[] args) { JPanel panel = new JPanel(); /* add a new action named "foo" to the panel's action map */ panel.getActionMap().put("foo", new AbstractAction() { public void actionPerformed(ActionEvent e) { System.out.println("hello, world"); } }); /* connect two keystrokes with the newly

Can JTable cell edit consume key strokes?

こ雲淡風輕ζ 提交于 2019-12-22 00:55:08
问题 In my program, there is a JMenu with many accelerators, and a JTable that is editable. Problem is, when editing the JTable, the accelerator keys still get triggered. E.g., if I enter the letter 'n' into the jtable cell, the 'next' menu option fires as well. How would one go about making the jtable cell editor consume the keystrokes exclusively? import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JTable; import

Detecting which key is pressed - is this a good way?

天涯浪子 提交于 2019-12-21 22:37:42
问题 I found a simple code on the internet a while ago... can't find the spesific site for it, but the code was made in 2005. So, I wondered if this was a good way of doing this: This is in the HTML: <body onload="document.body.focus();" onkeyup="return keypressed(event)"> When the key is up it calls this function in JavaScript: function keypressed(e) { var intKey = (window.Event) ? e.which : e.keyCode; if (intKey == 13) { // 13 = enter key //something happens if the key is clicked } // here, you

How to intercept capture TAB key in WinForms application?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 13:43:48
问题 I'm trying to capture the Tab key in a Windows Forms application and do a custom action when it is pressed. I have a Form with several listViews and buttons, I've set the Form's KeyPreview property to true and when I press any other key than tab, my KeyDown event handler does get called. But that's not true with the Tab key - I don't receive WM_KEYDOWN message even in WndProc. Do I need to set each control inside my form - its TabStop property - to false? There must be a more elegant way than

Programmatically send key strokes to a window program in Groovy or bat script

*爱你&永不变心* 提交于 2019-12-19 04:55:24
问题 Backstory: I need to programmatically find the differences between two files. I want to use WinMerge to generate a report (Tools -> Generate Report) that I can parse to get the differences between two files. I need this done using either a Groovy script or a bat script. I was hoping that WinMerge would offer command line options to generate the report and then I could just use a Groovy Process object to execute WinMergeU.exe with the arguments. No such luck according to the command options I

Simulate “Windows” key and “+” key to zoom in

笑着哭i 提交于 2019-12-19 04:05:08
问题 Windows 7 (finally) has built-in zoom feature for the screen. Hold down the "Windows" key and you can then use the "+" key to zoom in and the "-" key to zoom out. As a result I have been trying to simulate this combination. With AutoIt I have tried: 1) Send("{LWINDOWN}" & "+" & "{LWINUP}") 2) $x = Chr(43) Send("{LWINDOWN}" & $x & "{LWINUP}") 3) Send("#{+}") ;//works but it also sends "+" key 4) Send("{LWINDOWN}") Sleep(10) Send("+",1) Sleep(10) Send("{LWINUP}") None of those 4 steps work... I