Jump to content

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

Gathering ideas for AutoHotkey v.2


  • Please log in to reply
126 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
What symbol u use for := is not the question of confusion. Just stick to 1 and nobody will have any problems.


<< is both bit shifting and stream operator in C++, and there is no confusion.

?
Acctually, it can be anything in C++ as of operator overloading.
Posted Image

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
I also prefer "AND" and "OR" for readability.

Thalon

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006

foom, stop talking about "other popular languages", I believe most of the population of AHK users never programmed before, or used only Basic before...

Let me explain you my point of view and how i learned AHK.
I did my first programming in 2003 because i was so impressed by <!-- w -->www.derbauer.de<!-- w --> . Thats where i learned some of the concepts of programming like variables, types, functions, OOP. This doesn't mean i could use it in a professional way but i knew what an operator is and wasn't completely clueless when seeing source code of other programming languages like c++. Later i did some mirc scripting because it was nice to have some task automated in mirc (and the help file was so easy to understand for someone with almost none programming experience). Then i wanted to do some more serious programming and started to read c++ tutorials but as soon as i got to the chapter with pointers i was lost. By accident i found AHK on google and after i read the Quickstart-Tutorial i was hooked up. There was everything that i expected to do in c++ at that time and more. And it was all so simple and nicely documented. Now because i already knew the basics of programming i was able to quickly soak up what AHK has got to offer. The only holdup was with confusions about := and =. After only 1 week i started to do dllcalls ,to access DevILs capabilities to load different image formats, and started to give help on the forums to newbies. From using dllcall i learned about pointer that earlier confused me so much in c++. Now i am much more c++ aware than before without actually haved programmed anything in c++.

My main concern is about people having the same experience like me. If they move on to other languages after learning AHK first it would be nice if they already know the most common operators and concepts like strings are enclosed in quotes and all that. Now i know that this doesn't apply to all other languages. But its likely that the next language someone who started with AHK is going to be confronted with is c++ because he will be confronted with it when he starts dealing with DllCall. And most of the "Programming For Dummies" like tutorials that you find online tell you to learn a powerful language like c++ or java from the start. This was my experience. Trust me i know whats hard to learn for a programming newbie like myself was 2 years ago. Its really hard to get the concept of only 1 language into your head and if most of the concept can be adopted to other languages this is very convenient and a time saver. I have the feeling that you cannot think back to your first programming experience like i can. For me its 6 months of AHK in which i learned more about c++ then the year before trying to learn c++ on its own. You probably programm since 10 years and more and also is Chris and all the other guys here with > 1000 posts. For you a function is something natural for a newbie its something really confusing. Keep that in mind when you think of what a newbie feels like learning ahk. He might not have a slight idea of what a function or an operator is about. But if he has and the concept is the same he will quickly be able to progress.

To cut a long story short AHK has a educational influence on newbies. Make this influence as fruitful as possible.

This post isn't only targeted at you but also at Chris since he is the one that will make the final decision. And i hope he understands my concern.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I have the feeling that you cannot think back to your first programming experience like i can. [...] You probably programm since 10 years and more and also is Chris and all the other guys here with > 1000 posts.

I remember my first real programming experience (beside reading books on the subject...): it was on a TI-57 calculator (Texas Instruments), one of the first programmable calculator, a mix of assembly language and higher level computation (like those you can do on a calculator!).
Later I had a TI-59, able to save programs on a band of magnetized cardboard... On TI-57, you shut off the calculator, you loose the program (very small memory anyway).
I got it around my 18, that is some 27 years ago... :-)
I save you the list of computers I owned or played on...

I understand your feelings, but AHK is a programming language of its own, with its own constraints. Designing a language is delicate, a balance between familiar look-and-feel, ease of learning, clear syntax, ease of use and power.

Now, were are here to give hints on what seems right for us. I let Chris make the final choices and will use whatever he designed. Well, I have an advantage, having learnt a number of different languages, I can quickly adapt to a new one and I learnt to use its peculiarities instead of complaining about them...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006

... that is some 27 years ago ... :-)

:shock: Holy cow! This is probably longer than the time my parents know each other. :lol:
Edit: Don't mean to make you feel old. :lol:

