Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AutoHotkey v2 Alpha Release


  • Please log in to reply
870 replies to this topic
IsNull
  • Moderators
  • 990 posts
  • Last active: May 15 2014 11:56 AM
  • Joined: 10 May 2007
Thanks once more for your hard work. Some points:

Legacy commands to consider keeping (for convenience): IfWinActive, IfWinExist, IfInString, IfExist. I personally don't find IfInString all that convenient. Should it be kept? Should the others be kept?

The If.. commands should be removed, as they can be easily be rewritten with literal Ifs. Also, I would simply not accept ifs without Braces "()", and throw a Compiler/Interpreter Error.

For AHK v2 I recommend to remove the Commands completly and replace them with Build-In Methods. Anything other confuses newbies.. For compatibility, I would add Function-command support to the current AHK_L branch so both is allowed. Also mark all Commands as Obsolete which is actually also the strategy of IA.

As a substitute for SetFormat (which has been removed), I've included a script function for formatting strings. Take a look in Lib\format.ahk for a description of the syntax. It is basically a mixture of .NET's String.Format function and the C runtime's format specifiers. Any comments or suggestions about the syntax are welcome. Once the syntax is finalized, I'll add a built-in function.

Perfect.

Similarly, I plan to replace If Var is [not] type with a new "is" operator

Perfect.


Are there any objections to renaming URLDownloadToFile to just Download?
I notice that IronAHK has a "UriDownload" function, but I wonder what the point was.
My understanding is that a URL is a specific type of URI which includes information about how to locate the resource.
To download something, you need to know where it is and how to get it; i.e. you need a URL. Either way, "URI" or "URL" seems unnecessary.

About IA UriDownload: A very often seen task is to download some text (html) from the internet, so the initial behavior should be that UriDownload is a function which returns the downloaded data. To support binary data / large Data there is also support for writing it into a file. The naming changes were initially thought to not break existing scripts. URLDownloadToFile calls internaly UriDownload for compatibility.

Also, for automating purposes POST Parameter support is planed, so it would be gread when IA/AHK v2 Syntax stay together. Any plans to support POST params, maybe also build in Cookie support?

There might be some optimization potential to AHKs window Class/ID handling. I'm currently rewriting the IA Linux X11 implementation, and there are some things which would be great if AHK puts some more abstraction in it, so scripts can run better on both platforms.

The primary idea should be to define a AHK V2 SYNTAX - which Interpreter/Compiler is used shouldn't matter. That said, I would welcome a Syntax Definition, Command Library Overview, even when some things currently arn't implemented. This would it make much easier to have IA near AHK (v2). Like yet, some detailed destination where AHK v2 will go.
The main Problem I had with AHK_L was, that you've added things without first defined where you want to go. ;)


Last but not least: Any plans to support optional typing of variables?
Benefits:
* IDE can provide Member listing help (Intelisense), instant validating
* Method parameters can be validated by IDE
* Optional means: Newbies doesn't have to care about but Pros can speed up code, better overview in bigger projects

It's not necessary that typed Variables are handled as native type, if AHKv2 did not has the matching Code Design, but IDE support will make Coding much more comfortable and faster. Also, misspelling errors which are very often cause for AHK Script errors can be detected on any minimal Intellisense Logic.

This is a very important point for me, I would be interested to discuss this point in detail - maybe in a separate thread or over email.

cheers

maul.esel
  • Members
  • 790 posts
  • Last active: Jan 05 2013 09:26 PM
  • Joined: 28 Feb 2011
Well, my opinons (in random order):
[*:3v8cttrw]Personally, I don't like this #DerefChar $ thing. To me, the current syntax is good as it delimits the variables clearly. Additonally, I think this would be a new source of confusion, e.g. when taking code from the forum or in an IDE as already mentioned.
Or think about
Var := "InStr"
MsgBox %Var(Var, "-")
Does this call InStr() or Var() ?

[*:3v8cttrw]The is / contains operators would be great.
A function for Between would be ok, but it is not really necessary as its just some characters more to type if (var > 5 && var < 10)

[*:3v8cttrw]I'm not sure about removing literal assignments, but var`= D looks quite ugly.
[*:3v8cttrw]Additionally, I would suggest that there's just one expressional operator:
var = MyVar
var := MyVar
Just one of these should be valid in my opinion.

