AutoHotkey H1 Crashing! Please Help

Ask for help, how to use AHK_H, etc.
Nagendra Kumar
Posts: 2
Joined: 10 Jan 2021, 09:44

AutoHotkey H1 Crashing! Please Help

Post by Nagendra Kumar » 10 Jan 2021, 10:05

Launching threads with "#Include <LibName>" or "#Include LibName.ahk" results in crashing at the end of the thread script execution

There are no crashes when assigning the thread script to a variable or reading into a variable from a file

Tested with the below versions (32-Bit, 64-bit and MT Versions), and the results are same
H1 1.1.32.0
H1 1.1.33.2

This simple test failed

ThreadScript.ahk

Code: Select all

#NoEnv
#NoTrayIcon
MsgBox, % "In Thread`nParameter 1: " A_Args.1 "`nParameter2" A_Args.2		;All good so far
MsgBox, Thread done its job!										;All good so far
ExitApp														;Crashing at this stage

MainScript_Com_Method_Failed.ahk

Code: Select all

P1 := 111
P2 := 222
oThread := ComObjCreate("AutoHotkey.Script") ;Tested with 32-bit, 64-bit and MT-Versions
If IsObject(oThread) {
	oThread.AhkTextDll("#Include <ThreadScript>",, P1 " " P2)
	Sleep, 100
	While (State := oThread.AhkReady()) {
		ToolTip, % "Thread State: " State " (Iteration: " A_Index ")"
		Sleep, 100
	}
	MsgBox, Main: Thread finished its job
} Else
	MsgBox, Main: Error`nCom Object not found!
	
MsgBox, Main: Exits Here
ExitApp
MainScript_AhkMini_Method_Failed.ahk

Code: Select all

;oThread  := AhkMini("#Include <ThreadScript>", P1 " " P2)	;same result
;oThread  := AhkMini("#Include " A_ScriptDir "\Lib\ThreadScript.ahk", P1 " " P2) 	;same result
oThread  := AhkMini("#Include ThreadScript.ahk", P1 " " P2) 	;same result
Sleep, 100
While (State := oThread.AhkReady()) {
	ToolTip, % "Thread State: " State " (Iteration: " A_Index ")"
	Sleep, 100
}
;oThread.AhkTerminate()
oThread := ""
MsgBox, Main: Thread finished its job
MsgBox, Main: Exits Here
ExitApp
And the following methods are working.

Code: Select all

MainScript_Working.ahk
[code]
P1 := 111
P2 := 222

FileRead, ThreadScript, %A_ScriptDir%\Lib\ThreadScript.ahk
/* Or assigning it to a variable
ThreadScript =
(
#NoEnv
#NoTrayIcon
MsgBox, `% "In Thread``nParameter 1: " A_Args.1 "``nParameter2" A_Args.2
MsgBox, Thread done its job!
ExitApp
)
*/

GoTo, _Method1
;GoTo, _Method2

_Method1: ; Using Com Object
oThread := ComObjCreate("AutoHotkey.Script")
If IsObject(oThread) {
	oThread.AhkTextDll(ThreadScript,, P1 " " P2)
	Sleep, 100
	While (State := oThread.AhkReady()) {
		ToolTip, % "Thread State: " State " (Iteration: " A_Index ")"
		Sleep, 100
	}
	ToolTip
	MsgBox, Main: Thread finished its job
} Else
	MsgBox, Main: Error`nCom Object not found!
	
MsgBox, Main: Exits Here
ExitApp

_Method2: ; Using AhkMini()
oThread  := AhkMini(ThreadScript, P1 " " P2)
Sleep, 100
While (State := oThread.AhkReady()) {
	ToolTip, % "Thread State: " State " (Iteration: " A_Index ")"
	Sleep, 100
}
ToolTip
;oThread.AhkTerminate()
oThread := ""

MsgBox, Main: Thread finished its job
MsgBox, Main: Exits Here
ExitApp
Am I missing something?
Please Help!

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: AutoHotkey H1 Crashing! Please Help

Post by HotKeyIt » 10 Jan 2021, 11:17

Did you download the latest release: 1.1.33.03-H007 (see file properties)?
I tried all possible variation and cannot reproduce the crash.

Nagendra Kumar
Posts: 2
Joined: 10 Jan 2021, 09:44

Re: AutoHotkey H1 Crashing! Please Help

Post by Nagendra Kumar » 10 Jan 2021, 13:39

Thank you..
Seems fixed with Version 1.1.33.03-H007. No crashing..:)

Post Reply

Return to “Ask for Help”