-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathSimpleMultiThreading.au3
66 lines (59 loc) · 2.03 KB
/
SimpleMultiThreading.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#NoTrayIcon
Global $__hwnd_vars
If $cmdline[0] > 0 And $cmdline[1] = "child_thread_by" Then
;MsgBox(0, "$CmdLineRaw", $CmdLineRaw )
$__hwnd_vars = HWnd($cmdline[2])
Local $i, $p = ""
For $i = 4 To $cmdline[0]
$p &= '"' & $cmdline[$i] & '",'
Next
$p = StringTrimRight($p, 1)
Execute($cmdline[3] & '(' & $p & ')')
Exit
EndIf
$__hwnd_vars = GUICreate("main thread")
GUICtrlCreateEdit("", 0, 0, 350)
;~ GUISetState(@SW_SHOW)
Func _StartThread($exe, $function, $p1 = "", $p2 = "", $p3 = "", $p4 = "", $p5 = "", $p6 = "", $p7 = "", $p8 = "", $p9 = "", $p10 = "")
Local $i, $p, $para
For $i = 1 to 10
$p = Eval("p" & $i)
If StringInStr($p, " ") Then ; ´ø¿Õ¸ñµÄ²ÎÊý¼ÓÉÏÒýºÅ
$p = '"' & $p & '"'
EndIf
$para &= ' ' & $p
Next
$para = StringStripWS($para, 3)
If $exe == @ScriptFullPath Or $exe == @ScriptName Then
If @Compiled Then
Return Run('"' & @AutoItExe & '" child_thread_by ' & $__hwnd_vars & ' ' & $function & ' ' & $para)
Else
Return Run('"' & @AutoItExe & '" "' & @ScriptFullPath & '" child_thread_by ' & $__hwnd_vars & ' ' & $function & ' ' & $para)
EndIf
ElseIf FileExists($exe) Then
Return ShellExecute($exe, ' child_thread_by ' & $__hwnd_vars & ' ' & $function & ' ' & $para, "", "open", @SW_HIDE)
EndIf
EndFunc
Func _KillThread($thread)
If $thread And ProcessExists($thread) Then
Run(@ComSpec & ' /c taskkill /PID ' & $thread & ' /T /F', '', @SW_HIDE)
Return SetError(Not ProcessExists($thread))
EndIf
EndFunc
Func _SetVar($var, $it = "")
Local $text = ControlGetText($__hwnd_vars, "", "Edit1")
$text = StringRegExpReplace($text, "(?i)(?m)^" & $var & "=.*$", $var & "=" & $it)
If Not @extended Then
$text &= @CRLF & $var & "=" & $it
EndIf
ControlSetText($__hwnd_vars, "", "Edit1", $text)
EndFunc
Func _GetVar($var)
Local $text = ControlGetText($__hwnd_vars, "", "Edit1")
Local $match = StringRegExp($text, "(?i)(?m)^" & $var & "=(.*)$", 1)
If Not @error Then
Return SetError(0, 0, $match[0])
Else
Return SetError(1, 0, "")
EndIf
EndFunc