2017-08-24 82 views
1

我想爲AutoHotkey中的員工記錄創建一個自定義類對象。這個類對象將存儲員工的年齡,姓名和職位。如何在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; 
    } 
} 

然後,我會能夠爲新員工設置的屬性。

Employee worker1 = new Employee(22, "Timothy", "Programmer"); 
Employee worker2 = new Employee(26, "Anthony", "Quality Assurance"); 

我一直沒能在AHK中找到任何具有相同功能的東西。據我所知,AHK中的對象在功能上相當基礎。

如何創建與AutoHotkey的自定義屬性的類對象?

+1

https://autohotkey.com/docs/Objects.htm – puhlen

+1

[的對象的文檔(HTTPS: //autohotkey.com/docs/Objects.htm#Usage_Objects)似乎意味着可以給對象屬性賦予屬性而無需事先聲明它們。 (即'Employee.Name:= 「蒂莫西」') –

+0

我發現了一個引導件,其從基礎解釋AHK的類:[在AHK類,基礎教程] **(https://autohotkey.com/boards/viewtopic。 PHPΔT= 6033)** –

回答

4

我不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")