Jump to content



Photo

Another Multi Process Helper


  • Please log in to reply
42 replies to this topic

#1 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 17 July 2006 - 06:43 PM

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 Attached File  CoProc.zip   9.37KB   6626 downloads

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) EndFuncƒo݊÷ Ø.–؏®‡²ÄÜ¥'«½êÚºÚ"µÍ•Ôݝ Hћ܈[›ØÙÜÙˆÚ[˜ÛYH   œ][ÝÐÛÔ›ØË˜]Lɜ][Ý‚ŽÈH   ˆÌÎNÝ[™]ØØ[ÜÝ L  ˆÌÎNÈ[È[݈[ˆ›Þ ÒS’ÑVJԊBŽÈÈÛۛ™XÝÈHٝ™‚‚ŽÈXZ[ˆ›ØÙÜ•˜^TÙ]ÛÛ     œ][ÝÓXZ[ˆ›ØÙÜÈ  œ][ÝÈ   ˜[È]]Ò]Q B‰ˆÌ ͎ÚÛØÚÙ]HÔÝ[Š œ][Ýɜ][ÝË L  B•Ú[H B‚IˆÌ ͎ÚXØÙHÔXØÙ     ˆÌ ͎ÚÛØÚÙ] B‚RYˆ ˆÌ ͎ÚXØÙ ™ÝÈ [‚‚BWÐÛÔ›ØÈ     œ][Ý×ә]ÐÛۛ™XÝ[ۉœ][ÝË ˆÌ ͎ÚXØÙ B‚BNțșYYÈÛÜÙHHÛØÚÙ] H™]‚BNÈ›ØÙÜÈÚ[È]‚Q[™Y‚‚TÛY L B•Ñ[™‚ŽÈÛܚو›ØÙÜ‘[˜Èә]ÐÛۛ™XÝ[ۊ    ˆÌ ͎ÚXØÙ B‚IˆÌ ͎ÚXØÙHÑXØ]R[™H     ˆÌ ͎ÙÚWÐÛÔ›ØÔ™[ ÈțݚYYžHÛÔ›ØÂ‚BBIˆÌ ͎ÚXØÙ ÂNÈH[™HÈXØ]B‚BBP]]Ò]Q ÈÈݜ™[Y‚BBUYJHÈÛÜÙHHÛØÚÙ][ˆH™[›ØÙÜ‚RYˆœ›Üˆ[ˆ^]‚U˜^TÙ]ÛÛ     œ][ÝÕÛܚو›ØÙÜÈ œ][ÝÈ   ˜[È]]Ò]Q B‚SØØ[ ˆÌ ͎ÜНY™‚‚UÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÖ[݈Ûۛ™XÝYÈYˆ œ][ÝÈ   ˜[È]]Ò]Q  ˜[ÈԓŠB‚UÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÒ[ˆH[    œ][ÝÈ   ˜[ÈԓŠB‚UÚ[H B‚BIˆÌ ͎ÜНY™ˆ ˜[ÏHÔ™X݊ ˆÌ ͎ÚXØÙ  MŠB‚BRYˆœ›Üˆ[ˆ^]‚BRYˆÝš[™Ó[Š   ˆÌ ͎ÜНY™ŠH   ™ÝÈ [™Ýš[™Ò[”ÝŠ   ˆÌ ͎ÜНY™‹ԊH[‚‚BBRYˆÝš[™Ò[”ÝŠ   ˆÌ ͎ÜНY™‹   œ][ÝÙ^]    œ][ÝÊHH H[ˆ^]‚BBRYˆÝš[™Ò[”ÝŠ    ˆÌ ͎ÜНY™‹   œ][ÝÓÙЛÞ  œ][ÝÊHH H[‚‚BBBSÙÐ›Þ ]]Ò]Q Ýš[™ÓZY     ˆÌ ͎ÜНY™‹ ÊJB‚BBQ[™Y‚‚BBRYˆÝš[™Ò[”ÝŠ ˆÌ ͎ÜНY™‹   œ][ÝÚ[    œ][ÝÊHH H[‚‚BBBUÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÐÛÛ[X[™Ήœ][ÝÈ    ˜[ÈԓŠB‚BBBUÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÒ[ HÈ[™Éœ][ÝÈ   ˜[ÈԓŠB‚BBBUÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÓÙЛÞ  ›ÓÙəÝÈ HžH]ŠIœ][ÝÈ    ˜[ÈԓŠB‚BBBUÔÙ[™     ˆÌ ͎ÚXØÙ     œ][ÝÑ^] H]Z] œ][ÝÈ   ˜[ÈԓŠB‚BBQ[™Y‚‚BBIˆÌ ͎ÜНY™ˆH œ][Ýɜ][Ý‚BQ[™Y‚‚UÑ[™‘[™[˜ÈÏOI™Ý×ә]ÐÛۛ™XÝ[ۂ

Edited by piccaso, 07 June 2007 - 08:22 AM.

Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map







#2 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 17 July 2006 - 09:27 PM

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.

#3 WTS

WTS

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 17 July 2006 - 09:52 PM

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

yeah nice job picasso

Edited by WTS, 17 July 2006 - 09:52 PM.


#4 w0uter

w0uter

    resreveR nA

  • Active Members
  • PipPipPipPipPipPip
  • 2,262 posts

Posted 17 July 2006 - 10:42 PM

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

#5 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 18 July 2006 - 01:50 PM

@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:
Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

#6 erifash

erifash

    autoit - think free

  • Active Members
  • PipPipPipPipPipPip
  • 517 posts

Posted 18 July 2006 - 04:00 PM

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")).

#7 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 18 November 2006 - 01:28 AM

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, 18 November 2006 - 01:30 AM.

Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

#8 SmOke_N

SmOke_N

    It's not what you know ... It's what you can prove!

  • Moderators
  • 15,729 posts

Posted 18 November 2006 - 07:05 AM

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.


#9 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 18 November 2006 - 09:34 PM

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

your welcome, Thanks ;)
let me know what you think of it...

Updated first post, added changelog too...
Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

#10 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 18 November 2006 - 11:22 PM

i really like the changes piccaso. I have used your UDF's quite a few times but I always change these to functions:
AutoIt         
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, 18 November 2006 - 11:22 PM.

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.

#11 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 18 November 2006 - 11:31 PM

my idea was to use the global variable $gs_SuperGlobalRegistryBase to point to a costum location but i will make it compatible to your version (if you dont mind) so both methods will work.

nice idea ;)
Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

#12 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 19 November 2006 - 10:43 AM

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.

#13 59FIFTY

59FIFTY

    Seeker

  • Active Members
  • 46 posts

Posted 17 January 2007 - 10:53 PM

This UDF is very nice, except for one problem: If you have 2 scripts running communicating witch each other and the active window is a third app, the communication doesn't work at all.

Edited by 59FIFTY, 17 January 2007 - 11:19 PM.


#14 piccaso

piccaso

    Rock me, Amadeus!

  • MVPs
  • 893 posts

Posted 07 June 2007 - 08:31 AM

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 :)
Posted Image CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

#15 mrbond007

mrbond007

    License To Script

  • Active Members
  • PipPipPipPipPipPip
  • 422 posts

Posted 07 June 2007 - 09:02 AM

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

For someone who's getting old, you sure make some kickass scripts
Excellent job :)

#16 Armand

Armand

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 541 posts

Posted 08 October 2007 - 12:46 AM

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

#17 ReCoder

ReCoder

    Seeker

  • Active Members
  • 10 posts

Posted 08 October 2007 - 06:18 PM

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.

#18 Armand

Armand

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 541 posts

Posted 09 October 2007 - 07:10 AM

@ReCoder
wow... that helped alot (NOT...)
but thanks anyhow...

#19 Skizmata

Skizmata

    Prodigy

  • Active Members
  • PipPipPip
  • 169 posts

Posted 09 October 2007 - 01:15 PM

Thank you very much Picasso I have been using your suspend/resume in a project of mine the updates are appreciated. I have learned much from study of your work thank you.
AutoIt changed my life.

#20 N4rk0

N4rk0

    Seeker

  • Active Members
  • 24 posts

Posted 20 December 2007 - 03:27 AM

I think that need update for current version , when try to use it says that are useddeprecated var types calling dll....

Edit
I did it by myself , replase long_ptr with long

Edited by N4rk0, 20 December 2007 - 03:36 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users