How to efficiently react to touch events in Windows RT - c#

This might be a dumb question but I'm not familiar with XAML.
I'm implementing a RTP-MIDI client Library for Windows Store Apps and would like to investigate and troubleshoot potential latency and performance problems.
I've written a quick dummy application with a couple of buttons to send MIDI events to an musical instrument over the network using my Library. In that scenario, I find that my Library is able to process a single basic MIDI event in under 10ms over the network, but I find that the delay between the time I press a button on the UI and the time where my Library is instructed to send an event is very high.
Ideally, I would like to react to a "touch pressed" event and instantly send a MIDI event as well as a "touch released" event and instantly send the corresponding MIDI event.
I could not find such events on the regular button controls. Ideally, I would like to achieve the highest performance possible from the UI, even with a single button, in order to eliminate this source of problems in my performance assessment.
Is there a way I could react to the screen being touched "in real time" like a game, for instance?

The most basic access to various pointer events (such as tapping, clicking) are available through a series of lower level events, with these being directly related to your question:
PointerPressed
PointerReleased
PointerPressed should be the equivalent of MouseDown for example in a traditional application as it fires early, and before any translation into a higher level event (such as Click) has occurred.
The PointerReleased would be the equivalent of MouseUp. If you're relying on the PointerReleased event, you'll want to take note of the fact that the event isn't necessarily fired as a pair with the PointerPressed event, as there are a number of conditions where it may not fire. The documentation has the details.

Related

C# Hooking specific Keyboard keystroke and stop system propagation

I have an application where I have multiple keyboards connected through USB.
I need to hook a specific keyboard to get the keypress directly into the software, even if this one is not on the foreground. This so far works based on this project. The other keyboards shall work as normal.
Although it seems by using Direct Input, it is not possible to stop propagation (we don't want other apps to get that particular keyboard input).
Concerning Global Hook, it can block the keypress system-wise, but it is impossible, as far as I know, to identify the source of the keystroke (which keyboard it is from) and thus to selectively block them.
There is another project, here, that combines the two, but it is quite messy and heavy.
Is there a better way to achieve this? I am surprised that simple task is so complex.
If you are going to make the app windows only, you should look into Windows raw input api
It isn't that complicated.

Is there a way to get rid of the short pause in reaction after you press a key for the first time and hold it down?

I'm trying to make a game in WPF, C# where it would be crucial to have quick movements with the keyboard. Does anyone know how to get rid of the said phenomena?
What you are likely seeing in terms of a 'delay' is the keyboard repeat delay, which is controlled by the operation system (see Control Panel -> Keyboard).
You will probably have better luck working with the KeyDown and KeyUp attached events. https://msdn.microsoft.com/en-us/library/system.windows.input.keyboard.keydown(v=vs.110).aspx
By handing these events, you can handle repeating the functionality as frequently as you want until the KeyUp event is received.

How to trigger same event on every page of the WPF App using MVVM Light

Our application is implemented in WPF using MVVM Light.
We are replacing our old magnetic card reader which is currently a serial one with a USB HID-KB.
Serial card reader were easy since we had serial port events to trigger the incoming messages, we had no problem in handling these. But with USB card reader, the events are that of a normal keyboard. By the way, the card reader does not have vendor specific API, this a generic USB device.
As of now the solution is to capture a keydownevent in the view and handle the business logic on the viewmodel.
But the problem here is that the end user can swipe the card irrespective on whatever page he/she is on. We should be able to capture that swipe event. The only option I currently have is that I need to wire this keydownevent on every view as mentioned above.
Is there any way in MVVMLight or WPF that can declare an event on the global level, that can be triggered from every view.
Any pointers will be highly appreciated.
Thanks,
The solution is very simple.
Why don’t you handle the event in a common file, like the base file. Normally we handle application close events in such base files which will always be active. The thing is I have some conditions to check while the application is closing. So I handle the event in the common base file and do the condition checking there.
Please try that and let me know the result..

Capture all Windows 7 Touch events, not just on my form when it has focus

I have an application which has a form, but the fact that it has a form is irrelevant.
With this app, I need to listen to all Operating System level Touch events. Basically I need to capture that the screen has been touched no matter which form has focus, gather all the info like coordinates etc. and then do whatever with it.
I'll actually be sending it on to another app via a Windows Message but that's not relevant either. I just need to know how to listen and capture ALL OS level touch + drag events etc.
You can read HID data directly, using a Raw Input API and to parse it by yourself.
In general:
Find Hids and store preparsed data.
Register for input events
On WM_INPUT event parse buffer using HID API functions and preparsed data.
This link explains the topic of keyboard/mouse event hooks.
It is a rather advanced subject however, filled with lots of low-level interop. I'd avoid such a task and try to come up with a different solution for this. What is your final goal with this application?

C#: Record and Playback GUI Events

how can i record and playback mouse and keybaord events.
i need this to capture the user interactions with my application so that later on i can play to see what user did.
There are literally hundreds of keyboard / mouse automation apps out there:
http://www.nonags.com/nonags/auto.html
I recommend Do It Again - its free, easy to use and works well, although if I remember correctly it has a quirk where it doesn't work particularly well over a remote desktop connection.
UPDATE: Just re-read the question, I dont think what you want is the ability to record keyboard / mouse actions, as its not guarenteed that the application will "keep up" with the mouse clicks (windows could open in slightly different places, or there could be a slight delay etc...)
What you want is some screen capture software.
You should hook keyboard and mouse events, see Processing Global Mouse and Keyboard Hooks in C# , Low-Level Mouse Hook in C# or Processing Global Windows Mouse and Keyboard Hooks in C#

Categories

Resources