最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

autohotkey - "new" keyword is considered invalid - Stack Overflow

programmeradmin1浏览0评论

The new keyword is not working in AutoHotkey v2:

#Requires AutoHotkey v2.0

MsgBox "AHK Version: " A_AhkVersion

ih := new InputHook("L1 T0.5")
ih.Start()
key := ih.Wait()  ; Wait for one key press (or timeout)
ih.Stop()

MsgBox "Key pressed: " key

If I comment that out I get:

#Requires AutoHotkey v2.0

MsgBox "AHK Version: " A_AhkVersion

;ih := new InputHook("L1 T0.5")
;ih.Start()
;key := ih.Wait()  ; Wait for one key press (or timeout)
;ih.Stop()

;MsgBox "Key pressed: " key

How do I fix this?

The new keyword is not working in AutoHotkey v2:

#Requires AutoHotkey v2.0

MsgBox "AHK Version: " A_AhkVersion

ih := new InputHook("L1 T0.5")
ih.Start()
key := ih.Wait()  ; Wait for one key press (or timeout)
ih.Stop()

MsgBox "Key pressed: " key

If I comment that out I get:

#Requires AutoHotkey v2.0

MsgBox "AHK Version: " A_AhkVersion

;ih := new InputHook("L1 T0.5")
;ih.Start()
;key := ih.Wait()  ; Wait for one key press (or timeout)
;ih.Stop()

;MsgBox "Key pressed: " key

How do I fix this?

Share Improve this question edited Feb 13 at 0:39 user4157124 3,00214 gold badges31 silver badges45 bronze badges asked Feb 9 at 18:42 David CallananDavid Callanan 5,81015 gold badges76 silver badges123 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

The new operator has been removed. Instead, just omit the operator, as in MyClass(). To construct an object based on another object that is not a class, create it with {} or Object() (or by any other means) and set its base. __Init and __New can be called explicitly if needed, but generally this is only appropriate when instantiating a class.

Source

MsgBox "AHK Version: " A_AhkVersion

ih := InputHook("L1 T0.5")
ih.Start()
key := ih.Wait()  ; Wait for one key press (or timeout)
ih.Stop()

MsgBox "Key pressed: " key
发布评论

评论列表(0)

  1. 暂无评论