C# Farenin sol butonuna tıklatma

C#:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, UIntPtr dwExtraInfo);
private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
private const uint MOUSEEVENTF_LEFTUP = 0x04;
private const uint MOUSEEVENTF_RIGHTDOWN = 0x08;
private const uint MOUSEEVENTF_RIGHTUP = 0x10;
//P/Invoke için gerekli sabitler ve Importlar

C#:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
//Left click yapacak method.
 
C#:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, UIntPtr dwExtraInfo);
private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
private const uint MOUSEEVENTF_LEFTUP = 0x04;
private const uint MOUSEEVENTF_RIGHTDOWN = 0x08;
private const uint MOUSEEVENTF_RIGHTUP = 0x10;
//P/Invoke için gerekli sabitler ve Importlar

C#:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
//Left click yapacak method.
Hata alıyorum ne yapmam lazım?
hataa111.png
 
Şu örnekte mouse_event methodunu ve static propertyleri sadece "tus" sınıfı içerisinde kullanabilirsiniz.
 
Sınıfın içinde doğrudan method çağırmışsınız.
C#:
public static class MouseHelper{
    [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, UIntPtr dwExtraInfo);
    private static uint MOUSEEVENTF_LEFTDOWN = 0x02;
    private static uint MOUSEEVENTF_LEFTUP = 0x04;
    private static uint MOUSEEVENTF_RIGHTDOWN = 0x08;
    private static uint MOUSEEVENTF_RIGHTUP = 0x10;
    
    public static void Click(int x, int y){
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, x, y, 0, 0);   
    }
}

Bu sınıfa her yerden erişebilirsiniz. Kullanım için
MouseHelper.Click(x, y); //x,y burada tıklayacağınız noktanın koordinatlarıdır.
 

Yeni konular

Geri
Yukarı