Is there a way to simulate touch events in Windows 8 (and preferably in windows 7).
I know there is a project called Multi touch vista but I feel its a bit overkill and I never got it working correctly with multiple screens.
What I want to do is very simple, I want to start an app that can send touch events to Windows no need for multiple mice or any thing like that.
Can it be done or do I need a (MMV) driver to do that?
Thanks
/Jimmy
I was looking for something similar and found this article Simulating Touch Input in Windows Developer preview using Touch Injection API and sample code (C++) may answer your question. However, this seems to work only on Windows 8 (not Windows 7).
It simulates Tap, Hold, Drag, Pinch/Pan, Rotate and Cross-Slide.
Here is the touch (Tap) code:
POINTER_TOUCH_INFO contact;
InitializeTouchInjection(1, TOUCH_FEEDBACK_DEFAULT); // Here number of contact point is declared as 1.
memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
contact.pointerInfo.pointerType = PT_TOUCH;
contact.pointerInfo.pointerId = 0; //contact 0
contact.pointerInfo.ptPixelLocation.y = 200; // Y co-ordinate of touch on screen
contact.pointerInfo.ptPixelLocation.x = 300; // X co-ordinate of touch on screen
contact.touchFlags = TOUCH_FLAG_NONE;
contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
contact.orientation = 90; // Orientation of 90 means touching perpendicular to screen.
contact.pressure = 32000;
// defining contact area (I have taken area of 4 x 4 pixel)
contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
InjectTouchInput(1, &contact); // Injecting the touch down on screen
contact.pointerInfo.pointerFlags = POINTER_FLAG_UP;
InjectTouchInput(1, &contact); // Injecting the touch Up from screen
Another article: Getting Started with Windows Touch Gestures
I haven't had a chance to try it myself, but according to this article, the simulator included with the Windows 8 Dev Preview allows for simulating multi-touch zoom and rotation gestures using a mouse.
You can see a demonstration of this at approximately 35:40 of this BUILD conference session: Tools for building Metro style apps
Further to the solution which points to the C++ Sample code for InjectTouchInput which comes packaged in the User32.dll of Windows 8, the C# solution can be found here:
InjectTouchInput Windows 8 C# not working (returns false)
Creating a virtual Hid driver appears to be the only way.
Related
Am recording the video by intel real sense camera. The video recording is done and working successfully. But audio is not coming in that video.
For that my question is...
My configuration is Lenovo Yoga 15 with internal real sense camera
I want to install audio driver for sound ? Is that are required ?
please give me some suggestion.
session = PXCMSession.CreateInstance();
senseManager = session.CreateSenseManager();
senseManager.captureManager.SetFileName("new4.rssdk", true);
senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, WIDTH, HEIGHT, 30);
senseManager.Init();
for (int i = 0; i < 200; i++)
{
if (senseManager.AcquireFrame(true).IsError()) break;
PXCMCapture.Sample sample = senseManager.QuerySample();
senseManager.ReleaseFrame();
colorBitmap.Dispose();
}
I didn't understand the question well, so do you want to run audio and record the video together?
If yes, you have to create an instance of the class responsible for doing that.
take a look here Speech Recognition
I used two threads in order to do that. I have an application where I use facial recognition and audio recognition. I decided to split them and it worked very well.
I've got real device Nokia Lumia 730 (windows phone 8.1) for testing my game cocos2d-x. And I've discovered multitouch doesn't work.
First of all sample code:
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesBegan = [&](std::vector touches, Event* event){
log("onTouchesBegan: %d", touches.size());
}
listener->onTouchesMoved = [&](std::vector touches, Event* event){
log("onTouchesMoved: %d", touches.size());
}
listener->onTouchesEnded = [&](std::vector touches, Event* event){
log("onTouchesEnded: %d", touches.size());
}
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
No matter how many fingers I'm touching it always says 1.
I ran the same app on Android (samsung galaxy s3) and it's working well.
As I found out there's no need/no way to enable multitouch on windows phone and it's already enabled by default.
Second, I made simple test inside my win8.1-xaml project (didn't test win8.1-universal, can't use it anyway, because of lacking 3rd party libs support like admob):
Touch.FrameReported += Touch_FrameReported;
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
if (Visibility == Visibility.Collapsed)
return;
TouchPointCollection pointCollection = e.GetTouchPoints(this);
Debug.WriteLine("points touched: " + pointCollection.Count);
}
And this actually works and prints correct values.
So running these 2 pieces of code at the same time produces for example this:
onTouchesBegan: 1 <-- cocos2d-x part
points touched: 2 <-- c# project part
Cocos thinks there's only one touch, however wp knows there's more (2).
Help!
I am creating a windows Phone 8.1 application with the Geo Location. The code works, well pretty much, the one thing that I have noticed in the simulator, if the phone does not reside in the Geo-Fenced area for a 2 .. 3 .. seconds the background code does not fire even though I create my dwell time with no parameters.
MonitoredGeofenceStates mask = 0;
mask |= MonitoredGeofenceStates.Entered;
var geocircle = new Geocircle(position, 100);
gFence = new Geofence(ID, geocircle, mask, false);
I found the following blog but it was not that useful
http://blogs.windows.com/buildingapps/2014/02/25/testing-and-debugging-your-geofencing-apps/
How often does a phone or device check if its in a Geo fenced area? I would like to tell my users for their geo-fence to be active they must reside in the geo-fenced area for a minimum of x seconds...
My team built a WPF (C#) Application that integrates with Media Center to show a video in the center of a dashboard. Essentially, the application begins recording a TV channel via Media Center, waits 10 seconds and begins playing back the file as it is being recorded. In the year since the application has launched, we have had roughly 50 help desk tickets created, 45 of which are specifically for the Media Center integration and setup.
We have determined that we need to make a major change in the implementation and architecture to remove the Media Center application all together and try to show the feed from the TV tuner directly, like you would a web cam. Unfortunately, nobody on the team here has done this before nor can we find any resources or samples of this being done.
I'm looking for working code samples that can take the stream from the TV tuner and show it in Windows Form or WPF application. I'd even be willing to buy 3rd party components out there or software. Heck, I'd even be willing to pay someone that knows how to do this to do just that!
Can you please point me in the right direction?
CODE FOR VIDEO
<MediaKit:MediaUriElement x:Name="MediaContainer" Volume="1"
Stretch="Uniform" HorizontalAlignment="Center"
UnloadedBehavior="Manual" LoadedBehavior="Play"
Height="820.00020739959" Width="1393.843"/>
CODE FOR RECORDING VIDEO
DeletePreviousRecordings();
MediaCenterControl mcc = new MediaCenterControl();
mcc.StopAllRecordings();
DateTime recordingStartTime;
DateTime endTime = DateTime.Now.Subtract(TimeSpan.FromDays(1));
int loopCount = 0;
do
{
if (loopCount++ >= 5)
{
// TODO: Show error
break;
}
recordingStartTime = DateTime.Now;
RecordingEndTime = recordingStartTime.AddMinutes(RecordDuration);
} //loop count was added below so it knew not to throw until five shots have been missed # scheduling.
while ((endTime = mcc.RecordMedia(recordingStartTime, Settings1.Default.RecordChannel, RecordDuration, loopCount)) < DateTime.Now);
if (endTime > DateTime.Now)
RecordingEndTime = endTime;
}
This can definitely be done but you would have to narrow down to one tv tuner. I actually have this working using the WinTV-HVR-1950. It took me a while but you have to get down and dirty with the hauppage drivers to get the signal and send it to the application. I'll have to look up that code but I think I may have your solution.
I wanted to know, what would the coding be if I wanted to toggle mute/unmute of my microphone. I am making a program that can run in the background and pickup a keypress event and toggle mute/unmute of the mic. Any help with any of that coding would be very helpful. I am pretty new to C#, and this is just a really simple program I wanted to make. That is all it does, is it will listen for keypress of the spacebar, even when the program is in the background, then when the spacebar is pressed it will mute/unmute the mic.
Thank you for any and all help!
For Windows Vista and newer, you can no longer use the Media Control Interface, Microsoft has a new Core Audio API that you must access to interface with audio hardware in these newer operating systems.
Ray Molenkamp wrote a nice managed wrapper for interfacing with the Core Audio API here:
Vista Core Audio API Master Volume Control
Since I needed to be able to mute the microphone from XP, Vista and Windows 7 I wrote a little Windows Microphone Mute Library which uses Ray's library on the newer operating systems and parts of Gustavo Franco's MixerNative library for Windows XP and older.
You can download the source of a whole application which has muting the microphone, selecting it as a recording device, etc.
http://www.codeguru.com/csharp/csharp/cs_graphics/sound/article.php/c10931/
you can use MCI (Media Control Interface) to access mics and change their volume system wise. Check the code below it should be setting volume to 0 for all system microphones. Code is in c; check pinvoke for details on how to translate this code to c#
#include "mmsystem.h"
...
void MuteAllMics()
{
HMIXER hmx;
mixerOpen(&hmx, 0, 0, 0, 0);
// Get the line info for the wave in destination line
MIXERLINE mxl;
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mixerGetLineInfo((HMIXEROBJ)hmx, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
// find the microphone source line connected to this wave in destination
DWORD cConnections = mxl.cConnections;
for (DWORD j=0; j<cConnections; j++)
{
mxl.dwSource = j;
mixerGetLineInfo((HMIXEROBJ)hmx, &mxl, MIXER_GETLINEINFOF_SOURCE);
if (MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE == mxl.dwComponentType)
{
// Find a volume control, if any, of the microphone line
LPMIXERCONTROL pmxctrl = (LPMIXERCONTROL)malloc(sizeof MIXERCONTROL);
MIXERLINECONTROLS mxlctrl =
{
sizeof mxlctrl,
mxl.dwLineID,
MIXERCONTROL_CONTROLTYPE_VOLUME,
1,
sizeof MIXERCONTROL,
pmxctrl
};
if (!mixerGetLineControls((HMIXEROBJ) hmx, &mxlctrl, MIXER_GETLINECONTROLSF_ONEBYTYPE))
{
DWORD cChannels = mxl.cChannels;
if (MIXERCONTROL_CONTROLF_UNIFORM & pmxctrl->fdwControl)
cChannels = 1;
LPMIXERCONTROLDETAILS_UNSIGNED pUnsigned = (LPMIXERCONTROLDETAILS_UNSIGNED)
malloc(cChannels * sizeof MIXERCONTROLDETAILS_UNSIGNED);
MIXERCONTROLDETAILS mxcd =
{
sizeof(mxcd),
pmxctrl->dwControlID,
cChannels,
(HWND)0,
sizeof MIXERCONTROLDETAILS_UNSIGNED,
(LPVOID) pUnsigned
};
mixerGetControlDetails((HMIXEROBJ)hmx, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
// Set the volume to the middle (for both channels as needed)
//pUnsigned[0].dwValue = pUnsigned[cChannels - 1].dwValue = (pmxctrl->Bounds.dwMinimum+pmxctrl->Bounds.dwMaximum)/2;
// Mute
pUnsigned[0].dwValue = pUnsigned[cChannels - 1].dwValue = 0;
mixerSetControlDetails((HMIXEROBJ)hmx, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
free(pmxctrl);
free(pUnsigned);
}
else
{
free(pmxctrl);
}
}
}
mixerClose(hmx);
}
here you can find more code on this topic
hope this helps, regards
I have several microphones in win7 and class WindowsMicrophoneMuteLibrary.CoreAudioMicMute is incorrect in this case.
so I change the code and works great because now his cup Whistle all microphones and not just in the last recognized by win7.
I am attaching the new class to put in place.
http://www.developpez.net/forums/d1145354/dotnet/langages/csharp/couper-micro-sous-win7/