How to add parameters into AhkThread ? Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
gameba
Posts: 18
Joined: 20 Mar 2018, 12:24

How to add parameters into AhkThread ?

Post by gameba » 26 Mar 2018, 04:19

Code: Select all

threads:=[]
Loop 4
threads[A_Index]:=AhkThread("
(
	msgbox `% A_Args[1]
	msgbox `% A_Args[2]
	msgbox `% A_Args[3]

)", "1 2 %A_Index%")

ESC::
ExitAPP
I tried add parameter to AhkThread. A_Args[1], A_Args[2] work fine, but A_Args[3] not get A_Index value. Pls, Help me!
HotKeyIt
Posts: 1696
Joined: 29 Sep 2013, 18:35
Contact:

Re: How to add parameters into AhkThread ?  Topic is solved

Post by HotKeyIt » 26 Mar 2018, 18:30

Code: Select all

threads:=[]
Loop 4
threads[A_Index]:=AhkThread("
(
	msgbox `% A_Args[1]
	msgbox `% A_Args[2]
	msgbox `% A_Args[3]

)", "1 2 " A_Index)

ESC::
ExitAPP
guest3456
Posts: 2419
Joined: 09 Oct 2013, 10:31

Re: How to add parameters into AhkThread ?

Post by guest3456 » 26 Mar 2018, 20:47

ahk v2 used to allow this syntax:

"1 2 %A_Index%"

but lexikos removed it. so you can no longer deference inside a quoted string, so you have to do it the same as in v1 as HotKeyIt showed

Galaxis
Posts: 18
Joined: 04 Feb 2016, 20:09

Re: How to add parameters into AhkThread ?

Post by Galaxis » 01 May 2018, 22:13

HotKeyIt wrote:

Code: Select all

threads:=[]
Loop 4
threads[A_Index]:=AhkThread("
(
	msgbox `% A_Args[1]
	msgbox `% A_Args[2]
	msgbox `% A_Args[3]

)", "1 2 " A_Index)

ESC::
ExitAPP

Noob question- i just started using AHK_H recently for its multithreading. I was curious about the usage of ("( )") and its function. If I had to guess, it seems similar to concatenate. Is this the sole method for going to a new line- making the code look all neat and crisp? I don't remember that being possible in normal AHK
swagfag
Posts: 1221
Joined: 11 Jan 2017, 17:59

Re: How to add parameters into AhkThread ?

Post by swagfag » 01 May 2018, 23:47

thats the continuation section from ahk_l
though there are some differences in behaviour switching from v1 to v2

https://autohotkey.com/docs/Scripts.htm#continuation
https://lexikos.github.io/v2/docs/Scrip ... ntinuation
Galaxis
Posts: 18
Joined: 04 Feb 2016, 20:09

Re: How to add parameters into AhkThread ?

Post by Galaxis » 02 May 2018, 11:49

Ur awesome! thanks
Post Reply

Return to “AutoHotkey_H”