Seeker Posted November 18, 2005 Share Posted November 18, 2005 http://www.autoitscript.com/forum/index.php?showtopic=11144But still I want to read/write to the mailslot. In VBS you can do it like this:'Setup some variables sText = "Here is a message" & vbCrLf & "with a linefeed." sFrom = "Administrator" 'Create a File System Object Set oFS = WScript.CreateObject("Scripting.FileSystemObject") 'Send the message to everyone Call SendMsg(sText, "YourComputer", "YourName", sFrom) Wscript.Quit '--- End of Script ---- Sub SendMsg(sMsg, sTo, sGrp, sUser) 'Define Mailslot name: sFN = "\\" + sTo + "\MAILSLOT\messngr" 'Object Text Stream: Set oTS = oFS.CreateTextFile(sFN, True) oTS.Write sUser + Chr(0) + sGrp + Chr(0) + sMsg & Chr(0) oTS.Close Set oTS = Nothing End SubBut in autoscript I didn't manage to use those object nor to write directly to malslot:Func SendMsg($sMsg, $sTo, $sGrp, $sUser) ; 'Define Mailslot name: ; $aCallReturn = DllCall('kernel32.dll', 'str', 'CreateMailslot', '\\.\MAILSLOT\messngr', 0, 'MAILSLOT_WAIT_FOREVER', 0) ; MsgBox(0, "test",$aCallReturn) $sFN = FileOpen("\\" & $sTo & "\MAILSLOT\messngr", 2) MsgBox(0, "test",$sFN) FileWrite($sFN, $sUser & Chr(0) & $sGrp & Chr(0) & $sMsg & Chr(0)) EndFunc Func SendMsg2($sMsg, $sTo, $sGrp, $sUser) ; $sFN = "\\" & $sTo & "\MAILSLOT\messngr" $sFN = "c:\_test.txt" $oTS = $oFS.CreateTextFile($sFN, True) $oTS.Write($sUser & Chr(0) & $sGrp & Chr(0) & $sMsg & Chr(0)) $oTS.Close EndFuncI even tried to use 'kernel32.dll' -call like this:$sFH = DllCall('kernel32.dll', 'str', 'CreateMailslot', '\\.\MAILSLOT\messngr', 0, 'MAILSLOT_WAIT_FOREVER', 0)Yes. I do something wrong. But what? Link to comment Share on other sites More sharing options...
DaveF Posted November 19, 2005 Share Posted November 19, 2005 AutoIt's FileOpen function uses the low-level fopen() function to do its job, and I'm guessing fopen() doesn't understand NT kernel pseudofiles like \\.\mailslot and \\.\pipe .By using the COM functions in the AutoIt beta you might be able to make a direct translation of your VBS script. Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
Seeker Posted November 20, 2005 Author Share Posted November 20, 2005 By using the COM functions in the AutoIt beta you might be able to make a direct translation of your VBS script.As you can see I even tried that. Didn't work... Next please Link to comment Share on other sites More sharing options...
Seeker Posted November 21, 2005 Author Share Posted November 21, 2005 Here is the full code I used to test mailslots. What am I doing wrong?I've tested so far:Write straight to mailslot pseudofileConverted VBS to AU3 (tried to use these COM-calls)Tried to call kernel32.dll$sText = "Here is a message"; & @LF & "with a linefeed." $sFrom = "Administrator" $oFS = ObjCreate("Scripting.FileSystemObject") ; 'Send the message to everyone SendMsg($sText, ".", "Administrator", $sFrom) Func SendMsg($sMsg, $sTo, $sGrp, $sUser) ; $aCallReturn = DllCall('kernel32.dll', 'str', 'CreateMailslot', '\\.\MAILSLOT\messngr', 0, 'MAILSLOT_WAIT_FOREVER', 0) ; MsgBox(0, "test",$aCallReturn) $sFN = FileOpen("\\" & $sTo & "\MAILSLOT\messngr", 2) FileWrite($sFN, $sUser & Chr(0) & $sGrp & Chr(0) & $sMsg & Chr(0)) EndFunc Func SendMsg2($sMsg, $sTo, $sGrp, $sUser) $sFN = "\\" & $sTo & "\MAILSLOT\messngr" ; $sFN = "c:\_test.txt" $oTS = $oFS.CreateTextFile($sFN, True) $oTS.Write($sUser & Chr(0) & $sGrp & Chr(0) & $sMsg & Chr(0)) $oTS.Close EndFunc ; DllCall("kernel32.dll", "int", "SetConsoleTitle", "str", $NewTitle) ; CreateMailslot(lpszSlotName, 0, MAILSLOT_WAIT_FOREVER, (LPSECURITY_ATTRIBUTES) NULL); ; $sFH = DllCall('kernel32.dll', 'str', 'CreateMailslot', '\\.\MAILSLOT\messngr', 0, 'MAILSLOT_WAIT_FOREVER', 0) ; MsgBox(0, "test",$sFH) Link to comment Share on other sites More sharing options...
DaveF Posted November 21, 2005 Share Posted November 21, 2005 As you can see I even tried that. Didn't work... Next please I could see that how? From code you didn't post until today? Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. 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