move mouse

  • Thread starter Highlight between 3 fields
  • Start date
H

Highlight between 3 fields

Hello
I wonder if it is possible to move the mouse when the form opens?

I Mean that when the form opens, so I want the mouse arrow moves direct to
the edge of the screen monitor instead of moving it with my hand.

Thanks
 
T

Tom van Stiphout

On Sun, 28 Mar 2010 16:04:01 -0700, Highlight between 3 fields

Not unless you go to extremes.

-Tom.
Microsoft Access MVP
 
J

John W. Vinson

Hello
I wonder if it is possible to move the mouse when the form opens?

I Mean that when the form opens, so I want the mouse arrow moves direct to
the edge of the screen monitor instead of moving it with my hand.

Thanks

About all I can think of is to have a small textbox where you want the cursor
to appear (unbound of course), and set focus to it in the form's Load event.
 
J

Jon Lewis

You can do this using Windows api functions. If you're not familiar with
the Windows API then Google for explanation and for what the functions I've
used do. The code below will maintain the current Y co-ordinate of the
cursor but place it at the right edge of the screen. Modify for the effect
you want.

In Declarations section of your form's Module:

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y
As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long,
lpRect As RECT) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long

In your form's Load Event:

Dim pt As POINTAPI
Dim rct As RECT

GetWindowRect GetDesktopWindow, rct 'get screen coordinates of
the Desktop
GetCursorPos pt 'get
current position of cursor
SetCursorPos rct.Right, pt.Y 'move cursor
to far right of screen & current y coordinate

HTH

Jon
 
J

Jon Lewis

Just thought I'd point out my first reply is directed at the OP not Tom -
the original post is not appearing on my newsreader.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top