找回密码
 加入
搜索
查看: 3265|回复: 8

_CoProcReciver似乎不work,不知道是不是autoit版本的问题

  [复制链接]
发表于 2009-6-25 16:07:35 | 显示全部楼层 |阅读模式
本帖最后由 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
 楼主| 发表于 2009-7-3 18:07:05 | 显示全部楼层
经过验证是long_ptr的问题,可以替换CoProc.au3文件中long_ptr为long*
发表于 2012-3-2 16:51:25 | 显示全部楼层
2#说的不错。可以下载新的CoProc.au3

很不错,已经实现,不过_CoProcSend()函数不起作用。必须到http://www.autoitscript.com/foru ... amp;attach_id=33753
下载新的CoProc.au3,覆盖Include中的文件

Posted 17 April 2011 - 09:38 AM

Here's CoProc.au3 with _CoProcSend and _DuplicateHandle fixed.
Attached Files
  CoProc.au3   23.6K   159 downloads
发表于 2012-5-23 11:48:36 | 显示全部楼层
学习了,
发表于 2012-8-6 12:11:30 | 显示全部楼层
谢谢3楼,解决了问题
发表于 2013-4-3 10:10:10 | 显示全部楼层
谢谢  学习了
发表于 2014-4-23 22:43:44 | 显示全部楼层
谢谢3楼,正解,正为这个问题奇怪呢
发表于 2014-4-23 22:43:52 | 显示全部楼层
谢谢3楼,正解,正为这个问题奇怪呢
发表于 2017-1-3 14:59:40 | 显示全部楼层
非常感谢,原来是这个问题,解决了一个大问题
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-20 03:37 , Processed in 0.080997 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表