[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
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, p.X, p.Y, 0, 0);
//Left click yapacak method.
Hata alıyorum ne yapmam lazım?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.
mouse_event'i tuş sınıfında kullandım yine hata verdi.Şu örnekte mouse_event methodunu ve static propertyleri sadece "tus" sınıfı içerisinde kullanabilirsiniz.
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);
}
}
MouseHelper.Click(x, y); //x,y burada tıklayacağınız noktanın koordinatlarıdır.
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.