Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to detect double-click on desktop window?

Posted on 2010-09-15
6
Medium Priority
?
1,569 Views
Last Modified: 2013-12-16
Hello,

I am developing an VB.NET 2008 application, that will need to detect double clicks on desktop screen.

I am aware of the global mouse hook written in VB.NET, from the following internet page:
http://www.codeproject.com/KB/DLL/WindowsHookLib.aspx

but this always include clicks on buttons, icons and other items, and from the above example it seems that the desktop and the contained icons from the desktop, always have the same handle and classname.

What I need is to detect ONLY that double-clicks which are not connected with any action (those messages which system is not passing to any other application neither interpret by its own like double-clicks on icons).

Any ideas on how I could filter-out application/icons connected double clicks ?
Just double click on empty desktop area.

Thank you in advance.
0
Comment
Question by:mediasoftware
  • 3
  • 3
6 Comments
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 2000 total points
ID: 33687844

option Explicit

private Declare Function GetAsyncKeyState Lib "user32" _
        (byval vKey as Long) as Integer
private Const VK_LBUTTON = &H1
private Const VK_RBUTTON = &H2

private Sub Form_Load()
    Timer1.Interval = 100
End Sub

private Sub Timer1_Timer()
    If GetAsyncKeyState(VK_LBUTTON) then
        Label2.Caption = "Left Click"
    ElseIf GetAsyncKeyState(VK_RBUTTON) then
        Label2.Caption = "Right Click"
    else
        Label2.Caption = ""
    End If
End Sub

Open in new window

0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33687846
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 33687849
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mediasoftware
ID: 33687929
Hello itkamaraj,

Maybe I was not explained too well. I effectively use the global mouse hook code from:
http://www.codeproject.com/KB/DLL/WindowsHookLib.aspx

and that code works extremely well.

The one and only problem that I do have is that I need to detect double clicks on desktop screen, not on the icons from the desktop, but double clicks on empty desktop area.

Thank you in advance.
0
 

Author Comment

by:mediasoftware
ID: 33697288
Thank you itkamaraj.

I was followed the links and it's seems to put me in the right direction. Here are the conclusions I ended up with:

To distinguish clicks on desktop if they are on icons or empty place, one way, will probably follows these steps:

First, it should need to obtain information about the desktop icons such as location and size.

Secondly, it would needed for the mouse hook to get the double clicks and the desktop window handle. When a double click event is fired it would need to check if the handle is the desktop handle, if it is, that means the user clicked on desktop not on a window.

Next, if the click is on desktop window than it would needed to compare the icons information (icon size and location) to see if mouse is inside the icon bounds. If it is, that means the click is on the icon.

So the main thing here is to get the icon information. One way to get this information is to use API’s. One thread from the following internet page, might be quite useful: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/d7df8a4d-fc0f-4b62-80c9-7768756456e6.

That seems to be one way to accomplish this task.

Thank you again, itkamaraj.
0
 

Author Closing Comment

by:mediasoftware
ID: 33697294
Looking forward to work with you.

Thank you, itkamaraj.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

926 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