Coding Slow and Sure
Published on May 2, 2009 By SlowCoder In DesktopX

When I first learned about DX, Stardock claimed

Rather than having to learn proprietary scripting languages, DesktopX uses Windows Scripting Host so that developers can interact with devices and the OS in any scripting language they choose (VBScript, Javascript, Perl, etc.).

Very cool, I thought. For me it was a major motivation to buy the software. But in the latest version, alas, no perl. I don't know if it is still planned for a future version. I even don't know if there is a future version planned. But then again I've not been following the forums.

In the meantime I worked out a workaround using Windows Script Components (WSC). Information about these is on MSN and at ActiveState. Basically it is an XML file in which you define the COM interface that is implemented in any scripting language that has an ActiveX engine. Here is an example

<?XML version='1.0'?>
<!-- file: C:\Slowcoder\PLSTEST.WSC -->
<package>
 <component id='Slowcoder.PLSTEST'>
  <registration
   progid='Slowcoder.PLSTEST'
   description='Slowcoders try at Perl with DesktopX'
   version='1.0'
   clsid='FG7BEEF6-1BFB-4A6E-B576-17D12345677F'
  >
  <public>
   <method name='TryThis' />
  </public>
  <script language='PerlScript' src='C:\Slowcoder\PLSTEST_IMPLEMENTATION.PLS' />
 </component>
</package>

This is the file that you have to register with Windows:

 C:\Slowcoder> REGSVR32.EXE PLSTEST.WSC

Now you have a new COM component that can be used from JavaScript in the usual way, for example from an Object_OnLButtonDown callback function:

function Object_OnLButtonDown (X, Y) {
 var PLSTEST_Object = new ActiveXObject ('Slowcoder.PLSTEST')
 PLSTEST_Object.TryThis ()
}

But before doing this, first we have to write the (perl!) code that implements the TryThis method. This is the function of the C:\Slowcoder\PLSTEST_IMPLEMENTATION.PLS file.

Just to complicate things a little, I want to do all the DX object manipulation from the perl code. One way which I like very much is to give a reference to the DX object as a parameter to the perl function. From the DX JavaScript I will use:

 PLSTEST_Object.TryThis (Object)

So what does the implementation look like? Well, it's a perl sub that changes the text of my test object. The code:

# C:\Slowcoder\PLSTEST_IMPLEMENTATION.PLS

sub TryThis {
 # the parameter holds a  reference to the DX Object
 my $DXObject = $_[0];
 # just use properties and methods from the object here
 $DXObject->{Text} = 'Hello, desktop!';

}

With thousends of perl modules available the only limit is your imagination!


Comments
on May 03, 2009


I even don't know if there is a future version planned.

Give you feedback what you want in Future version : https://forums.wincustomize.com/345094

on May 03, 2009

Thanks for the link

on May 03, 2009

Welcome