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:
[box]Imports System.Runtime.InteropServices[/box]
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:
<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 (link:://msdn.microsoft.com/es-es/library/system.intptr(VS.80).aspx)
[box]Dim casinoHwnd As IntPtr
casinoHwnd = FindWindow(vbNullString, "Exact casino window title here")[/box]
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:
'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.
<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:
[box] Dim stRect As RECT
GetWindowRect(casinoHwnd, stRect)[/box]
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:
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:
[box]
SetCursorPos(stRect.Left + 188, strRect.Top + 352)
[/box]
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:
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:
[box]
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
[/box]
Voilá!
CONGRATULATIONS, YOU JUST DID YOUR FIRST CLICKER MODULE IN VISUAL BASIC.NET!
Victor
Thanks Vic. This will really come in handy later when I have done the basic parts :)
Very interesting post, many thx Victor.
Thanks for this Victor, any chance you could now go through how to harvest and store the numbers from the marquee and in turn tell the bot when to bet (live tables). . ?
Thankyou
Quote from: topcat888 on Sep 25, 01:07 AM 2010
Thanks for this Victor, any chance you could now go through how to harvest and store the numbers from the marquee and in turn tell the bot when to bet (live tables). . ?
Thankyou
I agree. Thanks! :thumbsup: