Page 1 of 1

crash with no error message

Posted: 05 Aug 2019, 23:25
by bennybroseph
Hey guys. So I ran into another problem...

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
		#Include Input\KeyPressThread.ahk
	)", &this.m_Keys[i] "")
Key class

Code: Select all

class Key
	__New(p_KeybindString, p_KeybindType, p_Hotkey)

		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


	if (p_Key.State = True)

	p_Key.PrevState := p_Key.State
	p_Key.State := True

;	ExitApp

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:
error.png (35.94 KiB) Viewed 700 times
[Mod edit: Topic name added]

Re: crash with no error message

Posted: 06 Aug 2019, 00:27
by swagfag
this line looks funny )", &this.m_Keys ""). i cant exactly recall if it was true, but u cant fetch the address of an object nested multiple times directly like that without having to do reassignments first
try )", &_key ""), assigned by the forloop

Re: crash with no error message

Posted: 06 Aug 2019, 19:32
by bennybroseph
Unfortunately it still crashes even with this change.