Hi.
How to simulate(automa tic) mouse movements and click operation using c#.
Actually, i got pixels in the face (face tracking) right now and i need to move mouse(automatic ally, without using mouse manually) i.e., simulate mouse click operation using those pixels in c#.
I think we can use robot() class in java , to achieve this, but how can we do this using c#.
Hope you understand my problem and get bck to me asap.
thanx
bye
3 34827
Hi.
How to simulate(automa tic) mouse movements and click operation using c#.
Actually, i got pixels in the face (face tracking) right now and i need to move mouse(automatic ally, without using mouse manually) i.e., simulate mouse click operation using those pixels in c#.
I think we can use robot() class in java , to achieve this, but how can we do this using c#.
Hope you understand my problem and get bck to me asap.
thanx
bye
Have find the solution of your problem.
Actually i am facing the same problem now a days.
Pls tell me if you find the solution.
My email id is khaleek_ahmad@y ahoo.com
Thanks in Advance
using System;
using System.Runtime. InteropServices ;
...
// usingAPI for mouse governing and other possibilities
#region Подключени е API для управления мышкой и других возможност ей
enum Messages{WM_LBU TTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202};
const int MK_LBUTTON = 0x0001;
[DllImport("User 32.dll")]
static extern int SendMessage(Int Ptr hWnd, Messages uMsg, int wParam, IntPtr lParam);
//импортируе м mouse_event():
[DllImport("User 32.dll")]
static extern void mouse_event(Mou seFlags dwFlags, int dx, int dy, int dwData, UIntPtr dwExtraInfo);
//для удобства использова ния создаем перечислен ие с необходимы ми флагами (константам и), которые определяют действия мыши:
//as a matter of convenience, use create enumeration with necessary flags (constants), which define actions of mouse:
[Flags]
enum MouseFlags
{
Move = 0x0001, LeftDown = 0x0002, LeftUp = 0x0004, RightDown = 0x0008,
RightUp = 0x0010, Absolute = 0x8000};
/// <summary>
/// Кликнуть в какомто месте экрана
///Click In some place of screen
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
private void TestMouse(int x, int y)
{
mouse_event(Mou seFlags.Absolut e | MouseFlags.Move , x, y, 0, UIntPtr.Zero);
mouse_event(Mou seFlags.Absolut e | MouseFlags.Left Down , x, y, 0, UIntPtr.Zero);
mouse_event(Mou seFlags.Absolut e | MouseFlags.Left Up, x, y, 0, UIntPtr.Zero);
}
#endregion
Hai friend,
use the code below to simulate mouse click -
using System.Runtime.InteropServices;
-
-
private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
-
private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;
-
[DllImport("user32.dll")]
-
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, uint dwExtraInf);
-
private void btnSet_Click(object sender, EventArgs e)
-
{
-
int x = Convert.ToInt16(txtX.Text);//set x position
-
int y = Convert.ToInt16(txtY.Text);//set y position
-
Cursor.Position = new Point(x, y);
-
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);//make left button down
-
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);//make left button up
-
}
-
txtX is a text box to set x position of cursor
txtY is a text box to set y position of cursor
btnSet is a a button
when yo clicks on the button btnset the cursor will move to the position specified in two text boxes(txtX & txtY)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jonny |
last post by:
Hi all,
Does anyone know how to capture the Windows Keys (I know
that they are out of the ascii key range) and how to
capture and record Mouse movements?
Thanks,
/Jonny
|
by: Harry J. Smith |
last post by:
How can you detect a mouse double click on a text box? I tried the following
but it does not work.
private void richTextOut_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
// Process Mouse up in output TextBox
{
|
by: Sakharam Phapale |
last post by:
Hi All,
How to capture Mouse Single click and mouse double click event on Commnad
Button.
I am doing as follows.
Private void Button1_MouseUp(Object sender,
System.Windows.Forms.MouseEventArgs e)
{
|
by: cover |
last post by:
Is it possible to use a 'mouse up' click in forms where if you have
for example, a drop down menu where you might click as the top
selection, an equipment area (hard coded into the form), the type of
equipment (a selection of 3 items again hard coded into the form), and
then upon 'mouse up' of the second field (equipment type), have the
3rd pull down populated by the mouse up click of the second selection
showing database entries available...
|
by: Abhishek |
last post by:
Hi,
I have a activex web browser embedded in a windows form and on a click of a
form button i need the mouse to go the position for example 100, 100 and
click the link that will be there on that position.
i am usind the win api setcursonpos to set the mouse position
assume that the link will always be there at 100, 100. how do i get Windows
to create the click event.
| |
by: Steve |
last post by:
How do you disable the mouse right click to prevent pop-up window?
Or if I want to have cut/copy/paste on pop-up window use same code as my
custom cut/copy/paste that are triggered by toolstrip buttons?
Thanks
Steve
|
by: DanAusitn |
last post by:
Good morning folk,
a quick question to anyone who can help.
i am working on a program and i am using the below code to simulate mouse movement to certain
co-ords, but the thing is the co-ords 0 , 0 refer to the position at the very top left of the monitor.
what i want is for the co-ords 0 , 0 to refer to the top left in my form so the mouse clicks and
movements stay inside the form.
|
by: sahani |
last post by:
how do i create a programme to capture mouse movements??
and i want to write something using mouse pointer during the presentation?
and what are the ways to implement software to capture mouse movements?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |