AutoHotKey v2类无法正常工作的问题求助
AutoHotKey v2类无法正常工作的问题求助
各位好,我在AutoHotkey v2里使用类的时候一直卡壳,写了个超简化的测试代码还是运行失败,折腾两天了完全摸不着头绪,希望能得到大家的帮助😭
运行下面的代码时,会弹出错误提示:Error: This value of type "Class" has no method named "new".
#Requires AutoHotkey v2.0 class Application { new(AppName) { this.name := AppName } Msg() { MsgBox("My application name is: " this.name) } } runtest() { App := Application.new("ExpressVPN") App.Msg() } runtest()
我自己已经尝试过这些方法,但都没解决问题:
- 把构造方法的名字从
new改成了__new - 试过用
App := new Application("ExpressVPN")这种传统的类实例化写法,但会出现警告:Warning: This variable appears to never be assigned a value.
我已经卡了两天了,上面的代码是我简化到极致的版本,就是为了方便定位问题,麻烦各位帮忙看看哪里出问题了!
备注:内容来源于stack exchange,提问作者Sasquatch-cyber




