Link to home
Start Free TrialLog in
Avatar of urif
urif

asked on

get the wincontrol under the mouse (system wide)

hi, i'm trying to identify the wincontrol that is under the mouse at any given time, for example: the caption, the scrollbar, a button, a form, etc.
i know how to do it locally, meaning in my own application with my own form and components, the thing is that i need to be able to do the same systemwide, if i move the mouse over the desktop then it should return "desktop" (or whatever the name is for the desktop object), etc.

the application that i am writing has already a mouse hook and i know where the mouse is at any given time.

any ideas? a code snippet would be great

thanks
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

Use WindowFromPoint() to get handle of a control under the mouse cursor.
Then use GetClassName() to get class name of control (handle).
You may also use GetWindowText() or SendMessage() with wm_gettext as msg parameter to get caption/text of a control.
ASKER CERTIFIED SOLUTION
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eddie Shipman
I wrote a clone of Win32Spy in delphi. I will post it later this evening.
Avatar of urif
urif

ASKER

sorry for the delay, i was not able to access the internet.
thanks so much for the help!
?!
Go to Customer Service and ask that points be shifted to ZhaawZ.
I could not find my code and thus have not posted it and do not
deserve the points.
Avatar of urif

ASKER

oops! so sorry, i already sent the request.

i thought that i gave the points to ZhaawZ but i guess i pressed the wrong button, again sorry.
hopefully the point will be passed onto ZhaawZ
Thanks..
I finally found my code, I posted it here:

http://www.delphipages.com/result.cfm?ID=5330