AutoHotkey_H x64w_MT freezes on ahkThread() call

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

AutoHotkey_H x64w_MT freezes on ahkThread() call

11 Jan 2020, 18:28

I've installed AutoHotkey_H Multi-Threading according to the AutoHotkey_H.chm, but when running the following script, nothing happens and the script appears to completely freeze. I can't interact with the Tray icon and the program's CPU usage in task manager is really high for some reason.

Code: Select all

#Persistent

testThread := ahkThread("#Persistent`n#NoTrayIcon`nSoundBeep`nReturn")
SoundBeep

Return
Is there a more detailed step by step of how to install AutoHotkey_H or something? I don't know what to do because I'm not getting an error, the program seems to just freeze after calling

Code: Select all

ahkThread(...)
Commenting it out plays the beep as expected.

I'm running the latest Windows 10 build 1909
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

11 Jan 2020, 20:26

That is really odd, it works for me just fine, on the same build.
What happens if you replace SoundBeep with a MsgBox in ahkthread?
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 07:01

You might want to check your lib folder and see what files are in there, and if any are missing. When downloading previous versions of AHK_H, I would find files were missing or that I downloaded the wrong files. When I made sure the correct files were in the lib folder, things usually worked as expected.
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 12:05

Changed it to the non_MT version but got the same result.

I have all of the provided scripts in the %My_Documents%\Autohotkey\lib folder but I'm getting the same thing.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 14:19

Try downloading and extracting to separate folder, for the above script you don't need any libraries, see if it is working then.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 17:54

Is it the same for a simple

Code: Select all

ahkThread("MsgBox thread")
MsgBox main
If so can you download and include in your script AhkThread and try to narrow down after which line the problem appears?
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 18:48

error2.png
error2.png (25.58 KiB) Viewed 4411 times
This is what happens when pasting it at the end like so

Code: Select all

#Persistent

testThread := ahkThread("#Persistent`n#NoTrayIcon`nMsgBox, Test`nReturn")
SoundBeep

Return

ahkthread_free(obj:=""){
  static objects
  if !objects
    objects:=[]
  if obj=""
    objects:=[]
  else if !IsObject(obj)
    return objects
  else If objects.HasKey(obj)
    objects.Delete(obj)
}
ahkthread_release(o){
  o.ahkterminate(o.timeout?o.timeout:0),MemoryFreeLibrary(o[""])
}
ahkthread(s:="",p:="",t:="",IsFile:=0,dll:=""){
  static ahkdll,base,functions
  if !base
    base:={__Delete:"ahkthread_release"},UnZipRawMemory(LockResource(LoadResource(0,hRes:=FindResource(0,"F903E44B8A904483A1732BA84EA6191F",10))),SizeofResource(0,hRes),ahkdll)
    ,functions:={_ahkFunction:"s==stttttttttt",_ahkPostFunction:"i==stttttttttt",ahkFunction:"s==sssssssssss",ahkPostFunction:"i==sssssssssss",ahkdll:"ut==sss",ahktextdll:"ut==sss",ahkReady:"",ahkReload:"i==i",ahkTerminate:"i==i",addFile:"ut==sucuc",addScript:"ut==si",ahkExec:"ui==s",ahkassign:"ui==ss",ahkExecuteLine:"ut==utuiui",ahkFindFunc:"ut==s",ahkFindLabel:"ut==s",ahkgetvar:"s==sui",ahkLabel:"ui==sui",ahkPause:"i==s",ahkIsUnicode:""}
  obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll),base:base}
  for k,v in functions
    obj[k]:=DynaCall(MemoryGetProcAddress(lib,A_Index>2?k:SubStr(k,2)),v)
  If Type(s)="String" and s!=""
    obj.hThread:=obj[IsFile?"ahkdll":"ahktextdll"](s,p,t)
  ahkthread_free(true)[obj]:=1 ; keep dll loadded even if returned object is freed
  return obj
}
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

12 Jan 2020, 21:44

The script freezes after this line

Code: Select all

obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll="FC2328B39C194A4788051A3B01B1E7D5"?&ahkmini:dll),base:base}
bennybroseph
Posts: 24
Joined: 03 Jul 2019, 10:00
Contact:

Re: AutoHotkey_H x64w_MT freezes on ahkThread() call

18 Jan 2020, 02:30

So I tried a bunch of things with no luck until I found something very interesting.

The code posted runs perfectly after a restart. It'll keep running just fine seemingly forever. However, as soon as I remove the override of ahkThread it freezes AND adding the override back in still freezes.
Restarting will start the cycle over again.

So to recap. This runs fine all the time.

Code: Select all

#Persistent

testThread := ahkThread("#Persistent`n#NoTrayIcon`nMsgBox, Test`nReturn")
SoundBeep

Return

ahkthread_free(obj:=""){
  static objects
  if !objects
    objects:=[]
  if (obj="")
      objects:=[]
  else if !IsObject(obj)
	return objects
  else If objects.HasKey(obj)
	objects.Remove(obj)
}
ahkthread_release(o){
  o.ahkterminate(o.timeout?o.timeout:0),MemoryFreeLibrary(o[""])
}
ahkthread(s:="",p:="",IsFile:=0,dll:=""){
  static ahkdll,ahkmini,base,functions
  if !base
    base:={__Delete:"ahkthread_release"},UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","F903E44B8A904483A1732BA84EA6191F","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkdll)
    ,UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","FC2328B39C194A4788051A3B01B1E7D5","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkmini)
    ,functions:={_ahkFunction:"s==stttttttttt",_ahkPostFunction:"i==stttttttttt",ahkFunction:"s==sssssssssss",ahkPostFunction:"i==sssssssssss",ahkdll:"ut==sss",ahktextdll:"ut==sss",ahkReady:"",ahkReload:"i==i",ahkTerminate:"i==i",addFile:"ut==sucuc",addScript:"ut==si",ahkExec:"ui==s",ahkassign:"ui==ss",ahkExecuteLine:"ut==utuiui",ahkFindFunc:"ut==s",ahkFindLabel:"ut==s",ahkgetvar:"s==sui",ahkLabel:"ui==sui",ahkPause:"i==s",ahkIsUnicode:""}
	msgbox, Line 28
  obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll="FC2328B39C194A4788051A3B01B1E7D5"?&ahkmini:dll),base:base}
  msgbox, Line 30
  for k,v in functions
    obj[k]:=DynaCall(MemoryGetProcAddress(lib,A_Index>2?k:SubStr(k,2)),v)
	msgbox, Line 33
  If !(s+0!="" || s=0)
    obj.hThread:=obj[IsFile?"ahkdll":"ahktextdll"](s,"",p)
	msgbox, Line 36
  ahkthread_free(true)[obj]:=1 ; keep dll loadded even if returned object is freed
  msgbox, Line 38
  return obj
}
This will cause the program to freeze, and running the above code afterwards freezes as well until I reboot.

Code: Select all

#Persistent

testThread := ahkThread("#Persistent`n#NoTrayIcon`nMsgBox, Test`nReturn")
SoundBeep

Return
Still not sure what to do though.

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 6 guests