Retrieve string used for creating a thread

Ask for help, how to use AHK_H, etc.
think
Posts: 42
Joined: 09 Feb 2014, 05:20

Retrieve string used for creating a thread

29 Jun 2019, 07:31

Is it possible to retrieve the string used for creating dll thread from the thread? In below case, can I retrive MyScript string later on?

Code: Select all

dll0:=ahkthread(MyScript)
MyScript:=""
swagfag
Posts: 2610
Joined: 11 Jan 2017, 17:59

Re: Retrieve string used for creating a thread

29 Jun 2019, 08:20

u could pass MyScript as a command line argument to the thread, then later use a combination of AhkGetVar and Alias to retrieve the thread's A_Args[1] which will contain the script u passed in

but why tho? u can simply store MyScript in ur main script when u create the thread for the first time. under what circumstances will u be unable to do so? also i think the method above can crash ur scripts if u do it with too many threads at the same time, but i havent checked
HotKeyIt
Posts: 1850
Joined: 29 Sep 2013, 18:35
Contact:

Re: Retrieve string used for creating a thread

29 Jun 2019, 13:08

?

Code: Select all

ahkdll:=AhkThread("MsgBox this is my script")
MsgBox % ahkdll.ahkgetvar("A_LineFile")
think
Posts: 42
Joined: 09 Feb 2014, 05:20

Re: Retrieve string used for creating a thread

29 Jun 2019, 14:58

HotKeyIt, thanks, this works, however I get Out of Memory error (or a Continuable Access Error) or the script simply freezes. Why would that be?
I know I could save the variable but it's very large and I thought I would save memory...
think
Posts: 42
Joined: 09 Feb 2014, 05:20

Re: Retrieve string used for creating a thread

29 Jun 2019, 15:23

I also tried dll0.ahkReload() but it freezes the script too.
think
Posts: 42
Joined: 09 Feb 2014, 05:20

Re: Retrieve string used for creating a thread

30 Jun 2019, 09:36

It seems to be related to #if command. Press Alt+X couple of times.

Code: Select all

string:="
(
loop 100
{
	tooltip % A_Index
	sleep 100
}
return

#If Test()
#If

Test(){
; do nothing
return
}
)"

dll0:=ahkthread(string)
return

!x::
dll0.ahkReload()
return
swagfag
Posts: 2610
Joined: 11 Jan 2017, 17:59

Re: Retrieve string used for creating a thread

11 Jul 2019, 13:16

wait. why does A_LineFile return the thread's script contents. is this an ahk_h specific thing?
swagfag
Posts: 2610
Joined: 11 Jan 2017, 17:59

Re: Retrieve string used for creating a thread

12 Jul 2019, 10:45

couldnt find anything in the docs. are there more undocumented hidden vars/features such as this
User avatar
jeeswg
Posts: 6466
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Retrieve string used for creating a thread

12 Jul 2019, 10:52

@swagfag: I found it mentioned in the AHK_H v1 chm file (but not the v2 chm file). Cheers.
A_LineFile contains the full file path of currently running script (ahkdll + addFile) or the script as string/text (ahktextdll or addScript).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
swagfag
Posts: 2610
Joined: 11 Jan 2017, 17:59

Re: Retrieve string used for creating a thread

12 Jul 2019, 11:35

whaat, theres a v1 chm file?
actually, i think i like this one better, think its more useful to have the docs document only the _h stuff and the differences from _l
i wonder what prompted the change

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 6 guests