DefineProp() and DefineMethod() Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
madsounds
Posts: 59
Joined: 31 May 2019, 08:14

DefineProp() and DefineMethod()

15 May 2023, 07:48

In AHK 2.0.2, how to add new property to the String class?
How to add new method to any class, since there's no more DefineMethod method>
teadrinker
Posts: 4371
Joined: 29 Mar 2015, 09:41
Contact:

Re: DefineProp() and DefineMethod()  Topic is solved

15 May 2023, 09:40

madsounds wrote: how to add new property to the String class?
Adding Properties and Methods
madsounds wrote: How to add new method to any class

Code: Select all

class MyClass {

}

MyClass.DefineProp('NewMethod', {Call: (this, params*) => MsgBox(params[1])})
MyClass.NewMethod('test')

MyClass.DefineProp('AnotherMethod', {Call: myFunc})
MsgBox MyClass.AnotherMethod('a', 'b', 'c')

myFunc(this, params*) {
    s := ''
    for param in params
        s .= param . ' '
    return s
}

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Bing [Bot], kunkel321 and 38 guests