Jump to content

Get Ctrl (ID or handle) that is under mouse


corgano
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

corgano,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...