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 badges1 Answer
Reset to default 2The
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