Winmove error with "[" in window title

Report problems with documented functionality
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Winmove error with "[" in window title

08 Dec 2017, 12:13

The following script produces an error. Specifically "Missing [".

Code: Select all

winmove, KEDIT - [, , 15, 43, 1316, 954
I can't find anything in the WinMove documentation https://www.autohotkey.com/docs/commands/WinMove.htm
that leads me to believe my code is incorrect. There is also nothing a the documentation for a "Window Title" about this. That is at: https://www.autohotkey.com/docs/misc/WinTitle.htm

The title of the window is "KEDIT - [C:\"...

A short discussion of this is found at: https://autohotkey.com/boards/viewtopic.php?f=5&t=40946 where I first presented it as a question. There one will find a couple of very interesting points. Another is this:

At the documentation for "Functions", one finds this quote:
The "% " prefix is also permitted in parameters that natively support expressions, but it is simply ignored.
The first variant syntax for WinMove is: Winmove, x, y. The documentation states X or Y may be an expression. That being the case, why does the following suggested workaround

Code: Select all

winmove, % "KEDIT - [", , 15, 43, 1316, 954
work? One would think that the "%" being ignored as in the quote above would make the preceding code not achieve the desired result.

If the "%" is simply ignored, we get:

Code: Select all

WinMove, "Kedit - [", , 15, 43, 1316, 954
which does not work.
guest3456
Posts: 3462
Joined: 09 Oct 2013, 10:31

Re: Winmove error with "[" in window title

08 Dec 2017, 12:31

the docs say that the X,Y parameters "can be expressions". the docs do not say that the WinTitle parameter "can be an expression". that explains why the % is required with quotes. usually only parameters "can be an expression" when they are number params, which saves you from dereferencing a var with %%s. i dont remember ever seeing a "can be expression" param that is a string

as far as the original issue, obviously the parser is thinking that the parameter is an expression as if you had only passed 2 params in the X,Y mode, just as was suggested in the thread you linked. perhaps the 'fix' would be to check if more than 2 params before assuming "can be expression" mode for the first 2 params.

lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Winmove error with "[" in window title

09 Dec 2017, 00:21

Without over-analyzing, I choose to think of this as by design.

In order to determine how many parameters the command has and therefore which mode to operate in, the parser must count the commas, taking into account that expressions may contain commas enclosed in (), [] or {}. Trying to detect every case where a window title could be mistaken as an expression or vice versa seems like it could be quite complicated.

Unless someone else can come up with a fix and provide extensive test cases to show that nothing else is broken, this will not be fixed sooner than v2. (v2-alpha fixes it by virtue of the fact that WinMove now has only one fixed syntax, and all parameters are expressions.)
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Winmove error with "[" in window title

09 Dec 2017, 14:27

To start, it is good to learn this hideous command syntax is not going to exist in V2.

I agree that fixing it would probably be very complicated, and undoubtedly not worth the effort. Although, a simple fix may be to just assume the syntax is Syntax #2 after an error is found parsing what "might" be an expression (Syntax #1).

I am a lover of documentation, and while many times documenting a design flaw is something that has always perturbed me, I think in this case--especially considering the advent of V2--a documentation change would go a long way to making this problem not a problem.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Winmove error with "[" in window title

10 Dec 2017, 01:13

Although, a simple fix may be to just assume the syntax is Syntax #2 after an error is found parsing what "might" be an expression (Syntax #1).
This is anything but simple with the current design.

Feel free submit a pull request on GitHub or post in Suggestions on documentation improvements. Ragnar seems to be actively implementing suggestions. I am not inclined to think about documentation right now.
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Winmove error with "[" in window title

10 Dec 2017, 13:43

I have noted this issue in: Suggestions on documentation improvements

thank you to all who provided feedback.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 16 guests