@@ -12,6 +12,8 @@ public static class WinAPI
12
12
13
13
public const int TimeBetweenActions = 5 ;
14
14
15
+ public static MouseEventFlags CurrentMouseState = MouseEventFlags . LeftUp | MouseEventFlags . MiddleUp | MouseEventFlags . RightUp ;
16
+
15
17
[ Flags ]
16
18
public enum MouseEventFlags
17
19
{
@@ -59,10 +61,36 @@ public static void PerformAction(MouseEventFlags value)
59
61
Point position = GetCursorPosition ( ) ;
60
62
MouseMoveTo ( position . X , position . Y ) ;
61
63
64
+ UpdateCurrentMouseState ( value ) ;
62
65
mouse_event ( ( int ) value , position . X , position . Y , 0 , 0 ) ;
63
66
Thread . Sleep ( TimeBetweenActions ) ;
64
67
}
65
68
69
+ private static void UpdateCurrentMouseState ( MouseEventFlags flag )
70
+ {
71
+ switch ( flag )
72
+ {
73
+ case MouseEventFlags . LeftDown :
74
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . LeftDown ) & ~ MouseEventFlags . LeftUp ;
75
+ break ;
76
+ case MouseEventFlags . LeftUp :
77
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . LeftUp ) & ~ MouseEventFlags . LeftDown ;
78
+ break ;
79
+ case MouseEventFlags . MiddleDown :
80
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . MiddleDown ) & ~ MouseEventFlags . MiddleUp ;
81
+ break ;
82
+ case MouseEventFlags . MiddleUp :
83
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . MiddleUp ) & ~ MouseEventFlags . MiddleDown ;
84
+ break ;
85
+ case MouseEventFlags . RightDown :
86
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . RightDown ) & ~ MouseEventFlags . RightUp ;
87
+ break ;
88
+ case MouseEventFlags . RightUp :
89
+ CurrentMouseState = ( CurrentMouseState | MouseEventFlags . RightUp ) & ~ MouseEventFlags . RightDown ;
90
+ break ;
91
+ }
92
+ }
93
+
66
94
public static void PerformActionDown ( MouseButton value )
67
95
{
68
96
var flags = value == MouseButton . Left ? MouseEventFlags . LeftDown :
0 commit comments