Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Another Multi Process Helper


  • Please log in to reply
43 replies to this topic

#41 matwachich

matwachich

    Polymath

  • Active Members
  • PipPipPipPip
  • 234 posts

Posted 23 March 2011 - 05:16 PM

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
AutoIt         
#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!







#42 Warmonger

Warmonger

    Wayfarer

  • Banned (NOT IN USE)
  • 63 posts

Posted 17 April 2011 - 08:38 AM

Here's CoProc.au3 with _CoProcSend and _DuplicateHandle fixed.

Attached Files


Edited by Warmonger, 20 April 2011 - 03:19 AM.


#43 Wolfteeth

Wolfteeth

    Seeker

  • Active Members
  • 45 posts

Posted 19 April 2012 - 03:52 PM

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

#44 bdrdc

bdrdc

    Seeker

  • Normal Members
  • 2 posts

Posted 24 January 2014 - 06:33 AM

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:
AutoIt         
#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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users