More consistent syntax (5 fixes)

Propose new features and changes
john_c
Posts: 453
Joined: 05 May 2017, 13:19

More consistent syntax (5 fixes)

12 Jun 2020, 15:42

1. To make K&R style work everywhere. Some people strongly prefer to have as fewer empty lines as possible. With the current limitations, it's not possible to use K&R consistently.

2. To make ClipWait use milliseconds instead of seconds. To stay consistent with Sleep, SetKeyDelay, etc.

3. To fix the issue that ClipboardAll assignment cannot be a part of a chain of comma-separated expressions.

4. To force parenthesis after If. (To prevent a lot of mistakes from people who don't use them.)

5. FileAppend and Send should treat `r as `r, and `n as `n. Neither one should be automatically converted to `r`n unless we explicitly ask about it.
lexikos
Posts: 7064
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: More consistent syntax (5 fixes)

12 Jun 2020, 17:17

  1. Try AutoHotkey v2-alpha.
    It's supported there, and can't be supported consistently in v1 because the { is sometimes a legitimate literal character.
  2. I'll consider it for v2, along with WinWait and co.
  3. Try AutoHotkey v2-alpha.
    The ClipboardAll() function replaces the ClipboardAll variable. It returns an object rather than raw binary data, and does not have the original quirks. It could be back-ported to v1, but that sort of thing is a very low priority for me.
  4. Try AutoHotkey v2-alpha.
    Parentheses aren't required, but it shouldn't be an issue since there's only one type of IF.
  5. FileAppend: Try AutoHotkey v2-alpha. It does not translate line endings by default.
AutoHotkey v1 is intended to retain compatibility with existing scripts (despite having sometimes failed at that). Most of your requests require breaking compatibility, and have already been implemented in v2-alpha for that reason.

Send does not convert `n or `r to `r`n. Send sends keystrokes by default. The only keystroke corresponding to `r or `n is {Enter}. In fact, Send `r`n sends {Enter}{Enter}. This is counter-intuitive since `r`n is pretty much always intended as a single line ending.

However, if you're sending raw text, you should be using the {Text} mode. This mode also does not convert `n or `r to `r`n. What it does is convert each `r`n, `n or `r to a single Enter keystroke. This is for two reasons: 1) scripts often use `n as a line ending (it's the default for continuation sections) even while targeting applications that use other line endings; 2) sending the raw character code is very unreliable. I tested sending the raw character codes for a`nb in a few applications, and my results were:
  • Firefox and Visual Studio printed "ab", dropping the `n completely.
  • Notepad automatically converted the `n to `r`n.
  • SciTE and Notepad++ (both Scintilla-based) inserted `n, inconsistent with the rest of the document but (iirc) consistent with pasting from the clipboard.
If you want to try it anyway, you can use Send {U+A} (`n) or Send {U+D} (`r).

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 2 guests