Jump to content
Sign in to follow this  
corgano

Get Ctrl (ID or handle) that is under mouse

Recommended Posts

corgano

I want to find out what Control is under the mouse, and the ID or handle of it. I know this has been asked before, but I searched with google (site:autoitscript.com control from pos ,and others) and the sites search but got nothing. can anyone post an example they might have laying around?

EDIT:

I was secucessfully able to get the control handle and ID of any control, but the script would rather return the ID of a goop then the control in the goop.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
Mat

_WinAPI_WindowFromPoint

For example of use check out my UDF for making a finder tool here, or look on the forums for lazycats example which I based it on.

Edited by Mat

Share this post


Link to post
Share on other sites
Melba23

corgano,

Someone brought this topic to my attention earlier today. I have not used it myself, but given its pedigree it might be worth a look. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
corgano

corgano,

Someone brought this topic to my attention earlier today. I have not used it myself, but given its pedigree it might be worth a look. :D

M23

DUDE

Thats exactly what I was looking for. I even posted in that thread, funny I didn't remember!

OK that didnt work

It was returning a diffenent controlID than autoiT window tool. Any other ones i could try?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
picea892

I guess this is solved. But for a simpler example you can see here.

Share this post


Link to post
Share on other sites
corgano

I guess this is solved. But for a simpler example you can see here.

Not yet...

How do I get the control ID from the control handle? I tried using control click with a control handle but it didn't work. How do I get a Control ID from a control handle? This works perfectly for handle (derived by Mat's window finder tool)

Func click()
    $INTERNAL_USER32_DLL = DllOpen("user32.dll")
    Local $mPos = MouseGetPos (), $hWndUnder = DllCall($INTERNAL_USER32_DLL, "hwnd", "WindowFromPoint", "long", $mPos[0], "long", $mPos[1])
    FileWrite($file,'WinWaitActive("'&WinGetTitle("[ACTIVE]")&'")' & @CRLF)
    FileWrite($file,'ControlClick("'&WinGetTitle("[ACTIVE]")&'","",'&$hWndUnder[0]&')' & @CRLF)
    MouseClick("left")
EndFunc

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
Melba23

corgano,

If you have the handle, _WinAPI_GetDlgCtrlID will get you the ControlID. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
corgano

Ok thank you people

just in summary:

$INTERNAL_USER32_DLL = DllOpen("user32.dll")
    Local $mPos = MouseGetPos (), $hWndUnder = DllCall($INTERNAL_USER32_DLL, "hwnd", "WindowFromPoint", "long", $mPos[0], "long", $mPos[1])
;this will get you the handle, from mats window finder tool
$ID = _WinAPI_GetDlgCtrlID($hWndUnder[0])
;this will get you the ID

Happy with how small it is! Thankyou everyone who posted

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
corgano

OK new problem, I am trying to get the control handle or id of a control inside a goop, the previous script only returns the goop control ID, not the control in the goop. How do I get past this?


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×