Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

DllCall-Support for X10 remote controls (i.e.Notebooks)


  • Please log in to reply
21 replies to this topic
Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
my Aldi Medion Notebook MD96500 has a X10.com remote control, which is not recognized as HID-USB-Device nor by winlirc.
After a long research I have found the X10 SDK to support the remotecontrol in your own applications.
Time to write a DLL to use with AHK for remote controlling apps with my remote control.

In the function DoAction you receive the Key and the state (pressed/released). Thus you can expand the script very easy.
if Command = "louder" then rise the volume
if Command = "2" switch to channel 2 in your TV-APP
...
...

If you have problems please Mail me or post in that thread

The DLL: https://ahknet.autoh...eyRemoteX10.dll
The script: https://ahknet.autoh...moteControl.ahk

If you have problems to get the dll working, you will need new MS-Dlls (mfc80.dll, msvcr80.dll) please download the 2 Archives, unpack them and start the vcredist_x86.exe. It will install the needed dlls
https://ahknet.autoh...6.sfx.part1.exe
https://ahknet.autoh...6.sfx.part2.rar
There's a uploadlimit of 2 MB, thus I had to split the Archives

Ciao
Micha

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Nice looking package. Now, when anyone searches for X10 or similar, they will find a ready-made solution thanks to you :)

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Updated links. Add mfc-dlls in a package

Muffy
  • Guests
  • Last active:
  • Joined: --
:D Sounds fine, but doesn't work with my Medion X10 on WinXP :cry:

The remote control is working, as i can see with a test program, but if i run your script no tooltip is displayed. Any ideas?

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi Muffy,
are there any error-messages or does just nothing happens ?

What test program do you have used? Perhaps I can try, if it works with my remote control, just to see that it should work.

Ciao
Micha

guest166
  • Guests
  • Last active:
  • Joined: --
I have a Niveus Media USB remote (x10 clone), will this solution work for me?
Any chance you could tell me step by step (read: for someone with no clue) how to get this working? :oops:

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
I can't tell you if it will work, but you can have a try.

Download the dll and the script from the first post.
Download this ZIP: https://ahknet.autoh...ha/mfc_dlls.zip

Put all files to the same directory and start the script.
If you press a key on the remotecontrol a tooltip should appear.

If that works, you can do everything what's possible with ahk by pressing a button on the remote control.

Ciao
Micha

Adj
  • Members
  • 11 posts
  • Last active: Apr 18 2010 01:35 AM
  • Joined: 23 Dec 2007
Hey Micha,
This sounds great! i'd love this if i could get it to work.

However i failed to get it working. I do not know what the problem is. I got a working (works with girder, which i do not like so much) X10 Remote Control with my Aldi Medion desktop.

I've downloaded the files, extracted them and put them in one directory. No errors occur when i start the script, but nothing happens when i press a button. I've checked the Key history and script info which is empty.

I'm not so known with DLL's so i might do something wrong there..

Could you please give me some direction to a solution please?

Thanks in advance!

Adj

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi Adj,
please try dependency walker. A short description is here

Jeggo
  • Guests
  • Last active:
  • Joined: --
Hello Micha,

I have the same problem with my X10 Medion remote clone.
As proposed I did a Dependency Walker run. As far as understand the output everything is OK.

I believe, that the AutohotkeyRemoteX10.dll is not processing the X10 commands.

I just mailed you the log file.

CU

Jens

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
I've recompiled the dll.
Please download the new vcredist from microsoft
http://www.microsoft...&displaylang=en
The new Dll:
https://ahknet.autoh...eyRemoteX10.zip
and the X10 SDK. The dll should work without, but I have installed Server2003 and the notebook drivers for my remote control doesn't install with that os. I wasn't able to run the dll without the sdk, but you can try it without the sdk first.
http://www.x10.com/activehomepro/sdk/
My remote is working without further dlls on my new installed notebook
Please post if you have any further problems
Ciao
Micha

Jeggo
  • Guests
  • Last active:
  • Joined: --
Hi Micha,

I tried the things you mentioned. But it did not work :-(
Still no reaction of the script, when I press a key on the remote.

Is it possible to get the sourcecode for your DLL?
Maybe I can findout what the problem is.

CU

Jens

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
are you sure that you have installed the correct driver, the batteries of the remote control are not empty and the remote control is working at all?
here is the code:
// AutohotkeyRemoteX10.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "ahscript.h"
#include ".\AutohotkeyRemoteX10.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
//helper function for single byte char to unicode translatation

UINT Initialize(DWORD hWnd)
{
    fEndThread = FALSE;
    pWnd = CWnd::FromHandle((HWND)hWnd);
    AfxBeginThread(RunThread, NULL);

    return NULL;
}

void UnInitialize(void)
{
    fEndThread = TRUE;
    //EVENT Abwarten
    pEventsReporter->Release();
    pEventsReporter = NULL;

    pActiveHome->Release();
    pActiveHome = NULL;
   
}


UINT RunThread (LPVOID pParam )
{	
    int nReturn = 0;
    HRESULT hr;
    hr = CoInitialize(NULL);

    hr = CoCreateInstance( CLSID_ActiveHome, NULL, CLSCTX_INPROC|CLSCTX_LOCAL_SERVER, IID_IActiveHome, (LPVOID *) &pActiveHome );
    if (SUCCEEDED(hr)) 
    {
        VARIANT varReseved1;
        VariantInit(&varReseved1);
        VARIANT varReseved2;
        VariantInit(&varReseved2);

        VARIANT varAction;
        VariantInit(&varAction);
        varAction.vt = VT_BSTR;
        wchar_t wchTemp[10];

         //setup events reporting for _IActiveHomeEvents
        pEventsReporter = new CEventsReporter;
        if (pEventsReporter) 
	  {
            pEventsReporter->AddRef();

            //hook up pEventsReporter to get calls
            pEventsReporter->AdviseActiveHome(pActiveHome);
		MSG msg;
		HWND hwnd;
		HWND hwndParent;
		while (GetMessage( &msg, NULL, 0, 0 ) > 0) 
		{
		    if (msg.hwnd && (((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST)) || ((msg.message >= WM_IME_SETCONTEXT) && (msg.message <= WM_IME_KEYUP))) ) 
		    {
			  hwnd = msg.hwnd;
			  for (;(hwndParent = GetParent( hwnd )) && IsChild( hwndParent, hwnd ); hwnd = hwndParent) {}
			  if (! ::GetWindowLong( hwnd, DWL_DLGPROC ) || !IsDialogMessage( hwnd, &msg )) 
			  {
				TranslateMessage( &msg );
				DispatchMessage( &msg );
			  }
		    }
		    else 
		    {
			  TranslateMessage( &msg );
			  DispatchMessage( &msg );
		    }
		}            
	  }    
    } 
    else 
    {
        printf("error: CoCreateInstance hr=0x%x", (unsigned int)hr);
    }
    return TRUE;
}


Jeggo
  • Guests
  • Last active:
  • Joined: --
Hi Micha,

now it is working :D
It looks like a reboot was missing. Next weekend I will try to integrate it in my AHK-script.
I will tryout what drivers and DLLs where actual needed to run the X10 remote.

CU

Jens

Barney9
  • Members
  • 62 posts
  • Last active: Oct 09 2015 09:13 AM
  • Joined: 02 Mar 2007
I was disappointed when I realized that my remote is no HID device. I bought it last week just for AHK. Finding your script is a great relief. It is actually cooler because I don't have to care about the HID Script.

Would it be possible to use COM with AHK_L so that we wouldn't need your DLLs?