Jump to content

Another Multi Process Helper


piccaso
 Share

Recommended Posts

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 CoProc.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Ý[Û
Edited by piccaso
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It works really well picasso. I like your method of doing this.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Assign("gi_CoProcParent", Number(EnvGet("CoProcParent")), 2)

Is BAD! lol.

Also i remember a glitch where BinaryString did not convert it to hex if it did not contain NON alphanumeric characters. Dont know if it is fixed or an error on my part. I usually just fixed it by adding a Chr(0) at the front and then stripping the first 2 bytes :D

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

@RazerM,WTS

Thanks :">

Assign("gi_CoProcParent", Number(EnvGet("CoProcParent")), 2)

Is BAD! lol.

Why?

Also i remember a glitch where BinaryString did not convert it to hex if it did not contain NON alphanumeric characters. Dont know if it is fixed or an error on my part. I usually just fixed it by adding a Chr(0) at the front and then stripping the first 2 bytes :D

MsgBox(0,"",BinaryString("0x" & Hex(BinaryString("Hello"))))

works fine, but you made me nervous :wacko:

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

Also i remember a glitch where BinaryString did not convert it to hex if it did not contain NON alphanumeric characters.

That's only if you are using String(BinaryString("Text")) to convert to hex. I had that same problem in another program but I fixed it using Hex(BinaryString("Text")).
Link to comment
Share on other sites

  • 3 months later...

after keeping the changes secret for some months i finaly managed to update it ;)

... i'm getting old, i had to read my own function headers to understand my code.

so let this be a lesson to all you non documenting function authors out there :lmao:

Edited by piccaso
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

  • Moderators

after keeping the changes secret for some months i finaly managed to update it ;)

... i'm getting old, i had to read my own function headers to understand my code.

so let this be a lesson to all you non documenting function authors out there :lmao:

I'm going to play with these over the weekend, but the work looks really good ... thanks :evil:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i really like the changes piccaso. I have used your UDF's quite a few times but I always change these to functions:

Func _SuperGlobalSet($sName, $vValue = "", $regkey = "HKEY_CURRENT_USER\Software\AutoIt v3\CoProc")
 Local $vTmp
 If $vValue = "" Then
  RegDelete($regkey, $sName)
  If @error Then Return SetError(2, 0, False) ; Registry Problem
 Else
  $vValue = StringTrimLeft(Hex(BinaryString(Chr(0) & $vValue)), 2)
  If @error Then
   Return SetError(1, 0, False) ; Wrong variable type
  Else
   RegWrite($regkey, $sName, "REG_BINARY", $vValue)
   If @error Then Return SetError(2, 0, False) ; Registry Problem
  EndIf
 EndIf
 Return True
EndFunc   ;==>_SuperGlobalSet

Func _SuperGlobalGet($sName, $fOption = False, $regkey = "HKEY_CURRENT_USER\Software\AutoIt v3\CoProc")
 Local $vTmp
 $vTmp = RegRead($regkey, $sName)
 If @error Then Return SetError(1, 0, "") ; Registry Problem
 If $fOption Then
  _SuperGlobalSet($sName)
  If @error Then SetError(2)
 EndIf
 Return BinaryString("0x" & $vTmp)
EndFunc   ;==>_SuperGlobalGet
The only thing I have changed is a paramater so I can choose my own registry key. This is because in a compiled exe I want it to write to its own registry key. Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

No problem. Thanks.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

Sorry 59FIFTY, i didn't get notified by the forum...

could you be more specific?

because it works for me...

Updated to work with the current autoit version.

And i added an example on how to use a socket in another process.

i wonder why nobody ever posed a way to use sockets that way, after all that multithread whining :)

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

  • 4 months later...

can you supply us with some more info regarding how to use coproc with parameterS (more than 1!!!) ?!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

can you supply us with some more info regarding how to use coproc with parameterS (more than 1!!!) ?!

Hi Armand,

please look at the attachement "CoProc.zip" in the first post.

@picasso

Thanks for this amazing UDF, i take it to my favorites.

Multiprozessing looks like more professional with your functions.

Link to comment
Share on other sites

@ReCoder

wow... that helped alot (NOT...)

but thanks anyhow...

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

  • 2 months 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...