Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HWD of windows that was clicked on 1

Status
Not open for further replies.

csteinhilber

Programmer
Aug 2, 2002
1,291
0
0
US
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,
-Carl
 
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.

Marcel
 
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!



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top