torels Posted April 9, 2009 Share Posted April 9, 2009 (edited) Hi there!I made this COM object to create a communication between 2 apps using files... a very simple VBScript, but I liked the idea i could comunicate between 2 scripts (or 2 programs written in different languages too) without having to set up tcp servers/clients or writing/deleting files all the time I hope you like it Here is the COM bject<component> <registration progid="Comunication.Object"/> <public> <method name="GetMessage"/> <method name="SetMessage"> <PARAMETER name="text"/> </method> </public> <script language="VBScript"> Set WshShell = CreateObject("WScript.Shell") Set objEnv = WshShell.Environment("Process") Dim objFSO, objOutputFile Dim strOutputFile Dim out strOutputFile = objEnv("Temp") & "\tmpmsg.txt" Set objFSO = CreateObject("Scripting.fileSystemObject") Function SetMessage(text) Set objOutputFile = objFSO.CreateTextFile(strOutputFile, TRUE) objOutputFile.Write(text) objOutputFile.Close End Function Function GetMessage() Set objFile = objFSO.OpenTextFile(strOutputFile, 1) out = objFile.ReadAll objFile.Close GetMessage=out End Function </script> </component>Save this as AnythingYouWant.wsc then run("@comspec & ' /C RegSvr32 /s YourWscFile.wsc'") . This is because you need to register you WSC file. You just have to do it Once.More info HERE.here are 2 example scripts:Script 1$com = ObjCreate("Comunication.Object");Create the object $com.SetMessage("hello world");Send the messageScript 2$com = ObjCreate("Comunication.Object");Create the object MsgBox(0,"",$com.GetMessage());Get the messagecomments, bug reports and suggestions are welcome Edited April 9, 2009 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
Developers Jos Posted April 9, 2009 Developers Share Posted April 9, 2009 I am wondering why you not simply create 2 UDFs called SetMessage() and GetMessage()? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
torels Posted April 9, 2009 Author Share Posted April 9, 2009 (edited) This allows you to comunicate between different programming languages too To do that with a UDF you would have to compile the au3 file and pass parameters to it to use it in other languages, or call autoit3.exe btw... I had some Doubts weather this was the right section or not. If it isn't could you please move it to chat, or whatever you think is the appropriate section ? thanks Edited April 9, 2009 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted April 9, 2009 Share Posted April 9, 2009 While I thank you for showing just how easy it is to create COM objects, I also have to question the usefulness of an entire object to write to/read from a file. We do have functions to do that already, that don't have the additional overhead of Creating and managing COM objects. Link to comment Share on other sites More sharing options...
torels Posted April 9, 2009 Author Share Posted April 9, 2009 as said in the first post, this is to avoid writing several lines of code to write/read from the file (just take a look at what it takes in vbs) or create a tcp server and client (that is a discrete amount of code, compared to 4 lines )by the way... creating and managing COM objects is very simple and easily accessible Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org 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