Board index » delphi » Get handle of clicked window...how?

Get handle of clicked window...how?

Hello fello Delphi-tes:

Does anybody know how I can click the window of an app and pass that
window's handle to my code?

Right now, I finally figured out how to simulate keyboard events and
pass them on to other apps, but I need to be able to switch apps (by way
of clicking their windows).

Any ideas? Anyone? Hey, I'll even send you some cookies if you can help
me figure it out.

Dee Philipp
--
Be well, do good work, and keep in touch!
e-mail: d...@xmission.com

 

Re:Get handle of clicked window...how?


Quote
dpb wrote:

> Hello fello Delphi-tes:

> Does anybody know how I can click the window of an app and pass that
> window's handle to my code?

I just looked into the Delphi Help and found this:
'GetActiveWindow':
The GetActiveWindow function retrieves the window handle of the active
window associated with the thread that calls the function.

I have not tried it yet, just looked to something that sounds like what
You need.
Please tell me, if You get a solution for this problem. I am very
interested to this.

Good luck!
  Pat :-)

Re:Get handle of clicked window...how?


Quote
In article <350DECE6.2...@humdinger-media.com>, d...@humdinger-media.com wrote:
>Hello fello Delphi-tes:

>Does anybody know how I can click the window of an app and pass that
>window's handle to my code?

If you have build those applications yourself, you culd do something with
Inter program messages.

Otherwise, I have no idea (It mus be do able, winsight can do it).
Parhaps a callback that intercepts all mousedown events??

The Graphical Gnome (r...@ktibv.nl)
Sr. Software Engineer IT Department
-----------------------------------------
The Unofficial Delphi Developers FAQ
http://www.gnomehome.demon.nl/uddf/index.htm

Re:Get handle of clicked window...how?


Did you tried to capture the mouse?
Your form shoul call the SetCapture(Self) methode, and after, at OnClick you
can check to see what window is at position the user clicked (translate to
screen coordinates first!), and after release the capture with a call
SetCapture(nil).

Best regards,
Remus

Quote
dpb wrote in message <350DECE6.2...@humdinger-media.com>...
>Hello fello Delphi-tes:

>Does anybody know how I can click the window of an app and pass that
>window's handle to my code?

>Right now, I finally figured out how to simulate keyboard events and
>pass them on to other apps, but I need to be able to switch apps (by way
>of clicking their windows).

>Any ideas? Anyone? Hey, I'll even send you some cookies if you can help
>me figure it out.

>Dee Philipp
>--
>Be well, do good work, and keep in touch!
>e-mail: d...@xmission.com

Re:Get handle of clicked window...how?


Hi,

try the following:

function WindowFromMousePos: hWnd;
var
    aPt: TPoint;
begin
    GetCursorPos(aPt);
    Result := WindowFromPoint(aPt);
end;

hth
Dan

dpb schrieb in Nachricht <350DECE6.2...@humdinger-media.com>...

Quote
>Hello fello Delphi-tes:

>Does anybody know how I can click the window of an app and pass that
>window's handle to my code?

>Right now, I finally figured out how to simulate keyboard events and
>pass them on to other apps, but I need to be able to switch apps (by way
>of clicking their windows).

>Any ideas? Anyone? Hey, I'll even send you some cookies if you can help
>me figure it out.

>Dee Philipp
>--
>Be well, do good work, and keep in touch!
>e-mail: d...@xmission.com

Re:Get handle of clicked window...how?


You can also try 'GetFocus' that returns the handle of the window or
control that
has input focus.

Louis Bressan

Other Threads