Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# how to simulate mouse click

//This is a replacement for Cursor.Position in WinForms
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool SetCursorPos(int x, int y);

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;

//This simulates a left mouse click
public static void LeftMouseClick(int xpos, int ypos)
{
    SetCursorPos(xpos, ypos);
    mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: linux command line exit with error message 
Csharp :: enum loop 
Csharp :: how to make console wait c# 
Csharp :: randomize through array in C# 
Csharp :: dotnet get directory of executable 
Csharp :: how to convert string to bool c# 
Csharp :: linq unique count property 
Csharp :: c# convert dictionary to anonymous object 
Csharp :: ping with c# 
Csharp :: unity or 
Csharp :: Csharp cast string to double 
Csharp :: bold caption latex 
Csharp :: c# mysql query 
Csharp :: bin/bash bad interpreter 
Csharp :: how to exit application c# console 
Csharp :: c# prime factorization 
Csharp :: c# form formborderstyle none move 
Csharp :: unity main texture not working 
Csharp :: substring c# after character 
Csharp :: delay in unity 
Csharp :: unity convert mouse position to world position in editor mode 
Csharp :: loadscene unity 
Csharp :: Join Or Create Room() photon 
Csharp :: how to unset passwordchar in c# windows application 
Csharp :: C# how to remove an image in a folder 
Csharp :: unity check if audio playing 
Csharp :: Attach Mixer to Audio Source via script 
Csharp :: an entry with the same key already exists asp net 
Csharp :: unity detect object with raycast 
Csharp :: C++ in C# 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =