Virtual mouse click inside a webbrowser at a specific x and
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
Hi guys so my problem is that the mouse moves and I don't want it to move here the code I have
Code: Select all
but this does not work this is in visual basic 2010 Declare Function mouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean
Public Const MOUSE_LEFTDOWN = &H2
Public Const MOUSE_LEFTUP = &H4
Private Sub RouletteXPro_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim x As Int32, y As Int32
'Change 'WebBrowser1.Width\2' and 'WebBrowser1.Height\2' to where ever you want the event to occur
'but remember to keep it within the webBrowser's size range.
x = WebBrowser1.Width - 100
y = WebBrowser1.Height - 100
'This will click dead center of the webBrowser.
Call mouse_event(MOUSE_LEFTDOWN, x, y, 0, 0)
Call mouse_event(MOUSE_LEFTUP, x, y, 0, 0)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label1.Text = Val(Label1.Text) - 1
If Label1.Text = 0 Then
Timer1.Enabled = False
End If
End Sub
= ( 30 views but no one can help I am about to give up on this code
the mouse moves and I don't want it to moveIt would probably be easier if you used this code:
Code: Select all
This will move the cursor to the point at x and y. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim x As Integer = WebBrowser1.Width - 100
Dim y As Integer = WebBrowser1.Height - 100
Cursor.Position = New Point(x, y)
End Sub
The mouse has to move in order for it to click in the spot you want to click. Maybe you could store the current mouse coordinates before doing the click and then return the mouse to that point afterwards.
If your trying to click a button or something on a web page then it would be easier and better to use the element invoke click method instead :?
If your trying to click a button or something on a web page then it would be easier and better to use the element invoke click method instead :?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
CodenStuff wrote:The mouse has to move in order for it to click in the spot you want to click. Maybe you could store the current mouse coordinates before doing the click and then return the mouse to that point afterwards.I have thought of that, thing is that I would like the form to minimize and still keep clicking the X and Y positions there is more then one
If your trying to click a button or something on a web page then it would be easier and better to use the element invoke click method instead :?
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023