|
-
Aug 3rd, 2013, 10:59 AM
#1
Thread Starter
Junior Member
Mouse move and click
Hi. I want a code that move my mouse on a position, then click. I want this for a auto-clicker.
Something like:
Code:
If progressbar1.Value = progressbar1.Maximum then
mouse.move...............
mouse.click ..........
progressbar1.value = 0
I searched the google, and i found something like "mouse_event". I tried it, but it click only one time (first time when progressbar1.value = max., but no 2nd, 3rd etc.) 
I want this to click me into form, but if not, i can find position from full screen . Thank's
-
Aug 3rd, 2013, 11:17 AM
#2
Re: Mouse move and click
If it works once then it works. If it doesn't work after that then it's because you're doing it wrong. If we can't see what you're doing, because you haven't shown us, then we can't know what's wrong with it.
-
Aug 3rd, 2013, 11:43 AM
#3
Thread Starter
Junior Member
Re: Mouse move and click
I delete what i wrote .... I tried more codes, finnaly I put a wrong code, but if you want i put this here. ")
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim aLines() As String = RichTextBox1.Lines
ProgressBar1.Increment(1)
If ProgressBar1.Value = ProgressBar1.Maximum Then
TextBox1.Text = TextBox1.Text + 1
ProgressBar1.Value = 0
WebBrowser1.Navigate(aLines(TextBox1.Text))
Dim X As Long
Dim Y As Long
Dim mouse_x As Long
Dim mouse_y As Long
' Get the coordinates.
X = CLng(txtX.Text)
Y = CLng(txtY.Text)
' Position the target form.
frmTarget.Left = X - frmTarget.Width / 2
frmTarget.Top = Y - frmTarget.Height / 2
' mouse_event moves in a coordinate system where
' (0, 0) is in the upper left corner and
' (65535,65535) is in the lower right corner.
' Convert the coordinates.
mouse_x = CLng(X * 65535 / Screen.Width)
mouse_y = CLng(Y * 65535 / Screen.Height)
' Click at that position.
mouse_event( _
MOUSEEVENTF_ABSOLUTE Or _
MOUSEEVENTF_MOVE Or _
MOUSEEVENTF_LEFTDOWN Or _
MOUSEEVENTF_LEFTUP, _
mouse_x, mouse_y, 0, 0)
End If
All after "Dim x as Long" I copy from another post, but is looks don't work.
Errors:
"frmTarget" , " MOUSEEVENTF_ABSOLUTE" , "MOUSEEVENTF_MOVE" are not declared.
'Width' is not a member of 'System.Windows.Forms.Screen'
'Height' is not a member of 'System.Windows.Forms.Screen'.
P,S: I don't modify this code, because i think is useless to modify if it's don't work.
And sorry for bad english.
-
Aug 3rd, 2013, 12:30 PM
#4
Re: Mouse move and click
Well that's your problem: you haven't modified the code. You can't just copy and paste someone else's code and assume that it will work. the error messages are telling you outright that you're using variables that you haven't declared, so you need to declare them. 'frmTarget' is obviously the target form; it even says so in the comments. The all-upper-case ones are presumably constants, so you can find their values online. I would guess that 'Screen' is also a variable that you haven't declared, which would be a Rectangle obtained from Screen.PrimaryScreen.WorkingArea or maybe .Bounds.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|