[*:3v8cttrw]Escaping quotes with standard escape char is a good idea.

[*:3v8cttrw]As objects (and even json :D) are supported, I think objects instead of long parameter lists would be good:
InputBox % {prompt : "type any char", title : "Inputbox"}
I think IronAHK's mail command also uses this. (The same with WinExist as flak suggested)

[*:3v8cttrw]Native struct support would be incredible :shock:

[*:3v8cttrw]The file extension should be different, but I don't think it's difficult which one to choose.

[*:3v8cttrw]At least in the begginigs (let's say up to 1st final version) the installer should not touch any existing AHK-Installation (I didn't test it yet, so if it's already like that, leave it like that ;-))

[*:3v8cttrw]One thing which is badly needed in my opinion is more support for object syntax. Version 2 should e.g. accept Object.Count++

[*:3v8cttrw]I would support the removal of IfWinActive, IfWinExist, IfInString, IfExist etc. They are all covered by built-in functions.

[*:3v8cttrw]Another idea would be an exclusive Or operator.

[*:3v8cttrw]About non-ascii characters in variables: I don't use them, however they aren't a problem (right :?:), So I would keep them.

[*:3v8cttrw]Treeview and Listview functions could be extended (e.g. TV_SetImageList()) (:oops: oops, this isn't wish list :lol:)

[*:3v8cttrw]Auto-concat is quite important, keep it !

[*:3v8cttrw]Output arrays are a good idea, this keeps things a lot simpler. But keep it consistent: don't make one command / function use it while another does not.

[*:3v8cttrw]UrlDownloadToFile could be shorter, as well as WinMenuSelectItem (MenuSelect?)

[*:3v8cttrw]The changes to SubStr(var, -1) are more intuitive, that's right.

[*:3v8cttrw]Renaming the Loop-commands would also be more intuitive, I think

[*:3v8cttrw]Merge the tab control types. (And maybe allow tabs inside tabs?)

[*:3v8cttrw]Default values for SetWorkingDir and SingleInstance would be good. Would it be possible to make SingleInstance a command to change it during runtime? (damn, again not wishlist :lol:)
Regards
maul.esel
Join the discussion on The future of AutoHotkey
Posted Image Visit me on github Posted Image
Win7 HP SP1 64bit | AHK_L U 64bit

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009

[*]Output arrays are a good idea, this keeps things a lot simpler. But keep it consistent: don't make one command / function use it while another does not.

I agree with this, get rid of the pseudo-arrays. It's really strange if a command defines variables which are not directly passed as parameters.

[*]Merge the tab control types. (And maybe allow tabs inside tabs?)

While we're at it, what about window panes?

  • Guests
  • Last active:
  • Joined: --

X = Y is no longer a literal assignment.

...does that mean = is now the same as := ?

Var declarations (using local/global/static) require := rather than =, for consistency and clarity.

...if, per above, = is now the same as :=, why require := on this? := should likely be removed (or re-purposed), in favor of = doing that job (like in JavaScript).

At least two notable forum members have expressed a desire to remove literal assignment (var `= value) entirely. I like this idea. Do you?

...Hell no!...I mean "please don't, at least not without something to address the following concerns"...I NEED some type of "literal" equals (not sure x`=y is really that good of syntax tho), cuz Continuation Sections+Expressions=Headache.

I would like to replace the syntax for continuation sections... Unfortunately, I have not come up with any "good" ideas.

...how about HereDocs &/or NowDocs? There needs to be some way to do Continuation Sections, either with literal syntax or with expression syntax, but not as difficult as you currently need to do. This example works, but try to create it yourself, from scratch...see how you need to do the double quotes weird, in the expression version, to make it identical to the literal version...

somevar=It worked!
somenum=19

somemath:=somenum*2
literal_continuation_section=
(LTrim
	Testing1(%somevar%)

	Testing2(%somenum%)

	Testing3(%somemath%)
)

expression_continuation_section:=
(LTrim
	"Testing1(" somevar ")

	Testing2(" somenum ")

	Testing3(" somenum*2 ")"
)

if (!(literal_continuation_section==expression_continuation_section)) {
	dont:="DON'T "
}

msgbox, 64, ,
(LTrim
	They %dont%Match!

	---literal_continuation_section---
	(%literal_continuation_section%)

	---expression_continuation_section---
	(%expression_continuation_section%)
)

I would like to support variable derefs inside quoted literal strings.
Opposite to the above, "%var" could contain a variable deref while '%var' is purely literal. I think that Perl and Bash scripts use this convention.

...yes, I support the one you call "Opposite"...which is actually the correct version, double quotes have been used as the var-derefing quote in MANY languages, no need to reverse that for AHK. Double-quote = var derefing, Single-quote = extremely literal, in fact this is the exact difference between HereDocs & NowDocs.

If Expression, Command is now a valid If statement with same-line action, since the late IfEqual and related commands had this capability. The comma is required.

...OK, for the following, I understand the comma being required...

if i=1, msgbox, wow
...however, I'd like the comma to not be required, when using parens around the expression, like in JavaScript...

if (i=1) msgbox, wow
...or...
if (i=1) { msgbox, wow }
...if you support braces on the same line, like that.

I always use parens on my if's & this would look really bad...& it would be unnecessary...

if (i=1), msgbox, wow
...at the very least you don't really need both the comma & parens as a hint to when the expression ends.

Speaking of "if (i=1)" are you gonna treat that as a comparison?...or change it to the more common "if (i==1)"...for comparison? I don't know what's currently in _L & what all's planned, but I'd like to mirror as much of JavaScript as possible. = is always assignment, == is always normal comparison (normal, but case-sensitive {like JS}, perhaps a function for non-case-sensitive matching), === is "exactly the same" comparison.

Also, how do you feel about plus (+) working as a concat operator?...or at least adding a #ConcatOperator directive, so I can enable it? Plus (+) works as both addition & concat in JavaScript, so I see no reason why it can't be supported in AHK (even if not "on" by default). Currently, I use "implicit concatenation", since I dislike dot (.) as concat operator...actually, I don't even know if dot is the concat oper in _L?...or is that just reserved for structs? I simply want some way to enable plus-as-concat, in my scripts (it should also add numbers correctly: 1+2=3, like in JavaScript, but concat "numbers in string form": "1"+"2"="12"...actually the rule is simple: if both sides of the operator are numbers, add them, if either side is a string, concat them).

If there is demand, I might change it to ".ah2" as suggested in the plan.

...I oppose all extension renaming. .ahk is "pretty", .ah2 or any other extension with a number is ugly. I do, however support "includes" being renamed to .ahi, AutoHotkey Include. .ahk = a script to double-click & run, .ahi = an include file, that does nothing if run directly. At the very least, if you do decide to rename things, allow some way, for me to un-rename them & still have the same behavior...I know I can rename files myself, but _L needs to treat files with ".ahk" extension the same as ".ah2" (if you end up renaming them). Version compatibility should be done with a #Version directive, not with the file extension.

infogulch
  • Moderators
  • 717 posts
  • Last active: Jul 31 2014 08:27 PM
  • Joined: 27 Mar 2008
Yeah I was confused about transform, deref and eval(). Revised:

If you remove literal assignment (which I support) then variable dereferences in quoted strings should be added.
string := "hello"

;v1
var = %string%, world

;v2 equivalent
var := "%string%, world"   ;or single quotes, whichever we decide

In that case if we remove Transform, Deref and add a generic Eval() function that evaluates any string as an expression, these would be equivalent:
string := "hello"

code := "`%string`%,``t world" ;this would yield the literal, unevaluated string:   %string%,`t world

;v1
Transform, var, Deref, %code%

;v2 equivalent:
var := Eval('"' code '"')   ;note that surrounding it with the decided dereferencing quote chars makes it a valid expression
; see v2 code in the block above; this is exactly the same, except dynamic

This is also a very important reason to support both single and double quote characters for defining strings in expressions, it makes it waaaay easier to actually include a literal quote character in a string.

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008

...if, per above, = is now the same as :=, why require := on this? := should likely be removed (or re-purposed), in favor of = doing that job (like in JavaScript).

Currently the := serves the purpose of assignment, no matter what. That means you can do: If (A_Is_Equal_To_B := A=B) and you have the value for later use. I use this often. On the other hand, it could easily be replaced with another symbol.

...however, I'd like the comma to not be required, when using parens around the expression, like in JavaScript...

if (i=1) msgbox, wow

Look at this code:
if (i=1) msgbox, msgbox, wow
The problem with this is auto-concat. Instead of running the msgbox command it concats the bool value (i=) and the string value of msgbox. The parser has no way to tell if you want to join a variable named msgbox with the first value, or if you want to call the msgbox command and theres no way to tell.

I have been a supporter of auto-concat and I don't think this merits getting rid of it (possibly biasedly). If there were more reasons I might change my mind.

...or...

if (i=1) { msgbox, wow }
...if you support braces on the same line, like that.

However, this could be done. I would like to see this.


Speaking of "if (i=1)" are you gonna treat that as a comparison?...or change it to the more common "if (i==1)"...for comparison? I don't know what's currently in _L & what all's planned, but I'd like to mirror as much of JavaScript as possible. = is always assignment, == is always normal comparison (normal, but case-sensitive {like JS}, perhaps a function for non-case-sensitive matching), === is "exactly the same" comparison.

I like the two variations of compare. = for case-insensitive, == for case-sensitive. When you know it will always be the same case use ==. For new users they can always use = and be safe. As for making AHK like javascript, I think it should be kept as a separate language. That's why there are different languages for different tasks and different tastes.

Also, how do you feel about plus (+) working as a concat operator?...or at least adding a #ConcatOperator directive, so I can enable it? Plus (+) works as both addition & concat in JavaScript, so I see no reason why it can't be supported in AHK (even if not "on" by default). Currently, I use "implicit concatenation", since I dislike dot (.) as concat operator...actually, I don't even know if dot is the concat oper in _L?...or is that just reserved for structs? I simply want some way to enable plus-as-concat, in my scripts (it should also add numbers correctly: 1+2=3, like in JavaScript, but concat "numbers in string form": "1"+"2"="12"...actually the rule is simple: if both sides of the operator are numbers, add them, if either side is a string, concat them).

A common trick is to convert strings to numbers by doing StringVar+0. Or to convert numbers to strings by doing NumVar . "". I don't want to be throwing around static_cast<string>(NumVar) like in C++ :wink:
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
I'm impressed - didn't think AHK v2 was this far along :)

At least two notable forum members have expressed a desire to remove literal assignment (var `= value) entirely. I like this idea. Do you?

...I mean "please don't, at least not without something to address the following concerns"...I NEED some type of "literal" equals

I agree that there should be some sort of literal assignment. Since commands accept literals, how about an Assign Command?
Assign, var, value

X = Y is no longer a literal assignment.

...does that mean = is now the same as := ?

Based on the AHKv2 documentation, I was under the impression := was going to be replaced by =.

I would like to replace the syntax for continuation sections... Unfortunately, I have not come up with any "good" ideas.

Since continuation sections seem to be unique to AHK, you could probably use whatever syntax and people could just adjust without too much confusion.

On that note - I would like to support variable derefs inside quoted literal strings. There are a number of different possibilities:
[*:360x563t]...[*:360x563t]Both types of quote marks could be equivalent, for convenience, and both could allow variable derefs.

I initial thought is that making them different would cause confusion (especially for noobies). I would vote for special syntax to deref a variable in a sting - for instance Ruby uses #{var}

  • Guests
  • Last active:
  • Joined: --

Look at this code:
if (i=1) msgbox, msgbox, wow
The problem with this is auto-concat. Instead of running the msgbox command it concats the bool value (i=) and the string value of msgbox.

...I don't think I understand this example (for 1 thing: why double "msgbox"?). I always use an outer level of parens around the expression. I think if's should require parens, like JavaScript. For example, I would never write this...

if (i=1) && (j=1) msgbox, wow
...that does not have an "outer level of parens", I would write the above as either...

if ((i=1) && (j=1)) msgbox, wow
...(if I needed the inner parens)...or...

if (i=1 && j=1) msgbox, wow
...if I do understand your example, you mean it would be interpreting it like...

if (i=1 msgbox) msgbox, wow
...but as you can see, if that is what I meant, I would move the parens around like this. If if's were changed to require an "outer level of parens", around the entire expression (like JS), I think that would cure the problem you are describing...or even a directive: #IfsRequireParens

I don't want to be throwing around static_cast<string>(NumVar) like in C++ :wink:

...no, I'd recommend something like, built-in functions: toNum(), toStr()...or even methods off the var or literal value: var.toStr(), "1".toNum()

JoeSchmoe
  • Members
  • 304 posts
  • Last active: Feb 28 2013 05:39 PM
  • Joined: 17 Feb 2008
I'm *so* thrilled to see this moving forward. Many thanks to Lexikos and the people who are taking the time to give good feedback for him (and to Polyethene, IsNull, and RaptorOne for the C# version). It is so wonderful to have such an active and healthy community!

I'm sorry to say that I have too much going on right now and can't contribute much on the details of Lexikos' syntactical questions. There is always an inherent danger when a bunch of super-smart and super-knowledgeable programmers are trying to upgrade a language that has a "killer feature" of being easy to use and learn. I haven't been able to read everything very carefully, but it looks like Lexikos is working very hard to solicit community feedback and guide it in the direction of keeping it simple and easy to learn.

The importance of this was underscored for me recently, as I've gotten my first alpha tester for the "self-discipline" script that I always have running. She isn't a programmer, but I've told her that AHK is incredibly simple and powerful, so she should be able to customize specific sections of the code with a relatively short learning curve.

When I read that Lexikos is working on allowing people to write code either using functions or commands, I'm thrilled because, for a non-programmer like my tester, I suspect that commands will be easier to learn. Either way, I can feel confident telling her that AHK has a good future, with two versions under active development, and that it will remain easy to use (and therefore continue to grow).

Thanks for all of your amazing work!

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
I honestly don't care if we keep literal assignments at all. `= seems like a good operator to me, but hey, I've done languages that ue := for expression assignment, = for expression assignment, = for comarison solely, == for comparison, and even /->/ for assignment (If ti-basic can be considered a language...) so any operator would be an easy adjustment.

The changes I feel strongly about are auto-concat (keep it, oh please keep it, it's faster to interpret, shorter to write, and . is a TERRIBLE concat operator), and/or changing the concat operator (how about &, as in VBS?), and the file extension (please change this somehow. There are so many good, but dead scripts that I want to be able to run without spending hours converting them). You could either make v2 be .ah2 or v2 be .ahk and v1 be .ah1, as blanket renames aren't hard at all (especially not with autohotkey ;) ), however a #v2 directive would eventually be made default breaking 6 years of dead scripts. Maybe instead a #V1 directive?

I would remove IfInString, IfWinExist etc in favor of If InStr() and If WinExist(), the latter just seems more clear to me.

As for between, we don't need a built-in function. Just remove it entirely. If anyone is desparate for it,
Between(var, low, high){
   return (var<=high && var >= low)
}
isn't that hard to make.

How is the website going to change to reflect all this? It would be disastrous for newbies looking at <!-- w -->www.autohotkey.net/~Lexikos<!-- w --> is certainly not the first place I would check for examples if I was a newbie stuck on something.

  • Guests
  • Last active:
  • Joined: --

...and/or changing the concat operator (how about &, as in VBS?)

...I'm strongly opposed to "&" for concat. But it may not be possible anyway (whew!) since "&" is used for "bitwise-and". I also strongly recommend "+" for concat (instead of OR in addition to dot for concat). Visual Basic is not a language to model after, JavaScript is.

  • Guests
  • Last active:
  • Joined: --
I understand only half because my school
English is not enough. :) But it looks good, keep it
up, and Autohotkey rescues from the
many versions.

igor

igor
  • Members
  • 1 posts
  • Last active: Apr 03 2011 08:10 PM
  • Joined: 03 Apr 2011
Damn, I was not logged in. :(

igor

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008

...if I do understand your example, you mean it would be interpreting it like...

if (i=1 msgbox) msgbox, wow

Yes. Sorry, that wasn't very clear at all.

...but as you can see, if that is what I meant, I would move the parens around like this. If if's were changed to require an "outer level of parens", around the entire expression (like JS), I think that would cure the problem you are describing...or even a directive: #IfsRequireParens

One of the things I like about AutoHotkey is it's not as strict as other languages. I like the freedom to write If (A>5) and (B<3) because it's clearer to me. Some might disagree.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010

Visual Basic is not a language to model after, JavaScript is.

How so? JavaScript is the language of the internet, while VBScript has been described as "the system administrator's language" and is much more widely used as a PC-scripting tool. In fact, it is what is mostly used on MSDN when referring to PC-scripting, (e.g., Sesame Script) and I was referred to AHK when I heard it was "Simpler, more intuitive, and more powerful than VBScript"