No announcement yet.

HS-MCE 2005 Caption Interface

  • Filter
  • Time
  • Show
Clear All
new posts

    HS-MCE 2005 Caption Interface

    I know this is not strictly a HS Script or plugin (uses existing available HS scripts), but it was designed and built just to interface with HS. Its posted here as its very much an "in progress" project..

    This is the product of 12hrs and two packets of chocolate M&M' is unpredictable and would probably be considered as a pre-alpha release, it is provided with no guarantees (if it wipes your hard drive/grows legs and runs off with your wife/crashes your PC and sets it on fire then I am not accountable). It may be of use to no one, but if you want to use it feel free. I am a casual programmer at best, by no means anything other than a hobbyist.

    I've been after a way of getting information from HS into Windows Media Centre (2005) for a while, while I am watching a movie I would like to know if someone is at the door, if there is motion detected elsewhere etc without having voice announcements spoil my entertainment. There could already be a script out there that does this, if there is I don't want to step on anyones toes, i've not seen one so thats why I have done this - I know MCE 2005 is considered old by some, but its the one I currently run and will do for some time.

    A while ago I came across this ( which gives details about showing dialogs in MCE from external applications. I sat on it for a while and then realised I should put it to good use. It supports a title, some text, an image and then a timeout.

    Using the released demo project I modified the VB6 application incorporating a Winsock control to accept incoming text TCP data.

    Then using SteveA's excellent SocketSend.vb script (available here I set about sending data from HS, across the network and into MCE.

    I've attached a screenshot of where I am at the minute...

    The instructions on using this are;

    1) Install the MCE plugin, having first downloaded it from the site. Install it on your MCE computer, there is a batch file included that will do most of the work for you.

    Ensure you copy gacutil.exe (some sort of .net compiler - should be on your PC somewhere) into the directory of the MCE plugin files. It is important you do this, I didnt initially and MCE crashed and reset the PC every time it loaded.

    2) Copy the attached program onto your MCE PC, it is written in VB6 and whilst the program is essentially very simple you may need to install MSWINSCK.ocx if you do not have it on your PC. You can download it off the net if you do not have it. That is its only dependency to my knowledge.

    I would suggest installing it to somewhere like C:\MCEPlug or similar, if you want the image file then also copy it into the directory, it defaults to myhomeseer.png which is the logo file for the MCE plugin.

    It does connect on load, so it should be happy enough placed in your startup directory.

    See if the program connects/disconnects without error, if so move along...

    3) Install SteveA's script into your HS directory, if you are already using it to control MCE then you may be able to run a 2nd copy with SocketSendText2.vb etc. Ensure that the ini file is updated with the IP address and port you wish to use (defaults to 107, just one I picked at random).

    4) All well and good you should be pretty much there;

    To pass information from HS into MCE you need to call the script (SocketSendText.vb) and pass it some parameters;

    i) Title
    ii) Text
    iii) Blank - reserved for future - poss image transfer/selection
    iv) Seconds for the message to stay on the screen

    For example;

    &hs.runex "SocketSendText.vb","SocketSendText","HOMESEER,Someone is at the door,,3"
    Will display what the attached image file shows...

    Thats pretty much it, the only limit is your imagination on what to send it - caller ID, log errors, email receipt, weather or whatever.

    Now the problems with it are;

    i) Error Control - or lack of it, I have not coded any real error control, whilst i've done a bit of testing it is not extensive. You pass a variable that it does not like then you may get nasty errors produced and the client side program terminate itself (HS should remain intact)

    ii) Disconnection/Reconnection - this is somewhat harder to recreate, it will sometimes be happy connected for hours, then you won't be able to send two messages in succession. I am trying to find out why - for now I would suggest sending a CloseSocket request after you send any message to it.

    Sometimes you need to restart MCE if you have disconnected/reconnected the application, can't seem to do anything about this.

    You will need to launch this app before you launch MCE.

    iii) The application is ugly - yes I admit it, very ugly, but its designed to run in the background on top of the eshell. If it actually works then I may put a minimise to system tray API into it.

    iv) Port saving/image path saving - To change the ports you would need to disconnect the app, change the port and then reconnect. Then when you next load the program it will default back. I'll look at some sort of ini file/text file that would be able to remember these settings.

    v) The delay - if you pass the delay for the message to disappear as "0" it is meant to stay on until you press OK, i've found it still goes away after about 7seconds...not sure why this is.

    Whilst I can provide no guarantee of support, if you do have problems then post them here and I will try and help by all means...certainly works for me at the minute.

    Hope it works for you and some of you are able to get some use out of it...source code is included you want to laugh at it/change it for the goes to SteveA for saving me time, I spent about 3hrs looking at ways of interfacing winsock with vbscript, only to realise that I had the solution all along with his MCE script interface...

    Last edited by mrhappy; July 22, 2010, 04:36 PM.

    Ironed out a few of the bugs (I think anyway);

    1) Disconnect/Reconnect - implemented a timer that relistens to the port after receiving data, seems to have worked for me.

    2) Included an ini file (settings.ini), specify the image path/port in this file and it will remember it on startup.

    3) Remote Close - if you send "Close,,," to the port it will disconnect the client remotely. You will need to close MCE, reconnect and launch MCE to get it back working again.

    4) Included another script - mcecapt.txt, this contains a socket close, a delay, sending of the text and a log write.

    You can fire it by the following;

    &hs.runex "mcecapt.txt","Main","HomeSeer,Its raining,,5"
    You may get some errors in the log about closing ports that are not open, either ignore these errors or you can comma out the lines in the socketsendtext.vb script to prevent you getting them in the future.

    I'm still getting the occasional refusal by MCE to display the caption, even though its received by the app - not sure why this is - possibly fault with MCE somewhere, a restart of MCE corrects this...not ideal I know.

    Edit; should really attach the file should'nt I!
    Last edited by mrhappy; July 22, 2010, 04:36 PM.


      will this work on vista?


        Sorry but it does not work at all properley in MCE anymore (windows changed the way plugins were handled leading them to be unloaded every 10mins without activity, i'm no MCE programmer so could not fix this) so no I don't think it will work in vista at all. A shame because I quite liked the functionality...and I do have vista.

        One thing to look out for is a freeware caller ID package for vista, you may be able to send data to a client via a socket connection and show dialogs from HS.


          Thanks, ill take a look at this.. I might go back to MCE 2005... and try out yours however.. Thanks