0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| a
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
namespace WinApi
{
public class Mouse {
// user32.dll apisinin mouse_event EntriPointinden Yararlancaz.
[DllImport("user32.dll")]
private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
// Onay Tanmlarmz
// -------------------
// Sol Down
public const UInt32 MouseEventLeftDown = 0x0002;
// Sol Up
public const UInt32 MouseEventLeftUp = 0x0004;
// Sa Down
public const UInt32 MouseEventRightDown = 0x0008;
// Sa Up
public const UInt32 MouseEventRightUp = 0x00016;
// Kk FOnksiyonumuzu yazalm tm mouse eventlar burdan geecek yani mouse_event'tan
private static void SendMouseEvent(UInt32 Button, uint x, uint y, System.IntPtr intptr)
{
mouse_event(Button, x, y, 0, new System.IntPtr());
}
// Down eventi gonderen fonksiyon. (Mouse Butonuna Basma. )
public static void SendDown(UInt32 Button, uint x, uint y)
{
// Cursoru tklamak istediimiz koordinatlara Konumlandryoruz.
Cursor.Position = new Point((int)x, (int)y);
// Olaymz Gonderiyoruz.
SendMouseEvent(Button, x, y, new System.IntPtr());
}
// Left Down Fonksiyonumuz.
public static void SendLeftDown(uint x, uint y)
{
SendDown(MouseEventLeftDown, x, y);
}
// Up Fonksiyonumuz.(Buton Brakma lemi)
public static void SendUp(UInt32 Button, uint x, uint y)
{
// Cursoru tklamak istediimiz koordinatlara Konumlandryoruz.
Cursor.Position = new Point((int)x, (int)y);
// Olaymz Gonderiyoryuz.
SendMouseEvent(Button, x, y, new System.IntPtr());
}
// Left Button Up Fonksiyonu (Sol Butonu Brakma ilemi)
public static void SendLeftUp(uint x, uint y)
{
SendMouseEvent(MouseEventLeftUp, x, y, new System.IntPtr());
}
// 1 basma + 1 brakma = 1 click olacandan click olaymz da bu ekilde gnderiyoruz.
public static void sendLeftClik(uint x, uint y)
{
SendLeftDown(x, y);
SendLeftUp(x, y);
}
// DoubleClick=2xClick (:
public static void SendDoubleClick(uint x, uint y)
{
sendLeftClik(x, y);
sendLeftClik(x, y);
}
}
} |