Post by Masonjar13 » 05 Mar 2018, 18:16
No problem! With the dll method, yes you do have to include it. You can use my
class here, to which you'll also need
MemoryLibrary,
Struct, and
ReadResource. They way I have it setup, if you use FileInstall, you can pass
A_IsCompiled to the threadMan object when you create it and it will read the dll from resource. Typically, you'll need a separate dll file for each script you want to run, but in this case, MemoryLibrary will load the dll into memory and use it from there instead, so one file is all you need. You can download the dll's from the
_H package. Be sure to match the correct bit-length (32-bit for x86/32-bit compiled scripts, 64-bit for x64/64-bit scripts) or an error will occur and prevent it from running.
That might seem like a lot, but this example should get you started.
Code: [Select all]GeSHi © Codebox Plus
#include <threadMan> ; be sure to include this file so you can access the class
pathToDll:=AutoHotkey.dll ; put the path to the dll here
thread1:=new threadMan(pathToDll,a_isCompiled) ; will work if script is compiled, and uncompiled if the dll is in the same folder as the script
thread1.newFromText("msgbox Hello from first thread!")
msgbox Hello from main thread!
exitApp
fileInstall,AutoHotkey.dll,0 ; we want this inaccessable so it doesn't actually extract the dll.
As I was testing this though.. it seems that readResource() isn't working.. not sure why. Compression doesn't seem to make a difference, either. So, this will work if the dll is accessible at the path, but not otherwise. I'll look into that.
No problem! With the dll method, yes you do have to include it. You can use my [url=https://github.com/Masonjar13/AHK-Library/blob/master/Lib/threadMan.ahk]class here[/url], to which you'll also need [url=https://github.com/Masonjar13/AHK-Library/blob/master/Required-Libraries/_MemoryLibrary.ahk]MemoryLibrary[/url], [url=https://github.com/Masonjar13/AHK-Library/blob/master/Required-Libraries/_Struct.ahk]Struct[/url], and [url=https://github.com/Masonjar13/AHK-Library/blob/master/Required-Libraries/readResource.ahk]ReadResource[/url]. They way I have it setup, if you use FileInstall, you can pass [url=https://autohotkey.com/docs/Variables.htm#IsCompiled]A_IsCompiled[/url] to the threadMan object when you create it and it will read the dll from resource. Typically, you'll need a separate dll file for each script you want to run, but in this case, MemoryLibrary will load the dll into memory and use it from there instead, so one file is all you need. You can download the dll's from the [url=https://hotkeyit.github.io/v2/]_H package[/url]. Be sure to match the correct bit-length (32-bit for x86/32-bit compiled scripts, 64-bit for x64/64-bit scripts) or an error will occur and prevent it from running.
That might seem like a lot, but this example should get you started.
[code]
#include <threadMan> ; be sure to include this file so you can access the class
pathToDll:=AutoHotkey.dll ; put the path to the dll here
thread1:=new threadMan(pathToDll,a_isCompiled) ; will work if script is compiled, and uncompiled if the dll is in the same folder as the script
thread1.newFromText("msgbox Hello from first thread!")
msgbox Hello from main thread!
exitApp
fileInstall,AutoHotkey.dll,0 ; we want this inaccessable so it doesn't actually extract the dll.
[/code]
As I was testing this though.. it seems that readResource() isn't working.. not sure why. Compression doesn't seem to make a difference, either. So, this will work if the dll is accessible at the path, but not otherwise. I'll look into that.