Now, were are here to give hints on what seems right for us. I let Chris make the final choices and will use whatever he designed. Well, I have an advantage, having learnt a number of different languages, I can quickly adapt to a new one and I learnt to use its peculiarities instead of complaining about them...

I think you are getting me wrong there. I don't complain because i'll have to adapt to the changes. I'll take them as they come and Chris isn't going to change it to become worse.
While i understand that AHK is a language on its own, i also know that while changing the syntax of ahk, this is the opurtunity to make it more common, for the reasons i explained in my post above.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I don't complain because i'll have to adapt to the changes.

I didn't meant that, I wrote that for me: good or bad changes (the later being unlikely...), I will still use AHK. Hey, language was quirky from the start (I used AutoIt 2...), it didn't prevented me from using it, and it can't become worse! :-) (mm, that's what you wrote, let's say we agree on this... ;-))

While i understand that AHK is a language on its own, i also know that while changing the syntax of ahk, this is the opurtunity to make it more common, for the reasons i explained in my post above.

That's were we disagree...
AutoHotkey's main goal should be, IMHO, to stick to its original purpose: to automate Windows with a simple syntax.
Secondary goal is to make it a general useful programming language.
The objective of making it a first learning language as a bridge to more "common" languages seems dummy for me.
Plus you suppose people will then learn C or a derivative. I believe that they might instead turn to some Basic dialect. That's another "common" popular language, with different syntax. Lot of people use Delphi too. What about Perl or Python? They are quite popular too...
In programming language field, there is not "one true way"... :-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

foom
  • Members
  • 386 posts
  • Last active: Jul 04 2007 04:53 PM
  • Joined: 19 Apr 2006
Dummy in the sence of not inventive? Why reinvent the wheel?
I suppose they will learn a c++ like syntax since c/c++,java,js,actionscript, and others have similarities whereas for example basic or ruby or whatnot are loner.

But now i'll try to keep my mouth shut until chris comes up with his rough draft.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I meant dubious, not dummy... Ie. I doubt Chris should take in account this objective in designing AHK.

I like C-like syntax, I used it a lot, but now I know that's not necessarily the best syntax. "Best syntax" doesn't even exist...
Basic can be a loner, but VB and friends (VBA, VBS, RealBasic, DarkBasic, BlitzBasic, PureBasic, Liberty Basic and lot more) are overall very popular and lot of programmers use it.

Overall, important points is to be consistent, to avoid multiple ways to do things (or hide them...). Note that having InStr and RegExMatch doesn't seem duplicate for me, for example...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Another suggestion for AHK v2:
Limit the avialable characters for label names the same way as for function and variable names:

Variable names are not case sensitive. Variable names may be up to 254 characters long and may consist of letters, numbers and the following punctuation: # _ @ $ ? [ ]

It will improve/enforce readability and ease parser scripts.

Edit:
- Maybe remove the ? from the list for all names, thus allowing the ternary operator to be recognized without spaces.
- Maybe remove the [] from the list for all names, thus preparing to be used by arrays.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

Another suggestion for AHK v2:
Limit the avialable characters for label names the same way as for function and variable names:[...]It will improve/enforce readability and ease parser scripts.

This has been made, I think, to support auto-labels:

If a button lacks an explicit g-label, an automatic label is assumed. For example, if the first GUI window contains an OK button, the ButtonOK label (if it exists) will be launched when the button is pressed.

This feature is bad idea anyway. What if the button name has spaces in it? Explicit labels seems better. I suggest to remove the feature and simplify labels.

- Maybe remove the ? from the list for all names, thus allowing the ternary operator to be recognized without spaces.
- Maybe remove the [] from the list for all names, thus preparing to be used by arrays.

Argh! Removing spaces seems always a bad idea... :-)
The removal of [] is already planned.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

Argh! Removing spaces seems always a bad idea... :-)

...aargh!...spaced out code is hard to read...yes, I want the ternary without spaces too!...& .= needs spaces?...why?

2) The Clipboard variable supports only the first five of these operators, and only when that operator is leftmost on a line

