|
本帖最后由 ghostystep 于 2009-7-3 18:07 编辑
今天在try autoit的多进程库的时候,发现_CoProcReciver似乎不work,
注册的函数始终无法被执行. 大家还发现过这样的问题啊?都怎么解决的?
不知道是不是autoit版本的问题,发现库文件里面曾经用过一个被删除了的系统变量,
我当时是直接删除了. (RunErrorsFatal)#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include "CoProc.au3"
#NoTrayIcon
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 525, 303, 290, 272)
$Input1 = GUICtrlCreateInput("163.com", 8, 8, 177, 21)
$Button1 = GUICtrlCreateButton("Ping", 192, 8, 75, 25, 0)
$Input2 = GUICtrlCreateInput("wglm.net", 288, 8, 137, 21)
$Button2 = GUICtrlCreateButton("Ping", 432, 8, 75, 25, 0)
$List1 = GUICtrlCreateEdit("", 8, 40, 257, 253)
$List2 = GUICtrlCreateEdit("", 288, 40, 225, 253)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_CoProcReciver("Reciver") ;注册Reciver()函数来接收子进程传递过来的消息
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_CoProc("_ping1")
Case $Button2
_CoProc("_ping2")
EndSwitch
WEnd
Func Reciver($vParameter);$vParameter里就是子进程发来的消息
MsgBox(0,"","test")
$aParam = StringSplit($vParameter, "|")
If $aParam[1] = "ping1" Then GUICtrlSetData($List1, "ping 163.com 返回: " & $aParam[2] & @CRLF, "1")
If $aParam[1] = "ping2" Then GUICtrlSetData($List2, "ping wglm.net 返回: " & $aParam[2] & @CRLF, "1")
EndFunc ;==>Reciver
Func _ping1()
While ProcessExists($gi_CoProcParent)
;不断向父进程发送消息,$gi_CoProcParent是父进程的PID,这个变量是函数自己建立的
_CoProcSend($gi_CoProcParent, "ping1|" & Ping("163.com"))
Sleep(1000)
WEnd
EndFunc ;==>_ping1
Func _ping2()
While ProcessExists($gi_CoProcParent)
;不断向父进程发送消息,$gi_CoProcParent是父进程的PID,这个变量是函数自己建立的
_CoProcSend($gi_CoProcParent, "ping2|" & Ping("wglm.net"))
Sleep(1000)
WEnd
EndFunc ;==>_ping2
|
|