AutoHotkey Community

It is currently May 27th, 2012, 10:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: July 9th, 2007, 5:05 pm 
Offline

Joined: June 8th, 2007, 6:13 pm
Posts: 4
I am trying to interface to the Activehome SDK (free download at x10.com) and am having problems.

I am using the COM helper functions and used typelib to learn about the activex control:

Code:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: ahscript.dll

[
  uuid(001000AF-1DEF-0010-10B6-DC5BA692C858),
  version(1.0),
  helpstring("ActiveHomeScript 1.0 Type Library"),
  custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 100663657),
  custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1138924410),
  custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, Created by MIDL version 6.00.0361 at Thu Feb 02 15:53:29 2006
)

]
library ActiveHomeScriptLib
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("STDOLE2.TLB");

    // Forward declare all types defined in this typelib
    interface _IActiveHomeEvents;
    dispinterface _DIActiveHomeEvents;
    interface IActiveHome;

    [
      odl,
      uuid(001000AF-3DEF-0912-10B6-DC5BA692C858),
      helpstring("_IActiveHomeEvents Interface")
    ]
    interface _IActiveHomeEvents : IUnknown {
        [helpstring("method RecvAction - Called when commands have been received")]
        HRESULT _stdcall RecvAction(
                        [in] VARIANT bszAction,
                        [in] VARIANT bszParm1,
                        [in] VARIANT bszParm2,
                        [in] VARIANT bszParm3,
                        [in] VARIANT bszParm4,
                        [in] VARIANT bszParm5,
                        [in] VARIANT bszReserved);
    };

    [
      uuid(001000AF-3DEF-0911-10B6-DC5BA692C858),
      helpstring("_DIActiveHomeEvents Interface")
    ]
    dispinterface _DIActiveHomeEvents {
        properties:
        methods:
            [id(00000000), helpstring("method RecvAction - Called when commands have been received")]
            HRESULT RecvAction(
                            [in] VARIANT bszAction,
                            [in] VARIANT bszParm1,
                            [in] VARIANT bszParm2,
                            [in] VARIANT bszParm3,
                            [in] VARIANT bszParm4,
                            [in] VARIANT bszParm5,
                            [in] VARIANT bszReserved);
    };

    [
      uuid(001000AF-2DEF-0208-10B6-DC5BA692C858),
      helpstring("ActiveHome Class")
    ]
    coclass ActiveHome {
        [default] interface IActiveHome;
        [default, source] dispinterface _DIActiveHomeEvents;
        [source] interface _IActiveHomeEvents;
    };

    [
      odl,
      uuid(001000AF-3DEF-0910-10B6-DC5BA692C858),
      helpstring("IActiveHome Interface"),
      dual,
      nonextensible,
      oleautomation
    ]
    interface IActiveHome : IDispatch {
        [id(00000000), helpstring("method SendAction - use to send commands")]
        HRESULT SendAction(
                        [in] VARIANT bszAction,
                        [in, optional, defaultvalue(0)] VARIANT bstrParam,
                        [in, optional, defaultvalue(0)] VARIANT vReserved1,
                        [in, optional, defaultvalue(0)] VARIANT vReserved2,
                        [out, retval] VARIANT* vReturn);
        [id(0x00000001), propput]
        HRESULT OnRecvAction([in] IDispatch* rhs);
    };
};


I just need the SendAction command.

Here is my attempt at an Autohotkey script:

Code:


CoInitialize()

GUID4String(CLSID_ActivehomeScripting, "{001000AF-2DEF-0208-10B6-DC5BA692C858}")
GUID4String( IID__ActivehomeScripting, "{001000AF-3DEF-0910-10B6-DC5BA692C858}")

; CreateObject( "X10.ActiveHome" )
prs := CreateObject(CLSID_ActivehomeScripting, IID__ActivehomeScripting)

scommand := "sendplc"
scommand2 := "a3 off"
Ansi2Unicode(scommand, wcommand)
Ansi2Unicode(scommand2, wcommand2)


DllCall(VTable(prs, 0), "Uint", prs, "str", wcommand,"str", wcommand2)   ; Send Activehome command
 
CoUninitialize()

 


The code executes but nothing happens with the actual X10 device.

I am not sure if I am using the right vtable offset or passing the parameters correctly. They are defined as variants in the IDL file and I am passing them as strings.

They also provide a command line interface .exe file to turn modules on and off and those work when I execute them from autohotkey, but I would like this to work natively in autohotkey if possible.

Here is the scant documentation I have on the usage:


Code:
Using the Scripting Interface
In general, communication with the ActiveHome Scripting Interface is done through the scripting object, an ActiveX object that communicates with the general X10 device service.

Creating the Scripting Object

Transmitting Commands
The ActiveHome Scripting Object has one basic function for sending all X10 commands, both powerline and radio-frequency: SendAction. All of your transmit commands are done using this function, with parameters to specify the type of command, address, and additional values. All parameters are specified as string values.

Powerline Commands
Powerline commands are specified with the "sendplc" parameter, and take several different forms. Each requires that you specify an X10 address (A1-P16), plus additional command parameters structured as follows:

On: <X10 address> on
Off: <X10 address> off
Dim: <X10 address> dim <dim percentage (of 100%)>
Bright: <X10 address> bright <bright percentage (of 100%)>
All Lights On: <X10 address (must include Unit Code)> alllightson
All Units Offn: <X10 address (must include Unit Code)> allunitsoff
Extended Code Command: <X10 address> <command> <value> (command and value are specified in hex).
This list containts all of the powerline commands used by the Scripting Interface.

Example of complete powerline transmission command:

"sendplc", "a3 dim 75"

This would tell the interface to send address module A3, and then send a dim command of sufficient duration to dim the module 75% of full brightness.



Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 4th, 2010, 5:01 am 
Offline

Joined: November 16th, 2007, 8:31 am
Posts: 10
Location: California, USA
I know its a few years after the original post, but I am having the same problem. Anyone using AHK to control their X10 stuff?

_________________
Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened.

-Sir Winston Churchill


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, robotkoer, Yahoo [Bot] and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group