|
-
January 16th, 2000, 08:07 PM
#1
Mouse Movement
How do i move the mouse on the screen?
-
January 18th, 2000, 06:33 PM
#2
Re: Mouse Movement
Well, you take the mouse in either your right or left hand AND.....(drum-roll please)...you move your hand and the mouse moves on the screen. WOW!!! Just joking. Use the SetCursorPos API function.
private Declare Function SetCursorPos Lib _
"user32" (byval X as Long, byval Y as Long) _
as Long
Then just call it like so:
Call SetCursorPos(20,20)
The above line will move the mouse to the 20th pixel from the left of the screen and to the 20th pixel from the top of the screen.
Hope this helps,
Rippin
-
January 19th, 2000, 09:12 AM
#3
Re: Mouse Movement
Nice. Do you by any chance know how to hide the cursor? Also, how can you restrict its movement within a certain area of a window?
-------------------------
Nick A.
-
January 19th, 2000, 09:23 AM
#4
Re: Mouse Movement
You can use the ClipCursor and ShowCursor APIs, ie.
private Type RECT
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
private Declare Function ClipCursor Lib "user32" (lpRect as Any) as Long
private Declare Function ShowCursor Lib "user32" (byval bShow as Long) as Long
private Declare Function GetWindowRect Lib "user32" (byval hwnd as Long, lpRect as RECT) as Long
private Sub Command1_Click()
static bRestricted as Boolean
Dim tRECT as RECT
bRestricted = Not bRestricted
If bRestricted then
'Restrict the Cursor to Inside the Form Area
Call GetWindowRect(hwnd, tRECT)
Call ClipCursor(tRECT)
else
'Release the Cursor
Call ClipCursor(byval 0&)
End If
End Sub
private Sub Command2_Click()
static bHide as Boolean
bHide = Not bHide
Call ShowCursor(Abs(Not bHide))
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
January 19th, 2000, 09:35 AM
#5
Re: Mouse Movement
Great. That's what i needed. Thanx a lot.
-------------------------
Nick A.
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
|