INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

How to simulate a mouse click in VFP by mgagnon
Posted: 25 Aug 04

Here is an example on how to simulate a left mouse click and recuperating the confirmation of that action.

CODE

#Define MOUSEEVENTF_RESET 1
#Define MOUSEEVENTF_LEFTDOWN  2
#Define MOUSEEVENTF_LEFTUP 4
#Define MOUSEEVENTF_RIGHTDOWN  8
#Define MOUSEEVENTF_RIGHTUP  16
#Define MOUSEEVENTF_MIDDLEDOWN 32
#Define MOUSEEVENTF_MIDDLEUP 64
#Define MOUSEEVENTF_MIDDLEUP_WHEEL_MOVED 128
#Define VK_LBUTTON  1
#Define VK_RBUTTON  2
Declare Integer GetAsyncKeyState In user32 Integer vKey
Declare Integer GetKeyState In user32 Integer vKey
Declare Integer SetKeyboardState In user32 String @lpKeyState
Declare mouse_event In user32.Dll Long,Long,Long,Long,Long
Clear
Local cBuffer, nIndex, lStop
lStop=.F.
* clearing input-state table
cBuffer = Replicate(Chr(0), 256)
= SetKeyboardState(@cBuffer)
DoEvents
Do While Not lStop
* simulating time-consuming activity
    Create Cursor cs (num N(10))
    For nIndex=1 To 1000
        Insert Into cs Values (nIndex)
    Endfor
    ?? "."
    lcTest=mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,288,0)
    If GetKeyState(VK_LBUTTON) <> 0
        ? "Left button pressed."
        Exit
    Endif
    If GetKeyState(VK_RBUTTON) <> 0
        ? "Right button pressed."
        Exit
    Endif
Enddo

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close