Detect Variable Name Of GUI Control? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Detect Variable Name Of GUI Control?

Post by Mulsiphix » 20 Mar 2022, 06:58

I would like to put my mouse over a GUI control, activate a hotkey, and have a MsgBox tell me what the variable name for that control is. I thought A_GuiControl held that information, but upon further reading, I'm not sure it works that way because the mouse hovering over a control doesn't make it the active thread, which is what I understand A_GuiControl to be tracking. Is there another built-in variable that might do the trick?
A_GuiControl
The name of the variable associated with the GUI control that launched the current thread. If that control lacks an associated variable,
A_GuiControl instead contains the first 63 characters of the control's text/caption (this is most often used to avoid giving each button a variable name). A_GuiControl is blank whenever: 1) A_Gui is blank; 2) a GUI menu bar item or event such as GuiClose/GuiEscape launched the current thread; 3) the control lacks an associated variable and has no caption; or 4) The control that originally launched the current thread no longer exists (perhaps due to Gui Destroy).

Code: Select all

#O::MsgBox, %A_GuiControl%

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Detect Variable Name Of GUI Control?  Topic is solved

Post by mikeyww » 20 Mar 2022, 07:44

Code: Select all

Gui, Add, Edit, w100 vebox1, Test1
Gui, Add, Edit, w100 vebox2, Test2
Gui, Show

#o::
MouseGetPos,,,, classNN
GuiControlGet, varName, Name, %classNN%
MsgBox, 64, Variable name, %varName%
Return

Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Re: Detect Variable Name Of GUI Control?

Post by Mulsiphix » 20 Mar 2022, 19:37

Thank you for showing me how to do this mikeyww! You are amazing :clap:

Post Reply

Return to “Ask for Help (v1)”