I'm attempting to set up a system where I phone a number, and then to confirm it isn't an answering machine I want the recipient to press a phone key to forward the call. The trouble is I'm struggling to find the event that gets raised for phone key presses.
I imagine it is a tone event but nothing seems to be raising.
I could also do with knowing how to detect what key is pressed as well.
Thanks,
Ryan
These are called DTMF tones, TAPI can detect and report them via the ITDigitDetectionEvent interface.
You need to setup the appropriate event filter and tell ITLegacyCallMediaControl::DetectDigits that you are looking for DTMF.
Related
I’ve been trying to create an console application which runs in the background detecting any key ups and keydown events, I’ve seen some threads on global key hooks however, I’m unable to make it detect key ups and key downs rather then key presses.
I’d like some advice on how to go about it, any help is valued and appreciated, thank you.
Figured out a solution using GetAsyncKeyState()
I have an extended keyboard and I want to simulate the key press of a special key that switches the keyboard mode. For that I think I need to find out key code, but can't figure out how can I get it. It's an extra key on my keyboard, not part of the ConsoleKey enum, and the only functions I've found to catch keys work with this enum.
If the key does something like change the keyboard color, this will depend on whether or not there is software on the computer which can do so as well. If not, this is probably just a local switch to the keyboard and that key isn't on the keymap for the keyboard itself, ether.
If it changes something else, it will depend on if there is driver software for the device or if it uses a default Windows driver.
If it takes installed software, it's probably a custom event (like some joysticks have) and would only be found if you use a reference to a library distributed by the keyboard manufacturer.
If it does not, then the switching mode is probably a "remap" mode tied to the keyboard firmware, and just changes which KeyDown event the affected keys send. If this is true, there is no way for Windows to even see what setting the keyboard is on.
I would say the logic for the function key changes is on the keyboard itself. For instance, the Fn key on my laptop does not cast any keyboard events by itself, but when combined with certain other keys, a key code is sent to the OS with a key code that triggers certain functionality.
For instance, in my keyboard Fn + Left lowers the volume, but the virtual key sent to the OS is VK_VOLUME_DOWN (see this for a list of virtual keys.)
Good news is, you can test the keys individually to see which key codes get sent to the OS! To accomplish this, you might want to set up a low-level keyboard hook) using P/Invokes.
There's a tutorial on CodeProject that may be useful to you.
I am working on a Win CE 5 application that captures data scanned via barcode scanner. The application should support some "system-barcodes", predefinded barcodes that trigger functions of the application.
Those barcodes have to work in the whole main-frame. So I set the property "KeyPreview" of the main-frame to true and registered an KeyEventHandler on the KeyDown event of the main-frame.
My problem is, I couldn't figure out how to get the full scanned string. The string is 12 characters long and ends with a newline.
Is there a possibility to get the whole string in the EventHandler?
Thank you in advance for any help.
Most, if not all, barcode scanners based on Windows CE inject the scan data as keyboard data to the device driver. The easiest way to intercept that data in your app, where you don't have to hook up handlers to every form and worry about controls getting the keys before your processing logic is to use a keyboard hook. It works just like on the desktop, so any code you find that applies to keyboard hooks on the desktop would be valid (with the exception that the DLL containing the APIs in WinCE is coredll.dll).
There is an example of keyboard hooking for Windows Mobile on CodeProject which would probably give you the bases for everything you need. From there, it's simply string parsing in the hook handler.
Using any of the Key events by setting the Form.KeyPreview property should allow you to see the data from the scanner. But you will only see it one "key" or character at a time. Those events only handle a single character or key on each call. As far as you app could tell, it looks no different than a user smashing keys on the keyboard.
If you have the option, and can put your scanner into a non-keyboard emulation mode and hook into scan events directly, then you would probably be much more satisfied with the results in terms of how it can work independently of the GUI when used that way. Typically with devices that can do that, you will receive the entire scan as a single event.
I'd suggest including the details about the device(s) you are using so someone might be able to give you more specific advice that might be relevant for the hardware in question.
I was wondering if there was a way to detect if key strokes are from the keyboard or a SendKeys.Send call.
I would like to block specific SendKeys.Send keys but if those keys are directly from the keyboard then let them go.
Create a console application and run the code located here: http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
Create a second application that will fire SendKeys.Send when you click a button. You will notice that the first console application detects key strokes from the keyboard but not keys from SendKeys.Send
I'm sure you could you use the code from the article to detect if the keystroke came from the keyboard or SendKeys.Send
My app (in C#) need to interface with a USB bar-code scanner, which is basically working like a keyboard. It inputs the bar-code with an enter key at the end.
The app need to be work even when it's at background, so I am using low level keyboard hook to get and filter the bar-code out in the global key events. This part is already working.
Here is my problem: I don't want other apps to get the keyboard(scanner) inputs if it is a bar-code. And the normal key events should not be interfered. In one word, block the key events selectively. Is this possible?
My app is in C#, but I have no problem with C++ or more native solutions as long as it's easy to integrate in C#.
Thanks.
Additional Information:
The whole idea is working at background, even when it's not active. It watches the global key events stream and spot the bar-code sequence (already implemented with Hook). And most importantly, it do NOT interfere with normal keyboard events nor other applications' operation. That's why I cannot block all the key events or make it top-most.
I already can get the bar-code. I need to prevent other applications from getting the bar-code.
At the end of your keyboard hook you would call CallNextHookEx to execute next hook in the chain.
I would suggest that put some unique signature as a preamble for your barcode so that your keyboard hook procedure can detect it as a valid barcode input from your scanner. Now, when you get this data, just skip the call to 'CallNextHookEx' so that the chain will be discontinued and other programs won't get your barcode. Otherwise - call 'CallNextHookEx' so the chain can continue.
Note: This is my theory, I have never tried the exact same thing myself. I have however, written hooks in C++ and C#.
Check this project out
http://globalmousekeyhook.codeplex.com/
It is in C# as well so will make your coding easier. Sounds like all you need is to hook up the global key press event and suppress it by setting the Handled value or something similar.