Getting active application by mouse click

Posted on 2006-11-28
Medium Priority
Last Modified: 2010-04-23
Ok, how about this.....is there a way to capture the application by way of a mouse click event?

So when a user clicks on a application (say Notepad) and then clicks on a button in a Vb.net 2003 program which will display what application they selected.  

Question by:TechMonster
  • 3
  • 2
LVL 16

Expert Comment

ID: 18033032
Hi TechMonster,

What are you trying to acheive?  There are ways to get references to other applications like Notepad, using functions from the win32 api, however they are pretty tricky to use...

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18034177
Take a look at my approach here:

It allows you to initiate a drag from your app and it identifies the hWnd of the control where the drop is made.  Then you can figure out the window that owns that control from there.

This is accomplished via the SetCapture() API.

If you think this is workable then I can see about converting the code to VB.Net.  It will be shorter than the solution VB6 since some of that code required APIs that are now encapsulated by the .Net framework.

Author Comment

ID: 18038299
The setCapture may work.  I am not 100% sure i understand how to use but it may be heading me in the right direction.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18038316
I'll work out a sample project to demonstrate it...
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 18049092

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

621 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