本帖最后由 C.L 于 2010-3-28 13:53 编辑
LZ的要求实现起来应该不算麻烦,没有装au3要编译只需很少的文件,我写了个例子(代码在3.3.5.1里测试通过),LZ看看是不是能实现你的要求
我特地将AU3卸了来测试这段代码,在我这里测试通过:
要处理的全代码:Global $result=0,$testNum = 1,$num = 2
$result = $testNum + $num
MsgBox (0,"","$testNum:"&$testNum&"+$num:2"&$num&"=$result:"&$result)
au3code.txt (代表从服务器传来的文本,要处理赋值 $num和结果 $result)Dim $Num = 2,$result = 0
if $cmdline[0] <> "" then;处理命令行
For $i=1 To $cmdline[0]
If $cmdline[$i] = "/testNum" Then
$getNum = $cmdline[$i+1]
$result = $getNum + $Num
EndIf
Next
EndIf
;MsgBox (0,"","处理全局函数$testNum:"&$getNum&"+"&$Num&"="&$result)
_Send("/result "&$result)
Func _send($message);向主程发送执行结果
$hWnd = WinGetHandle('main')
$struct = DllStructCreate('wchar var1[1000]')
DllStructSetData($struct, 1, $message)
$pStruct = DllStructGetPtr($struct)
$struct2 = DllStructCreate('dword;dword;ptr')
DllStructSetData($struct2, 1, 0)
DllStructSetData($struct2, 2, 1000)
DllStructSetData($struct2, 3, $pStruct)
$pStruct2 = DllStructGetPtr($struct2)
_SendMessage($hWnd, 0x4A, 0, $pStruct2)
Endfunc ;==>_send
Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
If @error Then Return SetError(@error, @extended, "")
If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
Return $aResult
EndFunc ;==>_SendMessage
test2.au3 (赋值$testNum,得到au3code.txt并编辑成test.exe后运行,接受返回的数值。Global $result=0,$testNum = 1,$rStr = ""
GUICreate('main')
GUIRegisterMsg(0x4A, '_MsgRec');注册函数来接收
FileInstall ("aut2exe.exe",@TempDir&"\aut2exe.exe")
FileInstall ("AutoItSC.bin",@TempDir&"\AutoItSC.bin")
RunWait(@TempDir&"\aut2exe.exe /in au3code.txt /out test.exe /nopack")
Run ("test.exe /testNum "&$testNum)
While Not $rStr
Sleep (1000)
WEnd
$sTem = StringSplit ($rStr," ")
If $sTem [1] = "/result" Then $result = $sTem[2]
MsgBox (0,"","收到传来处理结果:$result="&$result)
FileDelete ("test.exe")
Func _MsgRec($hWnd, $iMsg, $iwParam, $ilParam)
$a = DllStructCreate('dword var1;dword var2;ptr var3', $ilParam)
$b = DllStructGetData($a, 3)
$c = DllStructCreate('wchar var1[1000]', $b)
$getStr = DllStructGetData($c, 1)
$rStr = $getStr
EndFunc ;==>_Msg_Rec
|