如何在AutoHotkey中创建一个类?

Ste*_*ica 1 autohotkey class

我想为AutoHotkey中的员工记录创建一个自定义类对象。该类对象将存储员工的年龄,姓名和职称。

例如,在Java中:

public class Employee {
    public int age;
    public String name;
    public String title;

    public Employee(int age, String name, String title) {
        this.age = age;
        this.name = name;
        this.title = title;
    }
}
Run Code Online (Sandbox Code Playgroud)

这样便可以为新员工设置属性。

Employee worker1 = new Employee(22, "Timothy", "Programmer");
Employee worker2 = new Employee(26, "Anthony", "Quality Assurance");
Run Code Online (Sandbox Code Playgroud)

我无法在AHK中找到具有等效功能的任何东西。据我所知,AHK中的对象在功能上是相当基本的。

如何在AutoHotkey中创建具有自定义属性的类对象?

Dav*_*lfe 5

我不在AutoHotkey中使用类,但是应该像这样:

Class Employee{
    __New(age, name, title)
    {
        this.age := age
        this.name := name
        this.title := title
    }
}

worker1 := new Employee(22, "Timothy", "Programmer")
worker2 := new Employee(26, "Anthony", "Quality Assurance")
Run Code Online (Sandbox Code Playgroud)

  • 实现这一点确实是一个晦涩的结构,感谢您填补了用户指南中的空白。 (2认同)