sending/receiving activex messages with XScript?

Xlobby plugin development

sending/receiving activex messages with XScript?

Postby macboy on Thu Jun 07, 2007 6:54 pm

I have a question for you gurus out there, especially ones familiar with XScript.

I need to interact XLobby with another program which can send and receive ActiveX messages. I have written several VBScripts which interact with said program. Now I need to extend that experience to XLobby. I want to send commands to the program when buttons are pushed in XLobby, and I want to receive data (just some text and/or numbers) back and display it in XLobby. The responses come from the app in the form of ActiveX messages.

I do need help understanding what I need to get XLobby talking to the ActiveX control. Do I need XScript? Is that all I need? Can I use VBScript or something very similar? Does someone have code examples of registering with an ActiveX control for events, or is it so similar to VBScript that I don't even need to worry?

My intention is to do the legwork to get XLobby talking to a Slink-e device. The device itself, and its serial interface, are complicated, but luckily it comes with an application called SlinkeServ which does ALL the hard work, and it simply sends messages and receives commands (via an ActiveX control) to/from other applications which want to control devices attached the the Slinke. My goal is to get one or more Sony 400 Disc CD changers to connect to XLobby interactively (they can send status back via the Slinke, including track number, play time, and even track names). Again, I have a lot of experience writing VBScript code to interact with the CD Changers via the SlinkeServ ActiveX control (Slinkx). IR Transmit/receive to/from Slinke is another goal. Obviously once it is working I will contribute my efforts back to the xLobby community.

There are a few posts in the forum regarding the Slink-e. Nobody tackled it because it was deemed too difficult, but they did not consider how incredibly easy it is to interact with SlinkeServ (as opposed to the difficulty of directly interacting with the Slink-e over RS232). Here is an example of how easy it really is. This is a script which will tell a CD changer to "play":

set SlinkX1 = CreateObject("Slinkx.SlinkxCtrl.1")
SlinkX1.Send "cdp400", "Play"

That's it. Receving status back from the SlinkX1 object is just as easy. I'd just like some pointers to get started: what plugin(s) if any are needed, and maybe some code examples of interaction with an ActiveX control.
macboy
 
Posts: 8
Joined: Thu Jun 07, 2007 6:26 pm

Re: sending/receiving activex messages with XScript?

Postby macboy on Wed Jun 13, 2007 6:55 pm

Well, even though nobody has piped up and responded, at least some people have read this post so someone must be interested in whether you can interact with an ActiveX control using XScript. So here is the answer: No. Sort of. Well, maybe.

XLobby works in the .NET world. XScript also does. The VB (or C#) code which XScript compiles and runs is .NET code. Here is the problem: .NET cannot use ActiveX (COM) controls. However, the .NET SDK comes with a utility to import ActiveX, logically called AxImp.exe. This will generate a wrapper for the ActiveX (in my case, slinkx.ocx) which allows .NET code to use it... Actually no it can't. But all the documentation for AxImp doesn't tell you that. The namespace still isn't visible to just any .NET application (like Xlobby or XScript), so we need to add it to the GAC, Global Access Cache. To do that, we need to give it a 'strong name' (basically a unique name) using Sn.exe. Then you need to add the new .NET-ready dll to the GAC using GacUtil.exe. Then, if you are lucky, the namespace (methods, properties, etc. provided by the dll) will be available to .NET applications. And if you are really lucky, it might even be usable in XScript scripts. I don't yet know if this works because I am still learning all this crap and haven't had a chance to try out the last few steps. I certainly did not expect to need to jump through all these hoops. MS probably thinks that this is all simple and easy to learn and use.

If anyone has any insight as to whether I am on the right track or not, let me know. I believe that it can be done, and I think I am close.
macboy
 
Posts: 8
Joined: Thu Jun 07, 2007 6:26 pm

Re: sending/receiving activex messages with XScript?

Postby bmblank on Wed Jun 13, 2007 7:48 pm

Just about all of that went over my head like a jet, so it feels like I'm trying to dumb you down to my level (I'm not trying to...). I don't know if you're aware, but there is a plugin called XReceive that may help you in your quest. I humbly apologize if this is old news.
bmblank
 
Posts: 233
Joined: Fri Jun 30, 2006 12:55 pm

Re: sending/receiving activex messages with XScript?

Postby macboy on Wed Jun 13, 2007 8:26 pm

Don't worry, three days ago it would all have been over my head as well. And as I said, I don't even claim to understand it all myself yet.

Thanks for the tip on XReceive. I had not seen that one yet, and it will probably do what I want (albeit probably a little inefficiently). I REALLY wish that there was a comprehensive and up to date plugins page where we could all go to see what is available.
macboy
 
Posts: 8
Joined: Thu Jun 07, 2007 6:26 pm

Re: sending/receiving activex messages with XScript?

Postby bmblank on Wed Jun 13, 2007 8:30 pm

