VS C# Mouse Click kodu?

26/12/2013, 00:38

jiloooo

forumda 2 buton olacak
buton1_click olayına mouse sol tuş belli saniye aralıklarla tık tık basmasını
buton2_click olayına ise tıklama olayını bitirmesini istiyorum

0.5 saniye aralıklarla sonsuz döngüde sol tık yapan kodları nasıl oluşturabilirim?

teşekkürler
26/12/2013, 00:49

mahmut18

Hiç süre bazında click olayını denememiştim cevap gelirse öğrenmiş olacağız ama bir yerden edindiğim bir bilgi var umarım azda olsa yardımcı olur,

Mousenin 10 kere ard arda click olayı ;

public partial class Form1 : Form

{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

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

public Form1()
{
DoMouseClick();
}
public void DoMouseClick()
{
for (int i = 0; i < 200; i++)
{
System.Threading.Thread.Sleep(100);
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}

}
}
}

Siz arayın yaparsanız ve kodları paylaşırsanız çok iyi olur en azından diğer arkadaşlar ve bende bilgilenmiş oluruz iyi geceler...
26/12/2013, 01:22

jiloooo

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private void Form1_Load(object sender, EventArgs e)
{

}
public static void MouseLeftClick(Point pos)
{
System.Windows.Forms.Cursor.Position = pos;
mouse_event(MOUSEEVENTF_LEFTDOWN, pos.X, pos.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, pos.X, pos.Y, 0, 0);
}
private void timer1_Tick(object sender, EventArgs e)
{
MouseLeftClick(MousePosition);
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}


ne hata veriyor ne de çalışıyor
26/12/2013, 22:34

mahmut18

Çok zor ve karmaşık bir konu bende denedim ama beceremedim