Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HWD of windows that was clicked on

HWD of windows that was clicked on

HWD of windows that was clicked on

I'm trying to include functionality in my app that allows the user to click on the window of a target (external) application to identify it (and behind the scenes, I'll determine the window class, executable path, etc).

I've seen other apps that do something similar. User clicks a button in the base app, cursor changes to a crosshair or whatever, user moves cursor to find external window of interest and clicks to register that application with the base app. The apps I've seen don't bring the target window forward or change the z-order layering at all, so I can't figure out how they're doing it (don't appear to be using FindFirstWindow, etc).

I have experience enumerating over open windows, etc... but I'm unsure how my base app can intercept a mouse click on an external window.

Any help would be appreciated.
Thanks in advance,

RE: HWD of windows that was clicked on

Although i have never done such a thing, i should try doing the following:

- On receiving a WM_LBUTTONDOWN message on your button, call SetCapture to start capturing the mouse
- From this point, all mouse messages are going to your program, even if the mouse pointer moves out of your window.
- On receiving mouse messages, you can get the handle to the window the mouse pointer is above, by calling WindowFromPoint or ChildWindowFromPoint functions. (Not sure about this part, please don't shoot when i am wrong).
- On receiving a WM_LBUTTONUP message, call ReleaseCapture to get back normal mouse behaviour.

I expect this to behave a bit different as you describe: The user should press the mousebutton in your app and release it  above the window of interest. But it is the best i can come up with at this moment. It is also how Spy++ works.


RE: HWD of windows that was clicked on

Thanks much, MKuiper.

I'll give that a try.


RE: HWD of windows that was clicked on

That worked just as advertised, MKuiper.
But, yeah, I'm not terribly happy with the BUTTONDOWN on my app then BUTTONUP on the target app. For one, interface-wise, it's a bit difficult to explain.

I realized that Windows own SCRIPTIT allows you to drag windows ontop it's "interface" and it picks up the info from there. This seems a lot more intuitive, so I think I'll move forward in that direction if I can figure out the logistics.

Thanks again!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close