Solved

capturing mouse event with a formless application

Posted on 2001-09-18
9
174 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
  • 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
 
LVL 1

Author Comment

by:tomkyn
ID: 6491546
Excellent, just what I needed.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now