Jump to content

Recommended Posts

  • Moderators

argumentum,

Looks nice, but why do I get 2 copies of the message if I change the content of the input? As I would imagine that is the most likely case, it seems strange.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

in the example, there is a global counter.
The sender notes the message as >>> Counter >>>, then the receiver gets the <<< Counter <<<, that way you can see that the counter is the same in both, sender and receiver.

There is also a "Rounds" counter, so when you send, send X times, one right after the other, to test the semaphore and timeouts, therefore the 1 of 1 or 1 of x.

There is a Turn around: x ms. in one, the sender, to see the time it took to send and return from the function.

In the example you can:
- Change the $g__FMIPC_Size of the message. The message is upto half the size of the memory file created.
- Change the $g__FMIPC_Timeout of the message. ( A $var can be created by the scriptor, to use as a buffer, to retry later, via Adlib or what not, if there was an error sending, but all that would be the in the creativity of the scriptor/user, based in his/her code needs/ability/imagination/circumstances )
- Change how many times it will send in "rapid fire", by the $iRounds of the For Loop, to stress test the environment

Even tho, the script fires up the 2 other instances that do the testing, one can, run each independently with the command line of "one" or "another", to run it as different user levels and test that too. Much of the code will look like the help file's own example, as all this is taken and rearranged from the help file.

And thanks for asking, I was tired and did not include this, hopefully clarifying explanation.

And to anyone reading this, if you find a flaw or improvement, do share.

If there is need for support, please post it on [Solved] IPC between system and user's topic or general support forum   :) 

Link to post
Share on other sites

In this version (v0.2108.04.03)

Added a parameter to _FMIPC_Write(), to not wait until the message is flagged as read. ( I needed that feature. Default is to wait )
Removed the code from the 1st post. ( is easier to download the file and run, than copy paste all that )

Link to post
Share on other sites
  • Moderators

argumentum,

I have been playing with this UDF over the past few days - very nice indeed. I may have to change my "MailSlot" recommendation when asked about IPC in future.

One point - you set the UDF size and timeout variables within the example by direct assignments to the UDF global variables. It would be much better to have a small function within the UDF which could be called from the example to change these values when required - it is very poor coding practice to expose internal UDF variables to the user in this way.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

argumentum,

And you might want to put the _FMIPC_Write_ErrStr function in the UDF as well - it is better placed there than in the example itself.

Sorry to be picky, but it is worth getting a UDF as useful as this into as good a shape as possible.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

In this version (v0.2108.04.04)

  FuncName_ErrStr() are more and in the UDF itself.
  added _FMIPC_SetTimeout()
  added _FMIPC_SetSize()**
  changed _FMIPC_Create(). Without a parameter, will now use, StringTrimRight(@ScriptName, 4) & String(@AutoItPID), as the name.
  as such, a unique name is assigned by default, that can be easily discovered via ProcessList().

**_FMIPC_SetSize(), for now, can only be used before _FMIPC_Create(), due to a hiccup in _FMIPC_Close() that crashes the process, when the process stays running.
Hope to get to fix the bug soon, as I really want to have the functionality, but I don't have the time to investigate deeper and fix it right now, due to work  :( 
Any and everyone, is encouraged to look at it and fix it. I'll patch and update ASAP.

So this is an interim release until properly fixed. 

Edited by argumentum
Link to post
Share on other sites
  • 1 year later...
On 4/1/2018 at 5:56 AM, argumentum said:

I was in need of an IPC (Interprocess communication) between system, admin and user levels, and ended up writing this UDF to suit my wantings.

Hi argumentum,

(Sorry to dig out a year old thread)

I too was in need of an IPC to communicate bi-directional from system account to some user applications.