...ok "first 5" is ":= += -= *= /=" right?...why don't clipboard support .=?...(just wondering if it's a quick fix {I don't think I need it anytime soon})...
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
:D Warcraft 3 TFT (The Frozen Throne) got me into programing, I used their World Editor's GUI of the JASS(Java Applications Something Something :D) to make spells and games and such, and I still occasionally mess around on it. I should learn JASS for Warcraft..... :D :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here's my response finally. Sorry for the delay.

I believe we should keep literal assignment, as it is convenient, and I like the dereferencing.
To avoid any ambiguity, it could have a very different symbol, so there would be no ambiguity by using it.
I propose to use <<.

This is good. Something like this should probably get implemented in v2.

to concatenate strings to the end of a variable, a very common operation.

var .= result . "`n"
res <<< result`n

The benefits of this are less compelling. It might be better not to implement it to reduce documentation complexity and learning curve, as well as to reduce code size. But I'm not sure, so certainly it should be given more consideration.

You would need to write:

a :=
(
 "one" .
 "two" .
 "three"
)
I am not fan of this...

It's not necessary to write it that way. You can write it as:
a := "
(
one
two
three
)"
But maybe I'm misunderstanding your intent.

Possible, the best way is to use proposed << operator, to keep the old behavior. Continuation sections [containing unquoted strings] can be done as
x << (
....
)

Thanks for the idea.

I want to know if droping support for naked strings would increase the performance of expressions. And if naked strings in commands could stay, as commands get a different treatment(i suppose) by the parser/interpreter as other code.

It wouldn't help performance because expressions and non-expressions are separated during the script-loading process. So while a script is running, it knows the difference immediately, so no time would be saved.

- Drop the obsolete convention that space is a concatenation symbol in expressions. Let the space-dot-space be the official and only symbol. Here again, too much possibilities are confusing, and the old convention proved to bring ambiguity and bugs.

So a = It's cool would generate a syntax error message.

This is a very good point. I think the single biggest problem with allowing "automatic concatenation" is that it prevents detection of mistakes that the user would want to know about. For example, if someone writes var := This is a string (i.e. without quotes), the current implementation can't detect it as an error because it thinks you're concatenating a bunch of variables with strange names. On the other hand, v2 will probably detect the use of uninitialized variables, so it may warn you that "This" is being used without having been initialized. If that is enough warning to catch most unintentionally unquoted strings, we might be able to keep automatic concatentation because obviously some people prefer it (though from a purity and ambiguity standpoint, it is a bad feature in hindsight).

Should we keep the same extension? Of course, we can tweak the registry if we want to change this at our own level, but an official support would be better.
Should we have .ahk2 scripts? Or .ah2, if we absolutely want to stick to 3 letter extension? (No real need here.)

This is a difficult decision. Although I'm very reluctant to create a new extension such as .ah2, it may solve many problems and save users a lot of trouble. The final decision will depend partially on how extensive v2's changes are.

Likewise, perhaps we should create a new code tag (code2?) with distinct colors, so we can see at a glance which AHK is necessary to run it.

That's a good point. I'm going to look into an automatic conversion of all old scripts on the forum. However, that may be difficult, and it might create too many new problems.

Create a new "Scripts And Functions" forum... [or] all posts in the forum could be marked by putting [#v1] before every [topic title]

There are also useful scripts in the Ask for Help section... And people might want to be able to still publish scripts for AHK 1.

These are good points. They'll all be discussed/considered again when the time comes.

This is another inconsistence some new users do not understand.

if (Var1 = 1 OR Var1 = "String")
If you set the quote-char around "1" it will not work without any shown reason or error.

I don't understand.

its 6 months of AHK in which i learned more about c++ then the year before trying to learn c++ on its own.
… To cut a long story short AHK has a educational influence on newbies. Make this influence as fruitful as possible.

I appreciate your viewpoint. Lately, I've been trying to shift AutoHotkey's direction toward other languages, such as C-like syntax (where it makes sense and does more good than harm) and better naming conventions (such as SubStr vs. StrMid).

Another suggestion for AHK v2:
Limit the available characters for label names the same way as for function and variable names… It will improve/enforce readability and ease parser scripts.

The reasons for changing this don't seem too compelling, but I'd like to hear more if anyone feels strongly or can think of other reasons. Like others have said, the purpose of v2 isn't to make changes that have marginal benefit. Such changes tend to cause more confusion than they're worth.

If a button lacks an explicit g-label, an automatic label is assumed. For example, if the first GUI window contains an OK button, the ButtonOK label (if it exists) will be launched when the button is pressed.

This feature is bad idea anyway. What if the button name has spaces in it? Explicit labels seems better. I suggest to remove the feature and simplify labels.

If the button name has spaces or &'s in it, they're omitted from the label name as documented. I think automatic button labels are a convenient feature and should be kept. If you still disagree, please explain in more detail why they're bad.

2) The Clipboard variable supports only the first five of these operators, and only when that operator is leftmost on a line

...ok "first 5" is ":= += -= *= /=" right?...why don't clipboard support .=?

Operators like := have a command behind them. But new operators like ".=" are pure expressions, and the clipboard variable isn't supported in expression assignments because the added code complexity is large and doesn't seem worth it. But this may change in a future version.

In hindsight, the clipboard variable is probably one of the biggest sources of complexity and bugs in the code. It taints the concept of a variable throughout the program, which produces code that's larger and harder to maintain. In v2, the clipboard variable could be replaced by built-in functions or some other syntax. However, this might be more trouble than it's worth -- especially since so many users find the clipboard variable simple and convenient. So the clipboard variable could wind up staying as it is.

Concerning the need for spaces around the dot, .=, and ? operators, I hope to resolve that in v2 (and possibly sooner for the dots).

Thanks for all the ideas.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

You would need to write:

a :=
(
 "one" .
 "two" .
 "three"
)
I am not fan of this...

It's not necessary to write it that way. You can write it as:
a := "
(
one
two
three
)"
But maybe I'm misunderstanding your intent.

I gave the current syntax, the only allowed if literal strings are banned... I don't like the second syntax either...

This is another inconsistence some new users do not understand.

if (Var1 = 1 OR Var1 = "String")
If you set the quote-char around "1" it will not work without any shown reason or error.

I don't understand.

In the above example, I think that the 1 was the variable holding the first command line argument.

If the button name has spaces or &'s in it, they're omitted from the label name as documented. I think automatic button labels are a convenient feature and should be kept. If you still disagree, please explain in more detail why they're bad.

Yes, I have re-read the manual later and re-discovered this "compression" stuff...
I am not fan of auto-labels, but why not, after all. Perhaps you should be a bit more restrictive on labels (exclude : from them, for example) and suppress new forbidden chars as well.

In v2, the clipboard variable could be replaced by built-in functions or some other syntax. [...] So the clipboard variable could wind up staying as it is.

I vote to suppress it in favor of a function or two, like that auto-environment variables are removed. I don't mind keeping it, but if that can simplify the code and avoid exceptions in treatment, it can be worth it.

Concerning the need for spaces around the dot, .=, and ? operators, I hope to resolve that in v2 (and possibly sooner for the dots).

If you allow no dots around concatenation dot, then it won't be available for associative arrays.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
Ooo I have an idea! I ran into a problem a while ago involving naming a variable with a variable. When setting a variable, the var to the left of the = sign should not have percent signs, unless you want to use the contents of that variable to be the name the variable that is being set by what is on the right of the = sign.

Also, my far-fetched Attachment Variable idea is interesting, and would be used with ListBox, TreeView, calenders, datecals, Listviews, and things of that sort. There would be the regular variable to be assigned to the control via the "v" coming before the var name, but for attachment variables, you can have some other sign in front of it and can be placed where glabel, position, and variable is. The use of these Attachment variables would be that they could store text and such. They could possibly not have a name, the only name being simple info about the control and what is being selected, so you can use it with ease later on for storing text, booleans, and things of that sort. You still may not see the for this, so I will try to give an example... Let's just say the thing that declares an attachment variable is the hyphen (-). Here goes:
gui, add, text,,Select item from list box', and then type things into the edit field', it will be stored in the attachment var of the listbox.
gui, add, listbox,,vListBox - gListBoxLabel, Red|orange|banana
gui, add, edit,vstuff,Bleh
gui, show,, Blah blah blah

ListBoxLabel:
gui, submit, NoHide
guicontrol, focus, %stuff%
SendInput, %CountDown% ;countdown could be one of those variables that are always there, like A_WorkingDir.

return

I've not tested the syntax, simply wrote it down, by the way.