I need to to process keyboard events in TextBox controls (and other UI elements) in Windows RT, but have some problems. For example, the KeyDown event handler seems not to be fired in the TextBox when the backspace key is pressed (CoreWindow::KeyDown fires, though, but that has other problems described below).
I've been trying to find good resources on how keyboard event handling is dealt with in Windows RT, but haven't found any but lightweight documentation on the topic (eg. which classes exists etc). Any pointers to samples and other resources on this topic would be greatly appreciated.
In particular, I'd like to learn how keyboard events are processed in general in Windows RT, to answer questions such as "Why does my TextBox::KeyDown event fire before my CoreWindow::KeyDown event?".
Though I haven't found any resources on the topic, I have found a solution to some of the problems I had. I'm posting it here for future reference hoping that it'll help others.
How to capture backspace, arrow-keys and other keypresses in a TextBox
Subclass the textbox and override OnKeyDown(). If you don't call the superclass implementation, the KeyDown event will now be fired on most (if not all) keypresses, but you probably don't want to bypass all the internal keyboard handling of the TextBox, so beware. Best is to put your logic in the override and call the superclass implementation.
Related
I am currently developing a screen reader friendly drag and drop, and I was wondering if it is possible to trigger some kind of buzz noise, when some actions are not possible. E.g.: The user is on the first item and presses "arrow left". Of course, I could use normal Text, but I am curious.
Thanks in advance!
If you can detect that you can't move an item to the left anymore, you can play a sound using normal javascript with the Audio object and the play() method.
Whether someone is using a screen reader is irrelevant. There are a variety of reasons why someone might be using a screen reader but since you can't detect if one is being used, you shouldn't base your logic on screen reader usage.
An aria-live region is not necessary in this case.
I've been looking around for a few weeks trying to find a library to help fit my needs.
I'm looking for a way to create what would be as a secondary virtual keyboard / mouse cursor. It doesn't necessarily have to be visible per se, but the idea behind it is that I want to be able to have my normal cursor and keyboard free to be used, while the secondary virtual keyboard and mouse are used for automation in another window.
I'm not entirely sure where to begin on this journey... Any ideas, stackoverflow community?
I'm trying to send keystrokes of regular keyboard input from 'a-z' which may or may not include the directional arrow keys to a running game process, however i'm confused at the pywinauto documentation:
I've already connected the existing process via pid by:
from pywinauto.application import Application
from pywinauto.keyboard import SendKeys
app = Application().connect(process=1234)
#app.SendKeys('a')? Doesn't seem to work
I've read some other answers on this but it's not very clear as to what the next step is on the documentation, there aren't any real examples.
I've also read from some other answers that SendKeys auto focuses the windows, which isn't want I want, if possible would it be possible to send keystrokes to the process silently?
There are few moments. If the game process has its own window with native handle, you may try the following:
app.window(title="Window title").send_keystrokes("something")
app.window(title="Window title").send_chars("something")
It should work even for minimized window. The difference may appear for special symbols which may not work for some of these methods or even for both. But arrows should probably work with send_keystrokes.
If it's DirectX game, sending keys might be more complicated task. A while ago I found some references about potential implementation of this: https://github.com/pywinauto/pywinauto/issues/469 Though I had no chance to try it yet.
I have tried hard to find a C/C++ library to simulate mouse events in Linux, but cannot find one. Can someone suggest an easy library for the same?
There are two methods:
You can generate "synthetic" events
The mouse buttons are handled very similar to keys on the keyboard, so it should be simple to adapt this code. Note that applications can find out about this by looking at the IsSynthetic field in the event. Xterm for example ignores synthetic events for security reasons.
You can use the XTEST extension.
This allows sending events with IsSynthetic set to False, and hence full simulation, but the extension is normally disabled or restricted.
This is a similar problem: Link
Which was solved by calling GetAsyncKeyState(). While all fine and dandy, I need a Linux alternative. I need to know if a button is being held down, not just being pressed (because of the keyboard buffer delay). Does anything like this exist in the OpenGL/Glut libraries, or will I have to look elsewhere?
I have never used Glut, but I know that many people will say SDL is better. I have used SDL and I like it a lot. It does everything Glut does and a lot more. In SDL, you can use SDL_PollEvent() to get key state without the keyboard buffer delay.
Edit: I know almost nothing about Glut, but it looks like you can use glutKeyboardFunc to detect normal keys, and glutSpecialFunc for keys that do not generate ASCII characters (such as shift). I'm not sure if there is a better way, as this doesn't seem very nice.
You can detect when a keypress event occurs, record that state, and then listen for a key release event.
As said, you will have to make your own state machine, which is easy. But you also need to use this callback method I think.
http://pyopengl.sourceforge.net/documentation/manual/glutKeyboardUpFunc.3GLUT.xml