Jump to content

Another Multi Process Helper


piccaso
 Share

Recommended Posts

I know this thread is very old, but I have a problem with it:

The function _CoProcSend doesn't work fork for me

Always get @error = 3 (timed out) even if I give 5 seconds for time out parameter

here is my test code

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         Matwachich

 Script Function:
    Test

#ce ----------------------------------------------------------------------------

#include "CoProc.au3"
#NoTrayIcon

$run = 1
HotKeySet('+q', '_terminate')
Func _terminate()
    $run = 0
EndFunc

$gui = GuiCreate('')
$PID = _CoProc("_thread", "param")
ConsoleWrite($PID & @CRLF)
_CoProcReciver("_Reciver")

While $run
    Sleep(10)
Wend

ProcessClose($PID)

Func _Receiver($data)
    ConsoleWrite($data & @CRLF)
EndFunc

; ##############################################################

Func _thread($param)
    ;MsgBox(0, "Thread", $gi_CoProcParent)
    $gui = GuiCreate('')
    $ret = 0
    While 1
        $ret = _CoProcSend($gi_CoProcParent, "I'm Alive!", 1000, 0)
        If @error Then MsgBox(0, "Thread", $ret & " - " & @error & " - " & @extended)
        Sleep(1000)
    Wend
EndFunc

In advance, thanks!

Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 1 year later...

it doesn't work on v3.3.6.1

D:\AutoIt3\Include\coproc.au3(49,47) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"

$iOldRunErrorsFatal = Opt("RunErrorsFatal", 0)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\AutoIt3\Include\coproc.au3(64,43) : ERROR: Opt() called with illegal argument 1: "RunErrorsFatal"

Opt("RunErrorsFatal", $iOldRunErrorsFatal)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Code:

#include "coproc.au3"

$iPidChild = _CoProc(Default, "_recv") ; Create new Procces, Set _recv() as Reciever function

Sleep(2000) ; Give some time to load new Process

_CoProcSend($iPidChild,"Something...") ; Send a Message to new process

Func _recv($vParm)

MsgBox(0,"Recieved",$vParm)

EndFunc

Link to comment
Share on other sites

  • 1 year later...

I didnt want to sacrifice Scite's Syntax highlighting and keep it a bit simpler so thats what came out :D

Ok its not that simple any more.

Revision 30 attachicon.gifCoProc.zip

Update Notes:

Revision 24

Fixed Memory Leak in _ProcSuspend() and _ProcResume()

Fixed Example_Download.au3 Links

Revision 25

New Optional Parameter $sRegistryBase for _SuperGlobalGet() and _SuperGlobalSet()

Revision 30

Fixed for To work with current Autoit Version

Added wrapper for DuplicateHandle Api

Function List
_CoProc([$sFunction],[$vParameter]) Starts another Process and Calls $sFunc, Returns PID
    _SuperGlobalSet($sName,[$vValue],[$sRegistryBase]) Sets or Deletes a Superglobal Variable
    _SuperGlobalGet($sName,[$fOption],[$sRegistryBase]) Returns the Value of a Superglobal Variable
    _ProcSuspend($vProcess) Suspends all Threads in $vProcess (PID or Name)
    _ProcResume($vProcess) Resumes all Threads in $vProcess (PID or Name)
    _ProcessGetWinList($vProcess, $sTitle = Default, $iOption = 0) Enumerates Windows of a Process
    _CoProcReciver([$sFunction = ""]) Register/Unregister Reciver Function
    _CoProcSend($vProcess, $vParameter,[$iTimeout = 500],[$fAbortIfHung = True]) Send Message to Process
    _ConsoleForward($iPid1, [$iPid2], [$iPid3], [$iPidn])
    _ProcessEmptyWorkingSet($vPid = @AutoItPID,[$hDll_psapi],[$hDll_kernel32]) Removes as many pages as possible from the working set of the specified process.
    _DuplicateHandle($dwSourcePid, $hSourceHandle, $dwTargetPid = @AutoItPID, $fCloseSource = False) Returns a Duplicate handle
    _CloseHandle($hAny) Close a Handle
Example_Download.au3 doesent work right no more because the link is dead

Please read this bevore using _ProcSuspend() and _ProcResume().

i did this some time ago and i remeber taking something from someone somwhere.

if you find a piece of code inside, please forgive me.

if you want credit for it or want me to remove it dorp me a line...

Here are some examples:

#include "coproc.au3"

$iPidChild = _CoProc(Default, "_recv") ; Create new Procces, Set _recv() as Reciever function
Sleep(2000) ; Give some time to load new Process
_CoProcSend($iPidChild,"Something...")  ; Send a Message to new process

Func _recv($vParm)
    MsgBox(0,"Recieved",$vParm)
EndFuncoÝ÷ Ø.Ø®²ÄÜ¥'«½êÚºÚ"µÍÔÝ

HÑÜ[ØÙÜÙÂÚ[ÛYH ][ÝÐÛÔØË]LÉ][ÝÂÈH ÌÎNÝ[]ØØ[ÜÝL ÌÎNÈ[È[Ý[Þ
ÒSÑVJÔBÈÈÛÛXÝÈHÙÈXZ[ØÙÜÂ^TÙ]ÛÛ
    ][ÝÓXZ[ØÙÜÈ   ][ÝÈ  [È]]Ò]Q
BÌÍÚÛØÚÙ]HÔÝ[  ][ÝÉ][ÝËL
BÚ[HBIÌÍÚXØÙHÔXØÙ
    ÌÍÚÛØÚÙ]
BRY ÌÍÚXØÙ ÝÈ[BWÐÛÔØÈ
    ][Ý×Ó]ÐÛÛXÝ[Û][ÝË ÌÍÚXØÙ
BBNÈÈYYÈÛÜÙHHÛØÚÙ]H]ÂBNÈØÙÜÈÚ[È]Q[YTÛY
L
BÑ[ÈÛÜÙØÙÜÂ[ÈÓ]ÐÛÛXÝ[Û  ÌÍÚXØÙ
BIÌÍÚXØÙHÑXØ]R[H
    ÌÍÙÚWÐÛÔØÔ[ÈÈÝYYHÛÔØÂBBIÌÍÚXØÙÂNÈH[HÈXØ]BBBP]]Ò]QÈÈÝ[YBBUYJHÈÛÜÙHHÛØÚÙ][H[ØÙÜÂRYÜ[^]U^TÙ]ÛÛ
    ][ÝÕÛÜÙØÙÜÈ    ][ÝÈ  [È]]Ò]Q
BSØØ[ ÌÍÜÐYUÔÙ[
    ÌÍÚXØÙ ][ÝÖ[ÝÛÛXÝYÈY    ][ÝÈ  [È]]Ò]Q   [ÈÔBUÔÙ[
    ÌÍÚXØÙ ][ÝÒ[H[   ][ÝÈ  [ÈÔBUÚ[HBBIÌÍÜÐY [ÏHÔXÝ   ÌÍÚXØÙMBBRYÜ[^]BRYÝ[Ó[  ÌÍÜÐYH  ÝÈ[Ý[Ò[Ý   ÌÍÜÐYÔH[BBRYÝ[Ò[Ý   ÌÍÜÐY   ][ÝÙ^]    ][ÝÊHHH[^]BBRYÝ[Ò[Ý    ÌÍÜÐY   ][ÝÓÙÐÞ    ][ÝÊHHH[BBBSÙÐÞ
]]Ò]QÝ[ÓZY
    ÌÍÜÐY
ÊJBBBQ[YBBRYÝ[Ò[Ý   ÌÍÜÐY   ][ÝÚ[ ][ÝÊHHH[BBBUÔÙ[
    ÌÍÚXØÙ ][ÝÐÛÛ[X[Î][ÝÈ   [ÈÔBBBBUÔÙ[
    ÌÍÚXØÙ ][ÝÒ[HÈ[É][ÝÈ [ÈÔBBBBUÔÙ[
    ÌÍÚXØÙ ][ÝÓÙÐÞ    ÓÙÉÝÈHH]I][ÝÈ    [ÈÔBBBBUÔÙ[
    ÌÍÚXØÙ ][ÝÑ^]H]Z]    ][ÝÈ  [ÈÔBBBQ[YBBIÌÍÜÐYH    ][ÝÉ][ÝÂBQ[YUÑ[[[ÈÏOIÝ×Ó]ÐÛÛXÝ[Û

aaaaaaaaa1

Link to comment
Share on other sites

  • 7 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...