-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot 1.1.vb
More file actions
147 lines (120 loc) · 5.25 KB
/
Bot 1.1.vb
File metadata and controls
147 lines (120 loc) · 5.25 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'Created by SHAKATAR
'Youtube Channel : https://www.youtube.com/channel/UC6lbgL5LYO0f4-4DH8JNU4Q
'Please Subscribe
Public Module Bot
Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Sub Click()
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
Public Sub ClickPos(ByVal x As Integer, ByVal y As Integer)
Cursor.Position = New Point(x, y)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
Public Sub MoveCursor(ByVal x As Integer, ByVal y As Integer)
Cursor.Position = New Point(x, y)
End Sub
Public Function getCursorPosition()
Return Cursor.Position
End Function
Public Function getCursorXPosition()
Return Cursor.Position.X
End Function
Public Function getCursorYPosition()
Return Cursor.Position.Y
End Function
Public Sub HideApplication(ByVal NameProcess As String)
If NameProcess.EndsWith(".exe") Then
NameProcess = NameProcess.Replace(".exe", Nothing)
End If
If Process.GetProcessesByName(NameProcess).Length > 0 Then
For Each p As Process In Process.GetProcessesByName(NameProcess)
ShowWindow(p.MainWindowHandle, 0)
Next
Else
MsgBox("Le processus " & NameProcess & ".exe" & " n'a pas était trouvé !", vbCritical, "Erreur !")
End If
End Sub
Public Sub MinimizeApplication(ByVal NameProcess As String)
If NameProcess.EndsWith(".exe") Then
NameProcess = NameProcess.Replace(".exe", Nothing)
End If
If Process.GetProcessesByName(NameProcess).Length > 0 Then
For Each p As Process In Process.GetProcessesByName(NameProcess)
ShowWindow(p.MainWindowHandle, 2)
Next
Else
MsgBox("Le processus " & NameProcess & ".exe" & " n'a pas était trouvé !", vbCritical, "Erreur !")
End If
End Sub
Public Sub MaximizeApplication(ByVal NameProcess As String)
If NameProcess.EndsWith(".exe") Then
NameProcess = NameProcess.Replace(".exe", Nothing)
End If
If Process.GetProcessesByName(NameProcess).Length > 0 Then
For Each p As Process In Process.GetProcessesByName(NameProcess)
ShowWindow(p.MainWindowHandle, 3)
Next
Else
MsgBox("Le processus " & NameProcess & ".exe" & " n'a pas était trouvé !", vbCritical, "Erreur !")
End If
End Sub
Public Sub FocusApplication(ByVal NameProcess As String)
If NameProcess.EndsWith(".exe") Then
NameProcess = NameProcess.Replace(".exe", Nothing)
End If
If Process.GetProcessesByName(NameProcess).Length > 0 Then
For Each p In Process.GetProcessesByName(NameProcess)
AppActivate(p.MainWindowTitle)
Next
Else
MsgBox("Le processus " & NameProcess & ".exe" & " n'a pas était trouvé !", vbCritical, "Erreur !")
End If
End Sub
Public Sub KillApplication(ByVal NameProcess As String)
If NameProcess.EndsWith(".exe") Then
NameProcess = NameProcess.Replace(".exe", Nothing)
End If
Dim myProcesses As Process() = Process.GetProcessesByName(NameProcess)
Dim myProcess As Process
For Each myProcess In myProcesses
myProcess.Kill()
Next myProcess
End Sub
Public Sub OpenApplication(ByVal Path As String)
Dim App As New Process()
App.StartInfo.FileName = Path
App.Start()
End Sub
Public Sub Batch(ByVal Commands As String, Optional ByVal WindowStyle As ProcessWindowStyle = ProcessWindowStyle.Normal)
Dim Batch As New Process()
Batch.StartInfo.FileName = "cmd.exe"
Batch.StartInfo.Arguments = "/c " & Commands
Batch.StartInfo.WindowStyle = WindowStyle
Batch.Start()
End Sub
Public Function getPixelColor(ByVal x As Integer, y As Integer)
Dim Bitmap As New Bitmap(1, 1)
Using gr As Graphics = Graphics.FromImage(Bitmap)
gr.CopyFromScreen(New Point(x, y), New Point(0, 0), New Size(1, 1))
End Using
Dim Pixel As Drawing.Color = Bitmap.GetPixel(0, 0)
Return Pixel
End Function
Public Sub WaitMilli(ByVal Milliseconds As Integer)
System.Threading.Thread.Sleep(Milliseconds)
End Sub
Public Sub WaitSec(ByVal Seconds As Integer)
System.Threading.Thread.Sleep(Seconds * 1000)
End Sub
Public Sub WaitMin(ByVal Minutes As Integer)
System.Threading.Thread.Sleep(Minutes * 60000)
End Sub
Public Sub WaitHour(ByVal Hours As Integer)
System.Threading.Thread.Sleep(Hours * 3600000)
End Sub
End Module