I'm getting a crash to desktop with no error message. I've narrowed the problem code to what you see below. More specifically, this code and the code it executes is 100% where the issue lies:
Code: Select all
this.m_Keys.Push(CriticalObject(new Key("LButton", KeybindType.Targeted, "$LButton")))
this.m_Keys.Push(CriticalObject(new Key("RButton", KeybindType.Targeted, "$RButton")))
this.m_Keys.Push(CriticalObject(new Key("q", KeybindType.Targeted, "$q")))
this.m_Keys.Push(CriticalObject(new Key("w", KeybindType.Targeted, "$w")))
this.m_Keys.Push(CriticalObject(new Key("e", KeybindType.Targeted, "$e")))
this.m_Keys.Push(CriticalObject(new Key("r", KeybindType.Targeted, "$r")))
local i, _key
For i, _key in this.m_Keys
{
AHKThread("
(
#Include Input\KeyPressThread.ahk
)", &this.m_Keys[i] "")
}
Code: Select all
class Key
{
__New(p_KeybindString, p_KeybindType, p_Hotkey)
{
global
this.m_State := False
this.m_PrevState := this.m_State
this.m_Keybind := IniReader.ParseKeybind(p_KeybindString)
this.m_Keybind.Type := p_KeybindType
this.m_Hotkey := p_Hotkey
}
State[] {
get {
return this.m_State
}
set {
return this.m_State := value
}
}
PrevState[] {
get {
return this.m_PrevState
}
set {
return this.m_PrevState := value
}
}
Keybind[] {
get {
return this.m_Keybind
}
}
Hotkey[] {
get {
return this.m_Hotkey
}
}
}
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#SingleInstance Force
#Persistent ; Keep this script running until the user explicitly exits it.
;#MaxHotkeysPerInterval 99000000
;#HotkeyInterval 99000000
;#MaxThreads 255
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
_critObj := CriticalObject(A_Args[1])
_boundFunction := Func("PressKeybind").Bind(_critObj)
Hotkey, % _critObj.Hotkey, % _boundFunction
return
PressKeybind(p_Key)
{
if (p_Key.State = True)
Exit
p_Key.PrevState := p_Key.State
p_Key.State := True
}
;~$F12::
; ExitApp
;return
However, I don't really know enough about threads and how they work in AHK.
The only reason why I put these Hotkeys into their own thread is because when too many hotkeys in the array fired off some became "stuck" (The 'Up' hotkey didn't fire after physically releasing the key so the key was still considered held by the script).
So to solve that issue I put them into their own thread. Now the programs crashes to desktop though, so I'd consider that a step in the wrong direction...
If someone knows why a hotkey might not fire off or what's wrong with the current threaded solution that would be much appreciated.
As a heads up, I don't access 'this.m_Keys' ever again. That part where I would is currently commented out, but the issue persists.
Also, here is the error in the event viewer: [Mod edit: Topic name added]