Sup all?
OK, I made a program that simulates a mouse click on a specific X , Y coordinates on the webbrowser. The thing is that, is not working here is my code
VB.NET Code:
Class Control
Public Sub New(ByVal Handle As IntPtr)
hWnd = Handle
End Sub
Private hWnd As IntPtr = IntPtr.Zero
Public Property ControlHandle() As IntPtr
Get
Return hWnd
End Get
Set(ByVal value As IntPtr)
hWnd = value
End Set
End Property
Const WM_LBUTTONDOWN As Int32 = &H201
Const WM_LBUTTONUP As Int32 = &H202
<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Public Sub ClickControl(ByVal x As Integer, ByVal y As Integer)
Dim coords As Integer = (y << 16) + x
Dim lParam As New IntPtr(coords)
PostMessage(hWnd, WM_LBUTTONDOWN, IntPtr.Zero, lParam)
PostMessage(hWnd, WM_LBUTTONUP, IntPtr.Zero, lParam)
End Sub
Public Sub ClickControl(ByVal p As Point)
ClickControl(p.X, p.Y)
End Sub
End Class
End Namespace
I call is like this
VB.NET Code:
handle = Control.FindControl(WebBrowser1.Handle, Nothing) '"Internet Explorer_Server")
MyControl = New Control(handle)
Dim test As Point
test.X = 200
test.Y = 58
MyControl.ClickControl(test)
But the thing is that, is does not work! What did I do wrong here?
I also tried changing
Const WM_LBUTTONDOWN As Int32 = &H201
to
Const WM_LBUTTONDOWN As Int32 = &H2
and my webbrowser goes blank.