Solved

capturing mouse event with a formless application

Posted on 2001-09-18
9
178 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

12 Experts available now in Live!

Get 1:1 Help Now