Getting a handle of another window
I was wondering if it''s possible to get a handle to another applications window. What I mean is say I have microsoft Word running, how would I get a handle to MS Word''s window so I can use it in my own app? Anyone know if this is possible?
Thanks in advance
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
EnumWindows may do the job you want, there is also FindWindow but that is a little vague about whether it works across tasks (and you have to supply the class name).
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // callback function
LPARAM lParam // application-defined value
);
BOOL CALLBACK EnumWindowsProc(
HWND hwnd, // handle to parent window
LPARAM lParam // application-defined value
);
Return TRUE from EnumWindowsProc to continue enumerating, 0 otherwise.
---
Rob
See other worlds at http://www.silverfrost.com
---RobSee other worlds at http://www.silverfrost.com
Hold on a second, that doesn''t really do what I want. I''d have to know the class name of MS Word? Do I need to know the callback function too?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Word would be better implemented as an ActiveX Control. If you really want to try the handle windows idea though, Im pretty sure you can find MSWord class in the Registry.
What is a man without goals? A dead man.
What is a man without goals? A dead man.
---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.
The problem is, I don''t really know how to use ActiveX controls. Anyway, Word''s class name is in the registry? What about some other program''s class name, like a program I''ve made?
This is what I''ve been trying to do. I''ve made 2 programs caled program A & B. The purpose of this is to make program B send mouse clicks to Program A. I''ve been only able to do this if I had the handle to window A. Even then, that''s through GetActiveWindow. I was wondering how would I do this in another way, if :-
1) the window isn''t active
2) the classname isn''t known.
Oh yeah, just curious, is the classname of program A & B in the registry too?
Thanks a lot
This is what I''ve been trying to do. I''ve made 2 programs caled program A & B. The purpose of this is to make program B send mouse clicks to Program A. I''ve been only able to do this if I had the handle to window A. Even then, that''s through GetActiveWindow. I was wondering how would I do this in another way, if :-
1) the window isn''t active
2) the classname isn''t known.
Oh yeah, just curious, is the classname of program A & B in the registry too?
Thanks a lot
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Just remembered, I have already written this code, its:
FindWindow("OpusApp",NULL)
OpusApp seems to be the clas name of Winword''s main window. You can easily find these names by running an app like Spy++.
As for the Enum, you supply the callback and it calls you with every window handle.
---
Rob
See other worlds at http://www.silverfrost.com
FindWindow("OpusApp",NULL)
OpusApp seems to be the clas name of Winword''s main window. You can easily find these names by running an app like Spy++.
As for the Enum, you supply the callback and it calls you with every window handle.
---
Rob
See other worlds at http://www.silverfrost.com
---RobSee other worlds at http://www.silverfrost.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement