argumentum Posted June 5, 2019 Share Posted June 5, 2019 (edited) Forking and threading. They both do stuff while another loop or event handler, does it's thing. Load a DLL, and ask for a function or procedure to run, and it'll do it. Handling all those takes time waiting, or to come up with semaphores and mutex and what not. So the issue at times is that we want to have all that in AutoIt and there comes the OMGs. To me, it all comes to run something and not get the main loop stuck waiting, unresponsive, as if frozen. ( oh, there is no threading in AutoIt, what can I do ! ) Hence this UDFish ( I'm not good at technical writing 😕 ), that has these functions: #cs === User Calltips: =============================================================================================== _Fork_Startup() Init. UDF - Place on your main script once everything is declared. _Fork_StartupOnFailMsgBox([$ShowMsgBox = Default]) Default = (not @compiled), True = Show error MsgBox(), False = Do Not show error MsgBox() _Fork_Func([$sFunction = Default], [$vParameter = ""], [$sExtraCmdLine = ""], [$iUseBase64Cmd = 0], [$sVerb = ""]) Starts another Process and Execute or Call $sFunction, Returns PID. _Fork_SetReceiver([$sFunction = ""]) Register/Unregister IPC Receiver Function. _Fork_GetReceiver() Get IPC Receiver Function name. _Fork_GetParentPID() Get the parent PID. _Fork_GetWinInfos([$AutoItWinTitlePrefix = Default],[ $ForkPID = ""]) Get an array of Forked Processes _Fork_CallArgArraySeparatorChar($sChar = Default) Default = Opt("GUIDataSeparatorChar") _Fork_AutoItWinTitlePrefix([$sPrefix = Default]) Returns the prefix, or set it by passing a new string. _Fork_ForkReceiverGuiTitlePrefix([$sPrefix = Default]) Returns the prefix, or set it by passing a new string. _Fork_ProcessGetWinList($vProcess, $sTitle = Default, $iOption = 0) Enumerates Windows of a Process. _Fork_WaitForReceiver($iPidChild, [$iTimeout = 60 Sec]) wait for _Fork_SetReceiver() to load via AutoItWinSetTitle(). _Fork_WaitForFork($iPidChild, [$iTimeout = 60 Sec]) wait for _Fork_Func() to load via AutoItWinSetTitle(). _Fork_Send($vPidOrHWnd, $sMessage,[$iTimeout = 500 mSec],[$fAbortIfHung = True]) Send IPC Message to Process via PID or hWnd. _Fork_Broadcast($sMessage, [$iTimeout = 500 mSec], [$fAbortIfHung = True], [$iDelayMs = 0], [$iExcludeSelf = 1], [$WinCloseAll = 0]) Send IPC Message broadcast to all in _Fork_AutoItWinTitlePrefix(), see comments. _Fork_DuplicateHandle($dwSourcePid, $hSourceHandle, $dwTargetPid = @AutoItPID, $fCloseSource = False) Returns a Duplicate handle. _Fork_GetVerUDF() Returns the version of this UDF. _DbgAid_SetActive([$Active = Default]) Enable sending data for debug: Default = Auto (True if Win found), True = Enable, False = Disable. _DbgAid_GetActive() Query Active state. _DbgAid_GuiTitle([$sTitle = Default]) Get or Set the GUI title for the debug receiver. _DbgAid_SelfName([$sSelfName = Default]) Get or Set a short name to be identified by. _DbgAid_Send($sString[, $iForceType = Default]) Send a string to the debug GUI. _DbgAid_SendVia([$iType = Default / $e_ForkDbgAid_ViaCOPYDATA / $e_ForkDbgAid_ViaMailslot]) Get / Set _DbgAid_Send() type. #ce === User Calltips: =============================================================================================== I believe that, with these functions, one can run a function in any count of other PIDs, communicate back and forth with any of them, and a console of sorts, to send data to follow what is happening with those other instances. This is basically a rewrite of "Another Multi Process Helper" by @piccaso. The functions not ported, I decided to not port. The renamed functions, are renamed to simplify the understanding of what they do, from a view of a ... me I did this because I'll need it in an upcoming project, and share it to aid those, that may find this, simple to implement in their code. Try the examples from SciTE ( or your editor ) and read the code, as there are notes explaining how it works. As always, share your views and improvements. If you have coding questions, kindly place them in "AutoIt General Help and Support". _Fork_UDF(v2019.06.29d).zip ( current version ) Edited February 5, 2020 by argumentum update Danyfirex, moosjuice, Xandy and 1 other 3 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted June 29, 2019 Author Share Posted June 29, 2019 Updated to 2019.06.29. May have broken the way it was, so I left the prior version as you may need it to compare the functions call. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
ldub Posted June 29, 2019 Share Posted June 29, 2019 _MailSlot_Write : undefined function ! Link to comment Share on other sites More sharing options...
argumentum Posted June 29, 2019 Author Share Posted June 29, 2019 Thanks @ldub, I forgot about the underscore 😅 Uploaded a fixed one Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now