I already discovered Autohotkey a while ago, then Micha 's DLL, and after playing around with it, I can reprogram almost any button to the function of choice.
Finally, I am able to use the coloured buttons for something useful, or use the remote when navigating in Media Player Classic.
Here is the script I am currently using.
I still want to improve it, especially for Media Player Classic, when I
have some time, I want to get the FFWD and REWD buttons to act more
like they do in MediaCenter.
Got some help from Micha, he made the system with the INI file.
There are 3 parts to using it :
You 'll need to download the DLL from
http://www.autohotkey.net/~Micha/HIDsupport/Autohotkey.html
Now you need to save the lines below as an AHK file (for example : myhotkeys.ahk).
MYHOTKEYS.AHK :
----------------------
;This is the .AHK file, you can name it as you like.
;You now still need the .INI file, in which you will put most commands
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template AutoHotkey script.
;
; PLEASE DO NOT DELETE THE FOLLOWING LINES
;Path to AutohotkeyRemoteControl.dll
HomePath="C:\Program Files\Autohotkey\AutohotkeyRemoteControl.dll
"
;HomePath=release\AutohotkeyRemoteControl.dll
;Load the dll
hModule := DllCall("LoadLibrary", "str", HomePath) ; Avoids the need for DllCall() in
OnMessage(0x00FF, "InputMsg")
DetectHiddenWindows, on
;SetTimer,UPDATEDSCRIPT,1000
ReadIni()
;Register my device
EditUsage = 136
EditUsagePage = 65468
Gui, Show, x0 y0 h0 w0, Autohotkey HID-Support
;HWND := WinActive("F:\myprg\Win\Autohotkeyremote\Autohotke yRemoteControl\RemoteControl.ahk")
HWND := WinExist("Autohotkey HID-Support")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox RegisterDevice fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;Register another device
EditUsage = 1
EditUsagePage = 12
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
Winhide, Autohotkey HID-Support
return
InputMsg(wParam, lParam, msg, hwnd)
{
DataSize = 5000
VarSetCapacity(RawData, %DataSize%)
;MsgBox eingetroffen %wParam% %lParam% %msg% %HWND%
;Write something into the var, so the script won't be aborted :
;(g_script.ScriptError("This DllCall requires a prior VarSetCapacity. The program is now unstable and will exit.")

RawData = 1
nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDDat a", UINT,
wParam, UINT, lParam, "UINT *" , DataSize, "UINT", &RawData, "Cdecl
UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
loop, %DataSize%
{
Zeichen := ExtractInteger(RawData, A_Index, false, 1)
ifless, Zeichen, 9
{
Zeichen= 0%Zeichen%
}
Vals = %Vals%%Zeichen%
}
;The var Vals contains the values of your remote control.
;In the next block you can jump to the function which sends keys to your app or is doing what you want
;if the desired message arrives. You can name the labels as you want. I used the chars of my remote ctrl
ifequal, vals, 1760000, gosub Playbutton
ifequal, vals, 1770000, gosub Pausebutton
ifequal, vals, 1800000, gosub Rewindbutton
ifequal, vals, 1790000, gosub Fastforwardbutton
ifequal, vals, 1820000, gosub Chapterbackbutton
ifequal, vals, 1810000, gosub Chapterforwardbutton
ifequal, vals, 360200, gosub Backbutton
ifequal, vals, 90200, gosub Infobutton
ifequal, Vals, 9100, gosub Redbutton
ifequal, Vals, 9200, gosub Greenbutton
ifequal, Vals, 9300, gosub Yellowbutton
ifequal, Vals, 9400, gosub Bluebutton
}
return
Playbutton:
Dokey("Play")
return
Pausebutton:
Dokey("Pause")
return
Rewindbutton:
Dokey("Rewind")
return
Fastforwardbutton:
Send a
return
Chapterbackbutton:
Dokey("Chapterback")
return
Chapterforwardbutton:
Dokey("Chapterfwd")
return
Backbutton:
Send ^q
WinGetPos, X,Y,W,H,Open
Coordmode Mouse,Screen
Click 640,380
return
Infobutton:
SetKeyDelay,100
DoKey("Info")
return
Redbutton:
DoKey("Red")
return
Greenbutton:
DoKey("Green")
return
Yellowbutton:
Dokey("Yellow")
return
Bluebutton:
Dokey("Blue")
return
#IfWinActive ahk_class MediaPlayerClassicW
à::
Send ^{NumPad4}
return
&::
Send ^{NumPad8}
return
é::
Send {NumPad8}
return
'::
Send {NumPad4}
return
(::
Send {NumPad5}
return
§::
Send {NumPad6}
return
è::
Send {NumPad1}
return
!::
Send {NumPad2}
return
8::
Send ^{NumPad2}
return
"::
Send {NumPad9}
return
3::
Send ^{NumPad6}
return
#IfWinActive
#IfWinActive ahk_class eHome Render Window
8::
;This actually refers to the asterisk key on the remote
;This button is now remapped to Alt+Enter, which toggles between fullscreen mode and windowed mode
Send !{ENTER}
return
3::
;This actually refers to the # key on the remote
;This button is now remapped to Alt+F4, which closes Mediacenter
Send!{F4}
return
#IfWinActive
cleanup:
DllCall("FreeLibrary", "UInt", hModule) ; It is best to unload the DLL after using it (or before the script exits).
ExitApp
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
Reload
}
Return
;Search the array for the remotekey
DoKey(Remotekey)
{
global
;Get active Title
WinGetClass,ActClass,A
;WinGetActiveTitle, ActTitle
;msgbox %ActTitle%
loop, %KeyArray0%
{
KeyofArray := KeyArray%a_index%
;if key is the wrong key, try the next entry
if KeyofArray != %Remotekey%
continue
TitleOfArray := AppArray%a_index%
IfnotInString, ActClass, %TitleOfArray%
continue
;We have found the correct key and the correct application. Send the Key
Key2Send := SendArray%a_index%
;msgbox Send "%Key2Send%"
Send %Key2Send%
return
}
}
SendDVDKey(Key)
{
IfWinNotExist , InterVideo WinDVD 7
{
return
}
Winactivate, InterVideo WinDVD 7
Send, %Key%
}
Dez2Hex(Number)
{
format = %A_FormatInteger% ; save original integer format
SetFormat Integer, Hex ; for converting bytes to hex
Number += 0
SetFormat Integer, %format% ; restore original format
StringTrimLeft, Number, Number, 2
Stringlen := StrLen(Number)
if Stringlen < 2
Number = 0%Number%
return Number
}
ReadIni()
{
global
IfNotExist, .\myremotekeys.ini
{
MsgBox, Inifile myremotekeys.ini not found in current folder
ExitApp , 2
}
IniRead, Counter, .\filiep.ini, RemoteControl, Entrycount
KeyArray0 := Counter
AppArray0 := Counter
SendArray0 := Counter
loop, %Counter%
{
IniRead, IniLine, .\filiep.ini, RemoteControl, %a_index%
StringSplit, OutputArray, IniLine , `;
KeyArray%a_index% := OutputArray1
AppArray%a_index% := OutputArray2
SendArray%a_index% := OutputArray3
}
}
ExtractInteger(ByRef pSource, pOffset = 0, ****igned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
SourceAddress := &pSource + pOffset ; Get address and apply the caller's offset.
result := 0 ; Init prior to accumulation in the loop.
Loop %pSize% ; For each byte in the integer:
{
result := result | (*SourceAddress << 8 * (A_Index - 1)) ; Build the integer from its bytes.
SourceAddress += 1 ; Move on to the next byte.
}
if (!****igned OR pSize > 4 OR result < 0x80000000)
return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
return
--------------------------------------
End of the AHK file.
Now you still need an INI file for most commands.
I use the INI file for almost anything.
However, I have some problems with keys that I cannot read from the utility, such as the ENTER key.
As soon as I press it, ENTER is passed on, instead of showing me the numbers that are sent by the remote.
Here is the INI file I 'm currently using : (referred to as myhotkeys.ini in the AHK file)
--------------------------------------------------------------------------------------------------
[RemoteControl]
Entrycount=15
1=Red;eHome Render Window;^+z
2=Green;eHome Render Window;^+c
3=Yellow;eHome Render Window;^a
4=Blue;eHome Render Window;^o{Up}{Up}{Enter}
5=Red;MediaPlayerClassicW;w
6=Green;MediaPlayerClassicW;{ENTER} !v {UP 3} {RIGHT} {UP 5} {ENTER} {ENTER}
7=Yellow;MediaPlayerClassicW;{ENTER} !v {UP 3} {RIGHT} {UP 4} {ENTER} {ENTER}
8=Blue;MediaPlayerClassicW;{ENTER} !v {UP 3} {RIGHT} {UP 3} {ENTER} {ENTER}
9=Play;MediaPlayerClassicW;{VKFA}
10=Pause;MediaPlayerClassicW;{SPACE}
11=Rewind;MediaPlayerClassicW;!^+{F1}
12=FFwd;MediaPlayerClassicW;!^+{F2}
13=Chapterback;MediaPlayerClassicW;^{LEFT}
14=Chapterfwd;MediaPlayerClassicW;^{RIGHT}
15=Info;#32770;{Tab}
Now you still have to remap some keys in Media Player Classic so they will correspond with the keys used in the INI file.
If you do that you should get most keys as I used them.
For example, I use the number keys in Media Player Classic to zoom and
stretch the image when necessary, and the coloured buttons for the
different zoom modes.
PAL territory, using analogue cable Hauppauge PVR-350 and Hauppauge PVR-250, living in Belgium, Europe
http://www.extrabuttons.net