In order to create your clicker in VB.NET you must do the following:
1) Get the handle of the target (casino) window.
2) Create a RECT structure with the coordinates.
3) Move the mouse to the coordinates within the casino window.
4) Perform the actual click operation.
Let's go at it step by step.
NOTE: since we'll use external DLL imports, you must add the line:
To the very top of your VB.NET file.
1) Get the handle of the target (casino) window:
In order to get the handle of the casino window you must use a function that returns this handle based on either the process id OR the window's title. We will use a title-based one, in our case: findWindow.
The declaration is this:
Now we must get the handle into a variable of type intPtr
vbNullString means you don't pass the class name of the casino and are only using the title.
2) Create a RECT structure with the coordinates.
First create your RECT structure:
Now set a variable with it, passing the casino handle (casinoHwnd) to the GetWindowRect() function.
And set a variable with it:
We are halfway there!
3) Move the mouse to the coordinates within the casino window.
In order to move the mouse you have to use the SetCursorPos(x, y) function.
It is declared like this:
And you simply use the coordinates of the number to click + the coordinates of the casino window, like this:
Let's suppose the #1 is at coordinates x:188, y:352 in the casino window.
In order to move the cursor there you use the .left and .top propierties of the stRect structure and add the coordinates:
And the cursor is right there focused on the exact number.
4) Perform the actual click operation.
In order to perform the actual click, we must invoke the mouse_event function.
It is declared like this, including the two constants for the down/up event combo to recreate the click:
And now simply use:
Voilá
YOU JUST DID YOUR CLICKER MODULE IN VISUAL BASIC.NET!
Victor
1) Get the handle of the target (casino) window.
2) Create a RECT structure with the coordinates.
3) Move the mouse to the coordinates within the casino window.
4) Perform the actual click operation.
Let's go at it step by step.
NOTE: since we'll use external DLL imports, you must add the line:
Code (vbnet) Select
Imports System.Runtime.InteropServices
To the very top of your VB.NET file.
1) Get the handle of the target (casino) window:
In order to get the handle of the casino window you must use a function that returns this handle based on either the process id OR the window's title. We will use a title-based one, in our case: findWindow.
The declaration is this:
Code (vb.net) Select
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
End Function
Now we must get the handle into a variable of type intPtr
Code (vbnet) Select
Dim casinoHwnd As IntPtr
casinoHwnd = FindWindow(vbNullString, "Exact casino window title here")
vbNullString means you don't pass the class name of the casino and are only using the title.
2) Create a RECT structure with the coordinates.
First create your RECT structure:
Code (vbnet) Select
'RECT structure
Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Now set a variable with it, passing the casino handle (casinoHwnd) to the GetWindowRect() function.
Code (vbnet) Select
<System.Runtime.InteropServices.DllImport("user32")> _
Private Shared Function GetWindowRect(ByVal hwnd As IntPtr, ByRef lpRect As Rectangle) As IntPtr
End Function
And set a variable with it:
Code (vbnet) Select
Dim stRect As RECT
GetWindowRect(casinoHwnd, stRect)
We are halfway there!
3) Move the mouse to the coordinates within the casino window.
In order to move the mouse you have to use the SetCursorPos(x, y) function.
It is declared like this:
Code (vbnet) Select
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Integer, ByVal why As Integer) As Integer
And you simply use the coordinates of the number to click + the coordinates of the casino window, like this:
Let's suppose the #1 is at coordinates x:188, y:352 in the casino window.
In order to move the cursor there you use the .left and .top propierties of the stRect structure and add the coordinates:
Code (vbnet) Select
SetCursorPos(stRect.Left + 188, strRect.Top + 352)
And the cursor is right there focused on the exact number.
4) Perform the actual click operation.
In order to perform the actual click, we must invoke the mouse_event function.
It is declared like this, including the two constants for the down/up event combo to recreate the click:
Code (vbnet) Select
Public 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
And now simply use:
Code (vbnet) Select
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Voilá
YOU JUST DID YOUR CLICKER MODULE IN VISUAL BASIC.NET!
Victor