Hi.
How to simulate(automatic) mouse movements and click operation using c#.
Actually, i got pixels in the face (face tracking) right now and i need to move mouse(automatically, 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 34501
Hi.
How to simulate(automatic) mouse movements and click operation using c#.
Actually, i got pixels in the face (face tracking) right now and i need to move mouse(automatically, 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@yahoo.com
Thanks in Advance
using System;
using System.Runtime.InteropServices;
...
// usingAPI for mouse governing and other possibilities
#region Подключение API для управления мышкой и других возможностей
enum Messages{WM_LBUTTONDOWN = 0x0201, WM_LBUTTONUP = 0x0202};
const int MK_LBUTTON = 0x0001;
[DllImport("User32.dll")]
static extern int SendMessage(IntPtr hWnd, Messages uMsg, int wParam, IntPtr lParam);
//импортируем mouse_event():
[DllImport("User32.dll")]
static extern void mouse_event(MouseFlags 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(MouseFlags.Absolute | MouseFlags.Move, x, y, 0, UIntPtr.Zero);
mouse_event(MouseFlags.Absolute | MouseFlags.LeftDown , x, y, 0, UIntPtr.Zero);
mouse_event(MouseFlags.Absolute | MouseFlags.LeftUp, 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)
//...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |