[a100] ControlGetHwnd issue Topic is solved

Discuss the future of the AutoHotkey language
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: [a100] ControlGetHwnd issue

01 Nov 2018, 06:39

I kept my OP short and sweet, stating no assumptions, hoping for clarification
It took you two days to give a hint about what the "" in your code was supposed to mean. I can only assume you didn't read the documentation at all, because surely, you know that optional parameters are marked by being enclosed in []. Passing '' to an optional parameter might sometimes be equivalent to omitting it, but never is (or should) passing '', to a non-optional parameter, equivalent to bypassing it being mandatory.
The problem here is that "" can be perfectly valid if you look for a control that contains no text.
It seems you always get errorlevel == 1 when passing '', so it seems you cannot match controls with no text.
If the title match mode is 1 or 2 "" will match any control.
And regex ;). Perhaps you can match a control with no text with something like the regex ^$.
I thought that only lexikos could provide an answer, but everyone chimed in with their opinions anyway, like they always do.
I'm not sure I understand, are you unhappy we replied? You should send lexikos a pm if do not want to be bothered by replies from anyone else.

Cheers.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: [a100] ControlGetHwnd issue

02 Nov 2018, 22:57

- The hint was: doesn't work in v2.0-a100 (does work in v2.0-a099)
- The documentation isn't always 100% up-to-date.
- Looking through AHK v1: a blank Control parameter was sometimes equivalent to omitting it, sometimes used as a text needle.
- I think on balance, blank parameters are best defined as equivalent to omitted, for simplicity and consistency. (Exceptions: MsgBox/InputBox.) (You want simple rules that you can remember, that apply as widely as possible.)
- I mentioned some suggestions for the Control parameter, here:
ControlXXX functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 65#p242465
- Sometimes I find (AutoHotkey v2 Development forum) responses maximally abrasive and minimally thought-through, it gets a little wearing. (I kept my OP short and neutral to try to avoid this, but it didn't work.)
- To distinguish between a 'control' and a 'window' you can use GetAncestor with GA_PARENT. However, as I pointed out, you can have controls within controls, so I wouldn't force an error message when you put an hWnd in WinTitle that has a parent, that idea seems 'illiterate' to me.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 75 guests