Popular Post trancexx Posted December 11, 2009 Popular Post Share Posted December 11, 2009 (edited) This way of communication between processes very much resemble to the communication we do with our mail accounts. I would guess (smartly, no doubt) that was the key factor used for naming the functions when they were created.Information about mailslots can be found on microsoft's site, link. Summary could be that datagrams are used for communication and it's one-way and asynchronous.Attached zip file contains MailSlot.au3, AutoIt's implementation of these functions. Also there would be two scripts in there MailSlot_Sender.au3 and MailSlot_Reciever.au3. Both scripts are demos of the mailslot mechanism. Start both and use former to send mails to latter. Examples are basic and should show what's this about.MailSlot.zipAvailable functions are alphabetically:_MailSlotCheckForNextMessage_MailSlotClose_MailSlotCreate_MailSlotGetMessageCount_MailSlotGetTimeout_MailSlotSetTimeout_MailSlotRead_MailSlotWriteedit: New attachment. _MailSlotGetTimeout() function added to MailSlot.au3. Edited December 15, 2009 by trancexx mLipok, robertocm, czardas and 7 others 7 3 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
martin Posted December 12, 2009 Share Posted December 12, 2009 (edited) This is great trancexx, but one of the most interesting things that you didn't mention is that this works across a network. There's another good link here which explains some of this. If you use this over a network then pay attention to the caveats in that link.Thanks for this thread. Edited December 12, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Michel Claveau Posted December 13, 2009 Share Posted December 13, 2009 (edited) Hi, Trancexx ! I had played with Mailslot, in past. Your functions are better than my "hardcoded" tests. (your) mailslot is compatible with the waitfor command-line from Windows, or my others libs (i.e. in Python) (I tested the two cases). Thanks (and sorry for my bad english). Two little things: - read a Mailslot without data give, on my 7, a "Autoit memory allocation error". - your functions are OK with ASCII messages, but, when I tested messages in UTF-8 or CP1252, with diacritics, there are some worries (not very important) @-salutations -- Michel Claveau Edited December 13, 2009 by Michel Claveau Link to comment Share on other sites More sharing options...
trancexx Posted December 13, 2009 Author Share Posted December 13, 2009 Hi, Trancexx ! I had played with Mailslot, in past. Your functions are better than my "hardcoded" tests. (your) mailslot is compatible with the waitfor command-line from Windows, or my others libs (i.e. in Python) (I tested the two cases). Thanks (and sorry for my bad english). Two little things: - read a Mailslot without data give, on my 7, a "Autoit memory allocation error". - your functions are OK with ASCII messages, but, when I tested messages in UTF-8 or CP1252, with diacritics, there are some worries (not very important) @-salutations -- Michel Claveau No, thank you. "Autoit memory allocation error" is my mistake. I've located a mistake and will correct it... eventually. The problem is _MailSlotCheckForNextMessage() function. Corrected would be: If $aCall[3] = -1 Or Not $aCall[4] Then Return 0 Else Return $aCall[3] EndIf instead of current: If $aCall[3] = -1 Then Return 0 Else Return $aCall[3] EndIf Same thing can be done with _MailSlotGetMassageCount(), but it shouldn't strictly be necessary. Unicode problem is likely not related to these functions. You can always read binary and interpret it the way you like it, as I'm sure you are aware of. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
The Kandie Man Posted December 13, 2009 Share Posted December 13, 2009 This is great. I found only one nitpicking issue: _MailSlotGetMassageCount() Perhaps you meant: _MailSlotGetMessageCount() Just a typo, good work though. - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
trancexx Posted December 13, 2009 Author Share Posted December 13, 2009 lol ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
trancexx Posted December 13, 2009 Author Share Posted December 13, 2009 There. New and improved scripts posted. I added one new function while at it. It's _MailSlotSetTimeout() to change time-out for reading at any time. Thanks for the heads up. Much appreciated. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Michel Claveau Posted December 13, 2009 Share Posted December 13, 2009 (edited) Hi, all ! Here a very simplist example, who show dialog/drive (with) a Batch.#include "MailSlot.au3"writebat()run("C:\MStest.bat")Sleep(2000)Global $sMailSlotName = "\\.\MailSlot\waitfor.exe\SIGNAL"_SendMail($sMailSlotName,"1")Sleep(2000)_SendMail($sMailSlotName,"2")Sleep(4000)_SendMail($sMailSlotName,"3")Exit Func _SendMail($sMailSlotName,$sDataToSend) _MailSlotWrite($sMailSlotName, $sDataToSend, 1) Switch @error Case 1 MsgBox(48, "MailSlot error", "Account that you try to send to likely doesn't exist!") Case 2 MsgBox(48, "MailSlot error", "Message is blocked!") Case 3 MsgBox(48, "MailSlot error", "Message is send but there is an open handle left." & @CRLF & "That could lead to possible errors in future") Case 4 MsgBox(48, "MailSlot error", "All is fucked up!" & @CRLF & "Try debugging MailSlot.au3 functions. Thanks.") Case Else ;MsgBox(64, "MailSlot", "Sucessfully sent!") EndSwitchEndFunc ;==>_SendMail Func writebat() $b="" $b &= "@echo off " & @CRLF $b &= "echo Etape_1" & @CRLF $b &= "waitfor /T 60 SIGNAL"& @CRLF $b &= "echo Etape_2" & @CRLF $b &= "waitfor /T 60 SIGNAL"& @CRLF $b &= "echo Etape_3" & @CRLF $b &= "waitfor /T 60 SIGNAL"& @CRLF $b &= "echo Etape_4" & @CRLF $b &= "pause Ended" & @CRLF $f=FileOpen("C:\MStest.bat",2) FileWrite($f,$ FileClose($f)EndFuncMStest.au3 Edited December 13, 2009 by Michel Claveau Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 13, 2009 Moderators Share Posted December 13, 2009 trancexx, Well up to your usual standard. Thank you for sharing. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Digisoul Posted December 13, 2009 Share Posted December 13, 2009 Great Script Trancexx , this is the most reliable I.P.C method then others. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
martin Posted December 13, 2009 Share Posted December 13, 2009 (edited) Hi, all ! Here a very simplist example, who show dialog/drive (with) a Batch.I think that got a bit messed up! I think this is what you tried to post.Code removed now that Michel has corrected his post.I'll delete this post when you've corrected yours.I decided not to delete this post or the next one makes no sense. Edited December 13, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Michel Claveau Posted December 13, 2009 Share Posted December 13, 2009 Re ! Thanks, Martin.I had no found how to edit a message with some code.I am not made for modern-english's methods Link to comment Share on other sites More sharing options...
dmob Posted December 14, 2009 Share Posted December 14, 2009 (edited) Congratulations to you!!! I have successfully implemented your UDF across a network, and you Sir, have enabled me to solve a problem I've had for a while now and you've made me a very happy man! Thanks for your work, and for sharing. Five stars from me Edited December 14, 2009 by dmob Link to comment Share on other sites More sharing options...
JRSmile Posted December 15, 2009 Share Posted December 15, 2009 hi trancexx, you saved my ass i just thought about fifo buffering tcp packets and crawled the forum a bit, found the mmap udf but this wasn't the right thing now with your udf i can go on with my project thank you very much. Best regarrds, JR. $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
trancexx Posted December 15, 2009 Author Share Posted December 15, 2009 I think it would be necessary to have one more function _MailSlotGetTimeout(). That way you could read current time-out, change it to new, read the message, restore the old time-out. Yeah, that's missing. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JScript Posted March 15, 2011 Share Posted March 15, 2011 (edited) @trancexx Hello, I see that your UDF will solve my problem with function TCPConnect() it takes on average 20 seconds to return control to the program if no connection found (...) Send Broadcast messages (TCP does not support broadcast, UDP does, but not using NAT), simple to implement, there is no doubt that it is better than the TCC/UDP (at least for me). Already solved 90% of my problems, but I have left some questions: 1 - Records smaller than 425 bytes?!? Why? No way around? 2 - Transferring files (binaries)? Thank you for your attention. Edited March 15, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
JScript Posted March 16, 2011 Share Posted March 16, 2011 (edited) Wow! I had never paid attention to the item "NamedPipes Management " in the AutoIt help file!And using NamedPipes we can transfer more than the 425 bytes of the mailslot...Edit: http://www.codeproject.com/KB/threads/Win32IPC.aspx@trancexx, you could create an example of using "NamedPipes" the same way that the mailslot? Edited March 16, 2011 by jscript Doniel 1 http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
trancexx Posted March 16, 2011 Author Share Posted March 16, 2011 (edited) @trancexxHello,I see that your UDF will solve my problem with function TCPConnect() it takes on average 20 seconds to return control to the program if no connection found (...) Send Broadcast messages (TCP does not support broadcast, UDP does, but not using NAT), simple to implement, there is no doubt that it is better than the TCC/UDP (at least for me).Already solved 90% of my problems, but I have left some questions:1 - Records smaller than 425 bytes?!? Why? No way around?2 - Transferring files (binaries)?Thank you for your attention.Well hello there.There shouldn't be 425 byte limit. You are probably doing something wrong, maybe sending/reading as string with null terminator as 425th character.You can transfer binary data, there is a flag for that, default even. Don't limit your self on my examples, they are there just to show the main principle of communication. Edited March 16, 2011 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JScript Posted March 16, 2011 Share Posted March 16, 2011 (edited) Well hello there.There shouldn't be 425 byte limit. You are probably doing something wrong, maybe sending/reading as string with null terminator as 425th character.You can transfer binary data, there is a flag for that, default even. Don't limit your self on my examples, they are there just to show the main principle of communication."...Mailslot messages can be of around 400 bytes only.", please check this link: http://www.codeproject.com/KB/threads/Win32IPC.aspx"...cannot be larger than 424 bytes when sent between computers.", and this: http://msdn.microsoft.com/en-us/library/aa365130%28v=vs.85%29.aspx Edited March 16, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2011 Moderators Share Posted March 16, 2011 jscript,If you look at the link martin provided in post #2, you read this:"Boring technical note from Microsoft Records smaller than 425 bytes are sent using datagrams. Records larger than 426 bytes are sent using a connection-oriented transfer over an SMB session. Connection-oriented transfers are limited to one-to-one communication from one client to one server. Note that Windows does not support records that are 425 or 426 bytes."Certainly I have never had any trouble sending more than 425 bytes to multiple receiver scripts using the mailslot. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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