Solved

capturing mouse event with a formless application

Posted on 2001-09-18
9
181 Views
Last Modified: 2010-05-02
How do I capture a mouse event (move, click, yadda yadda yadda) in an application which doesn't have a form?
0
Comment
Question by:tomkyn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 4

Expert Comment

by:wileecoy
ID: 6491486
Basically you will be using some API calls to get the position of the mouse and capture the events.

The solution depends on the scope of your question.

Are you trying to get the events over certain apps or any clicking of the mouse?

Wileecoy.
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6491508
The following will get the mouse coordinates:

Add the following Form1(default form), Text1(default textbox), Timer1(default timer)

Private Type POINTAPI
    X As Long
    Y As Long
End Type


Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long


Private Sub Timer1_Timer()

Dim Pt As POINTAPI

    GetCursorPos Pt
    Text1.Text = "X: " & Pt.X & "   Y: " & Pt.Y

End Sub
0
 
LVL 4

Accepted Solution

by:
wileecoy earned 100 total points
ID: 6491515
This link may also be of assistance to you.

http://www.planetsourcecode.com/xq/ASP/txtCodeId.2795/lngWId.1/qx/vb/scripts/ShowCode.htm


hth.

Wileecoy.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:tomkyn
ID: 6491546
Excellent, just what I needed.
0
 
LVL 1

Author Comment

by:tomkyn
ID: 6491579
I can get the coordinates now.  Can I also capture the click event?  In other words, can I pop up a msgbox from my app when I click (regardless of where on the screen I click) the mouse button?
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6491636
... digging ...
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6491663
I will have to get back to you later in the evening - Can't find anything here.

Wileecoy.
0
 
LVL 1

Author Comment

by:tomkyn
ID: 6491718
Heh...  

Private Declare Function Getasynckeystate Lib "user32" Alias "GetAsyncKeyState" (ByVal VKEY As Long) As Integer

and the VKEY is &H1  :)
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6491859
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question