Have you really managed to get the user side to communicate with the system file map? (meaning sending anything from user --> system) This has always been the part I never got to work with your UDF or most of the other ways I found looking for a solution (including mailslots and other IPC UDF's).

I eventually ended up using tcp sockets and it worked on first attempt.

So actually my search has been ended. Just curious if you found a way to do this with your UDF's (Great work by the way 😉 )

 

Link to post
Share on other sites
4 hours ago, Conitental said:

I eventually ended up using tcp sockets and it worked on first attempt.

That is what I do myself most times. I never continued this code, that is more of a recompilation of code laying around than a personal brainstorm.

4 hours ago, Conitental said:

Just curious if you found a way to do this with your UDF's

The your UDF merits a clarification. The way I see it, everyone is welcome, and I encourage, the testing and bettering of code, any and all code.
I dislike the notion of intellectual property. The history of the code would be important for following the development, so mention of the collaborators in chronological order and their contribution carries this importance. Other than that, is our code ;) 

5 hours ago, Conitental said:

Have you really managed to get the user side to communicate with the system

Back then, when I tested, I thought I did. But to be fair, I don't remember much. I thought the code was good enough to share under the claim. I'd have to go back to it, and look at it again. And I will ( pinky swear ) to look at it at a future time, when I can devote some time to it :) 

5 hours ago, Conitental said:

Sorry to dig out a year old thread

