How to check if a control or object exists with AutoHotkey v2?
In v1 I can find IfWinExist and more, but in v2 not.
could somebody please give me a hint?
How to check if a control or object exists with AutoHotkey v2
Re: How to check if a control or object exists with AutoHotkey v2
True, I cannot directly find a native function.
You can build it with ControlGetHwnd so it reacts like WinExist.
You can build it with ControlGetHwnd so it reacts like WinExist.
Code: Select all
ControlExist(Control, WinTitle:="", WinText:="", ExcludeTitle:="", ExcludeText:=""){
try
return ControlGetHwnd(Control, WinTitle, WinText, ExcludeTitle, ExcludeText)
catch
return false
}
Re: How to check if a control or object exists with AutoHotkey v2
To answer this specific part of your post, even the documentation for v1 says not to use IfWinExist anymore and directs you to WinExist. And v2's WinExist is exactly the same. The equivalent of IfWinExist, ... is if WinExist("...")
Re: How to check if a control or object exists with AutoHotkey v2
I find it actually quite strange that you have different indications for ControlGetHwnd and WinGetID, as ID and Hwnd are the same things, It would be logically to use everywhere the name ID (shorter and as Hwnd means Handle to a Window, it seems more logically to use ID that is short and can be used for controls and windows)
So ControlGetID, GuiFromID and GuiCtrlFromID would be a more logical function names.
And I would also change the hwnd property to the name ID.
So ControlGetID, GuiFromID and GuiCtrlFromID would be a more logical function names.
And I would also change the hwnd property to the name ID.
Re: How to check if a control or object exists with AutoHotkey v2
a control ID is something else