Jump to content

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

AutoHotkey_L v1.1.00


  • Please log in to reply
17 replies to this topic
Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
1.1.00.00 (May 1)

New features:
Implemented basic class definition syntax.
Implemented the new keyword for creating a derived object.
Added Func() for retrieving a reference to an existing function and improved IsFunc to recognize function references.
Added support for ++ and -- with object fields, such as x.y[z]++.

Changes:
Changed __Delete to not trigger __Call.
Changed OnClipboardChange to use AddClipboardFormatListener when available (i.e. on Windows Vista and later) to improve reliability.
Auto-concat with ( is more selective, so some invalid expressions like 12(34) will no longer work.

Fixes:
Fixed SetTimer Label, -0 to be treated as "run-once, very soon".
Fixed A_MyDocuments etc. to use SHGetFolderPath instead of undocumented registry keys.
Fixed non-empty ExcludeText causing windows with no text to be excluded.

If you found the old documentation for objects hard to follow, please give the new documentation a try.
Downloads (etc.)

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
new docs are better, i am grasping the whole objects thing a lot more than last time. but i found the this.base.base stuff confusing in the object method section

also, from this link:

<!-- m -->https://ahknet.autoh... ... _NewDelete<!-- m -->

1. perhaps you should note how an object can be destroyed with an example.
2. how is the variable this.ptr accesible to both functions? its not declared as a class member variable. (same Q for the this.RGB var in the Color class example)

thanks

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
more docs comments:

"meta-functions" link under Custom Objects is 404

this could probably use a code example (quoted from object Prototypes)

When thing.test() is called, thing is automatically inserted at the beginning of the parameter list. However, for backward-compatibility, this does not occur when a function is stored by name (rather than by reference) directly in the object (rather than being inherited from a base object). By convention, the function is named by combining the "type" of object and the method name.



shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006

AddedFunc() for retrieving a reference to an existing function and improvedIsFunc to recognize function references

This is awesome!
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

but i found the this.base.base stuff confusing in the object method section

Which part? I wrote that section to clear up any misconception a user might have about using this.base.base.Method() to invoke the super-class version of Method. (See for instance the first comment in finc's post and my response.)

1. perhaps you should note how an object can be destroyed with an example.

You can't explicitly destroy an object. See Reference Counting.

2. how is the variable this.ptr accesible to both functions?

Quite obviously, via this. As the documentation explains, this is a hidden function parameter (i.e. an ordinary variable) which typically contains a reference to the object. Any reference to any object can be used to retrieve values stored in that object.

its not declared as a class member variable.

That's completely irrelevant. The concept of member visibility does not apply to objects in AutoHotkey, which are basically just associative arrays. See below.

Class variable declarations [...] do little more than storing a value in the class object.
Source: Objects - class vars

"meta-functions" link under Custom Objects is 404

Thanks. I frequently forget the "#" when linking to a location within the same document.

this could probably use a code example (quoted from object Prototypes)

That paragraph applies directly to the example above it. If you're referring to the part "by name (rather than by reference)":
[*:3tx27owk]I'd prefer not to duplicate the example to show such a minor difference. "FuncName" is a function name, while Func("FuncName") returns a function reference. This should be obvious if you've read the Function References section.
[*:3tx27owk]The ability to use function names in objects should be considered deprecated, since the behaviour is inconsistent (as explained in that paragraph) and performance is worse than with function references. I'd prefer not to write any examples using deprecated functionality.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
New docs are great :!:
Class is really nice :)
Thank you very much :D

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Very nice! I will use class syntax for new objects I'll create.

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

The docs look much much better. I'm looking them over and starting to get some of the newer syntax.
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
Oh my, I need to make a script to auto-update _L! So many good things in every release :)
Thanks very much for improving OnClipboardChange - there goes all my workarounds out the window ;)
We're just missing 1 thing from the "what can't AutoHotkey do?" thread - native toast support

; Purpose - new toast syntax ideas
MakeToast, OutputToast, time, settings
Toast := MakeToast(Time, settings, butter=false)
Although with class syntax...

Thanks again for all your efforts Lexikos

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Oh my, I need to make a script to auto-update _L!

There's an update script included in the installer.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
:lol: my bad... I'll add it to startup...

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

but i found the this.base.base stuff confusing in the object method section

Which part? I wrote that section to clear up any misconception a user might have about using this.base.base.Method() to invoke the super-class version of Method. (See for instance the first comment in finc's post and my response.)


yeah i got it now. reading that and also the latest comments in the Class Syntax thread helped

2. how is the variable this.ptr accesible to both functions?

Quite obviously, via this. As the documentation explains, this is a hidden function parameter (i.e. an ordinary variable) which typically contains a reference to the object. Any reference to any object can be used to retrieve values stored in that object.

its not declared as a class member variable.

That's completely irrelevant. The concept of member visibility does not apply to objects in AutoHotkey, which are basically just associative arrays. See below.

Class variable declarations [...] do little more than storing a value in the class object.
Source: Objects - class vars


would defining the class this way have any merit other than code readability and reader comprehension?

class GMem
{
   [color=red] var ptr[/color]

    __New(aFlags, aSize)
    {
        this.ptr := DllCall("GlobalAlloc", "uint", aFlags, "ptr", aSize, "ptr")
        if !this.ptr
            return ""
        MsgBox % "New GMem of " aSize " bytes at address " this.ptr "."
    }

    __Delete()
    {
        MsgBox % "Delete GMem at address " this.ptr "."
        DllCall("GlobalFree", "ptr", this.ptr)
    }
}


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

would defining the class this way have any merit other than code readability and reader comprehension?

Generally no.

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Very nice
Never lose.
WIN or LEARN.

a4u
  • Guests
  • Last active:
  • Joined: --

Added Func() for retrieving a reference to an existing function and improved IsFunc to recognize function references.

Very nice - though I just realized that this returns a Func Object. Should this be listed under objects in the the Help File?