Actually, thank you for bringing up, this having an issue no one was aware of, and posting about it.

Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SEuBo
      Hi there,
      while I created an example script to generate and execute a function during runtime, I stumbled across a neat way to share data between running autoit scripts.
      This is done using the amazing magic of  AutoItObject_Internal . (You'll need at least Version 3.0.0 of AutoItObject_Internal)
      Using this UDF, you can create a shared data storage, basically an empty "AutoitObject_Internal-"Object which you can then use to write / read data Inline. no set/get methods, just
      #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") $oShare.some_data = 'foo' and you're done. any other script accessing this data will have to do:
      #include "AutoItSharedData.au3" $oShare = _AutoIt_SharedData_CreateOrAttach("MyCustomID") ConsoleWrite($oShare.some_data & @LF)  
      Basically it's Larsj's Implementing IRunningObjectTable Interface, but you dont have a Dictionary, but an IDIspatch Object instead.
      There are already a bunch of IPC options available - and this is another one.
      AutoItSharedData.au3
       
      Example Script 1
       
      Example Script 2
      Output: 
      To test: run Example Script 1, Then run example Script 2.. or the other way around.
      Example Script 3
      Example_sharedata3.au3
      Example_sharedata3_Controlsend.au3
      Example_sharedata3_Tooltip.au3
      To test: run Example_sharedata3.au3.
      Output: 
       
       Example SharedData4:
      Output: 
      /Edit: Please note that there's a limitation with the Running object table :
      The Script accessing a variable first, will be the "server" for this variable. This means, access to that variable from other scripts should only be possible, as long the "server" script is running! Use appropriate Object Error handlers in case you don't want the surviving "clients" to crash.
      Feedback and/or improvements appreciated
       
      changelog
      version 2.0
      Removed need for AutoItObject, as AutoItObject_Internal now comes with ROT support Added UDF Header Fixed typo on "#include AutoItObjectInternal.au3" -> "#include AutoItObject_Internal.au3" Added ObjGet() after registering the object fails (in case 2 programs tried to register the same ID simultaneously) Updated Examples & zip archive. Cheers,
       
      AutoItSharedData.zip
    • By argumentum
      so in https://www.autoitscript.com/forum/topic/193254-solved-ipc-between-system-and-user/ I asked around about IPCs and got all the answers I was looking for.
      Now the question is: what IPC is most "resilient" on an overwhelmed PC, meaning, the CPU is at 100%, memory is top out and, as is always, need to rely on the IPC.
      ..and all this happened because I open over 100 GUIs at once 😜
      ..but it happens sporadically on low CPU or memory demand anyways.
      ..should I sleep() some time before running another instance ?
      I did not know if to make the question in technical, chat, ..or here. So it's here.   
      Since you will ask what I've tried, I've used the IPC from the Fork UDFish ( WM_COPYDATA that can do Admin/user mix ) and the FMIPC file mapping,  that work under the same conditions.
      So, how do you handle IPC if it fails ?
       
    • By tatane
      Hi,
      I would like to send an array from a script to a another. This array has 1000 rows and 4 columns with this kind of data :
      1st row  =     528  ;  31  ;   HOSTNAME|1|02:45:47|abcdefgh|username|5   ;   old
      2nd row = ...
      What IPC should I use ?
       
       
    • By argumentum
      There is this topic on Examples about IPC. My question is: What is the best IPC to work with between a script running as SYSTEM level, User level, and Administrator level to interact with each other ? 
      Thanks
    • By JohnWIlling
      IPC_IO.AU3
      I am in the need for a simple synchronous Client/Server communication.  I found several examples and references to various kinds of Inter-Process Communications such as TCP, Named Pipes, Mail Slots, Shared Memory, Memory Mapped Files, and simple Files.  I wanted to see what the best solutions would be.  I began developing a library and slowly began adding each of the IPC methods and ended up with a library with a very simple synchronous “ASCII” API where the application can choose which method to use at startup.
      For the Server side, a Server app must initialize communication by calling:
      Func InitConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE)
      The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data.
      A “File Descriptor” is returned and must be used in the future API calls.
      The Server side must then call:
      Func StartConnection($iFD)
      This call waits for a Client to connect.  The Server then calls:
                      Func ReadData($iFD, ByRef $sData)
      To read a Request from the Client and then calls:
                      Func WriteData($iFD, ByRef $sData)
      To send the reply back to the Client.
      When communication with the Client is done, the Server app will call:
      Func StopConnection($iFD)
      When the Server app is done with the communications it will call:
      Func EndConnection($iFD)
       
      For the Client side, a Client app must open the communication by calling:
      Func OpenConnection($cType = $cDefaultType, $ResourceName = "", $bBlock = $cDefaultBlocking, $fSleepFunc = "", $iBufSize = $DEFAULT_BUFSIZE)
      The optional arguments allow the app to specify the connection type (such as: $cNamedPipe, $cFile, $cTCP, $cSharedMem, $cMailSlot), a value for the resource name (such as the file, named pipe name, TCP port number, etc.), the communication buffer size, and a callback function for when the “read” is waiting for data.
      A “File Descriptor” is returned and must be used in the future API calls.
      The Client side then send a request to the Server app by calling:
                      Func WriteData($iFD, ByRef $sData)
      To read a Response from the Server by calling:
                      Func ReadData($iFD, ByRef $sData)
      To end the connection to the Server by calling:
      Func CloseConnection($iFD)
       
      Within the IPC_IO.AU3 library, each IPC method is ether:
      ·         “stream” based where data is read/written by calling _WinAPI_ReadFile/TCPRecv or _WinAPI_WriteFile/ TCPSend
      ·         “direct” based for Shared memory where the Client reads the data directly from the Server App’s memory and the Server directly reads the Client App’s memory
      In processing a request, the “ReadData” process starts by checking if data is ready to be read by calling the routine: “ReadStart”, then it reads in the size of the request by calling “ReadSize”, it then reads in the Ascii Request by calling “ReadBuffer”, then the sequence is completed by calling “ReadEnd”. 
      The Write Process follows the same sequence with “WriteData” calling “WriteStart”, “WriteSize”, “WriteBuffer”, “WriteEnd”.
       
      Results
      My testing showed that the performance of sending and receiving of a 10k file took:
      ·         "Shared Memory" was the fastest, at 0.007468 Sec
      ·         “Named Pipes” at 0.015954
      ·         “Mail Slots” at 0.016427
      ·         “File Based” at 0.270287
      ·         “TCP” at 0.994884
       
      IPC_IO.au3
      Client.au3
      Server.au3
×
×
  • Create New...