Just so happens one such organized soul has put one together. :D (It wasn't me...)
viewtopic.php?f=11&t=4617&st=0&sk=t&sd=a&hilit=MASTER+PLUGINS
That page directs you to here:
http://www.xlobby.com/files/Marbles_00/ ... n_List.htm

Thanks be to Marbles_00 for putting that together.
bmblank
 
Posts: 233
Joined: Fri Jun 30, 2006 12:55 pm

Slink-e two-way communication working using XReceive

Postby macboy on Thu Jun 14, 2007 2:05 pm

So I messed around a little with XReceive yesterday and I got some basic interaction working. I mocked up a screen with basic controls (play, stop, prev, next) and a track name, artist name, and time display. It worked well. At that point I was interacting with CDJ (which is a 'jukebox' program included in the Slink-e software package) rather than directly with the CD changers.

At this point I think that I will forget about using XScript(NG) and go this route, with a VBS script interacting with the SlinkeServ ActiveX control and sending appropriate data back to XLobby using XReceive (mostly by setting variables). Commands will be sent out of XLobby using either a command-line program, or possibly XScript if I need something fancy.

So now that I know I can fully interact with the Slink-e in XLobby, this opens up very powerful control possibilities. Slink-e supports 8-zone IR transmit and receive, with built-in command encoding/decoding, and I will support that in XLobby. Of course the most powerful feature of Slink-e is the two-way communications using Control-A1 ("S-link") connections to Sony audio stuff. I plan not only to control my CD changers, but also my A/V Receiver. Full, two-way control of the receiver is possible using the Slink-e. Everything on the receiver that is user-configurable can be set and queried this way. I will base my XLobby GUI on the built-in GUI for the new STR-DA5200ES receiver, which you can drool at here. It is based on the cross-bar interface Sony has used on PSP and PS3. Xlobby with Slink-e will be able to interactively control all mid- and high-end Sony receivers built in the last 10 years or so (i.e. it must have a Control-A1 jack).

I hope this is exciting to some people who have some Sony gear in their racks. Sadly, the Slink-e is discontinued. However, many Slink-e owners who owned the device only for the purpose of controlling multiple 400-CD changers, are now moving to hard-drive based music systems and selling the Slink-es. So they pop up on e-bay every so often (for reference it was a $250 device new). But being a DIY geek, I built my own. That project isn't quite complete, but the basic functionality is there. I plan to someday sell kits so that people can build their own cheaply. The Slink-e was many things, and cheap wasn't one of them.

If anyone wants to contribute (especially skinning gurus) let me know. If anyone has a Slink-e and a rack full of Sony gear, and wants to be a tester, let me know. I'll start up a separate thread if there is interest in this.
macboy
 
Posts: 8
Joined: Thu Jun 07, 2007 6:26 pm

Re: sending/receiving activex messages with XScript?

Postby bmblank on Thu Jun 14, 2007 3:35 pm

Again, it's mostly over my head, but that's great that you got it working. Given how many people are workin on it, xlobby has become a pretty powerful tool.
bmblank
 
Posts: 233
Joined: Fri Jun 30, 2006 12:55 pm

Re: Sending/receiving activex messages with XScript : Working

Postby macboy on Fri Jun 22, 2007 11:11 pm

I finally got this sorted out. I am able to use the Slink-e ActiveX control from with an XScriptNG script! Yeah! OK, I can tell you are not as excited by this as I am, but try to show a little enthusiasm.

I will put together a how-to and post it here, explaining how to use any Activex control in a XScriptNG script. This will allow MUCH easier creation of plugins to control all sorts of other hardware and other software. Basically anything which has an ActiveX control could have a plug-in created with XScriptNG, and anyone can do it with a simple text editor - no costly visual studio .NET developement environment or the associated learning curve will be required.

Many products related to home automation and/or input/ouput devices have an ActiveX control, provided either by the manufacturer or a third-party. Examples could include X-10, using the free X-10/CM11a (ActiveHome) ActiveX control provided by the makers of HomeSeer, or this CM17a (FireCracker) ActiveX called FUzE; Slink-e (my project); bi-directional interaction with HomeSeer, HASe, or many other home automation software packages, etc. The Slink-e in particular is a very powerful device. I don't mean to belittle the USB-UIRT, but Slink-e is far more versatile and powerful. Having it integrated into Xlobby will be a big step forward in getting Xlobby to interact with the world outside the HTPC box.

I truly believe that this will make writing powerful plugins much easier. The VB.NET language as used in these scripts is easy to learn and use, especially when you have a good example/template to start with. This should help bring plugin writing to the masses. Of course it is all made possible by the authors of XScriptNG (and of course XScript). I really hope that people take this information and run with it. I want to see some interesting uses of ActiveX in Xlobby!

Here's briefly what my script does now: After it is run for the first time, it waits for messages from the Slink-e telling it that some device has sent some data on the Control-A1 bus (or IR, or whatever). It can then respond to those messages in any way, including settings Xlobby vars, activating any Xlobby event... anything that XScriptNG allows. It can also receive any Xlobby event and respond to it by sending commands to any device on Control-A1 or IR etc. This will allow full bidirectional control of Sony audio gear, which includes a Receiver, 400 CD changer, and 5 disc SACD changer. It can also receive and transmit IR codes.

I will post a how-to and sample code here once I get it cleaned up a little. Stay tuned.

p.s. My other thread on RS-232 communications will open up a lot of other doors as well. I just posted some sample code there.
macboy
 
Posts: 8
Joined: Thu Jun 07, 2007 6:26 pm

Re: sending/receiving activex messages with XScript?

Postby m_ski on Thu Jun 28, 2007 11:40 am

macboy,

You can write complete xlobby plugins with a simple text editor - you do not need visual studio (Express versions are free anyway). The .NET framework comes complete with command line compilers for vb.net and c#.net (vbc.exe and csc.exe in your .NET directory within the Windows folder).
You will probably find that your interface to slink-e can be much more effective using a proper plugin. Art posted a basic template for a plugin here - http://www.xlobby.com/forum/viewtopic.php?f=14&t=2952&st=0&sk=t&sd=a&start=15
m_ski
 
Posts: 204
Joined: Wed Dec 08, 2004 7:57 am
Location: Kent, United Kingdom