|
-
Jan 23rd, 2000, 05:18 AM
#1
I get the mouse to move through vb? like move it from one corner to another corner? Or something to this exstant?
-
Jan 23rd, 2000, 05:55 AM
#2
Hyperactive Member
There is an answer in vb-world tips under mouse/keyboard.
-
Jan 23rd, 2000, 06:07 AM
#3
Lively Member
Put this in a module
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
And Final Put this to an form and create a command button called command1
Sub MoveMouse(x As Single, y As Single)
Dim pt As POINTAPI
pt.x = x
pt.y = y
ClientToScreen hwnd, pt
SetCursorPos pt.x, pt.y
End Sub
Private Sub Command1_Click()
MoveMouse 300, 150
End Sub
Final if you click the button mouse moves in 300,150 position(x,y) of your form
With MoveMouse procedure you can put mouse cursor in x,y position like
MoveMouse x,y
To make mouse to move in a line you can use this procedure
Sub domove(px1, py1, px2, py2 As Single)
Dim pb As Single
Dim i As Single
Dim pyold As Single
If (px1 - px2) <> 0 Then
pb = (py1 - py2) / (px1 - px2) '
pyold = py1
If (px1 - px2) < 0 Then
For i = px1 To px2
If (py1 - py2) < 0 Then
pyold = Abs(py1 + (i - px1) * pb)
MoveMouse Abs(Int(i)), Abs(Int(pyold))
End If
If (py1 - py2) > 0 Then
pyold = Abs(py1 + (i - px1) * pb)
MoveMouse Abs(Int(i)), Abs(Int(pyold))
End If
Next i
End If
If (px1 - px2) > 0 Then
For i = px1 To px2 Step -1
If (py1 - py2) < 0 Then
pyold = Abs(py1 + (i - px1) * pb)
MoveMouse Abs(Int(i)), Abs(Int(pyold))
End If
If (py1 - py2) > 0 Then
pyold = Abs(py1 + (i - px1) * pb)
MoveMouse Abs(Int(i)), Abs(Int(pyold))
End If
Next i
End If
End If
End Sub
Use it like this
domove (0,0,400,300)
This move mouse pointer from 0,0 position to 400,300 position
It's simple code.... bye
Created By Antony Tsiukas
-
Jan 23rd, 2000, 08:49 AM
#4
Hyperactive Member
Be careful! I wouldn't like my mouse roaming all over my desktop!
------------------
I wish I was patient... RIGHT NOW!
-
Jan 23rd, 2000, 09:44 AM
#5
i guess i got my answer from the article.
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
|