;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template AutoHotkey script.
;
;Global Variables
;--------------------------------------------------------------------------------------------
HomePath=AutohotkeyRemoteControl.dll
MediaPortalPath=C:\Archivos de programa\MediaPortal\MediaPortal.exe
DVD=false
MousePID=0
;Load the dll
;--------------------------------------------------------------------------------------------
hModule := DllCall("LoadLibrary", "str", HomePath) ; Avoids the need for DllCall() in
OnMessage(0x00FF, "InputMsg")
DetectHiddenWindows, on
;SetTimer,UPDATEDSCRIPT,1000
;Register device HID
;--------------------------------------------------------------------------------------------
EditUsage = 136
EditUsagePage = 65468
Gui, Show, x0 y0 h0 w0, Autohotkey HID-Support
HWND := WinExist("Autohotkey HID-Support")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox RegisterDevice Error. 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%)
RawData = 1
nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT", &RawData, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox GetWM_INPUTHIDData Inicialiting Error. Errorcode: %errorlevel%
goto cleanup
}
loop, %DataSize%
{
Zahl := NumGet(RawData, a_index-1,"UChar")
Zahl := Dez2Hex(Zahl)
Vals = %Vals%%Zahl%
}
;Keyboard codes (Multimedia Wireless Keyboard)
ifequal, Vals, 02010000, gosub KbMyTV
ifequal, Vals, 02020000, gosub KbMyMusic
ifequal, Vals, 02080000, gosub KbMyPictures
ifequal, Vals, 02100000, gosub KbMyVideo
ifequal, Vals, 01010000, gosub KbInternet
ifequal, Vals, 01020000, gosub KbMail
ifequal, Vals, 01000400, gosub KbPrevious
ifequal, Vals, 01000008, gosub KbPlay
ifequal, Vals, 01000010, gosub KbPause
ifequal, Vals, 01000200, gosub KbStop
ifequal, Vals, 01000800, gosub KbNext
ifequal, Vals, 01002000, gosub KbVolumeMin
ifequal, Vals, 01001000, gosub KbVolumePlus
ifequal, Vals, 01004000, gosub KbMute
;Remote codes (Cyberlink Remote control)
ifequal, Vals, 040100, gosub RmHomePg
ifequal, Vals, 048000, gosub RmRed
ifequal, Vals, 040800, gosub RmGreen
ifequal, Vals, 041000, gosub RmYellow
ifequal, Vals, 042000, gosub RmBlue
ifequal, Vals, 040200, gosub RmLiveTV
ifequal, Vals, 03800000, gosub RmRecord
ifequal, Vals, 03040000, gosub RmRadio
ifequal, Vals, 040010, gosub RmSAP
ifequal, Vals, 040020, gosub RmTeletxt
ifequal, Vals, 040040, gosub RmLastCH
ifequal, Vals, 040008, gosub RmSubtitle
ifequal, Vals, 040002, gosub RmLanguage
ifequal, Vals, 040001, gosub RmAngle
ifequal, Vals, 03000400, gosub RmBack
ifequal, Vals, 03000002, gosub RmInfoEPG
ifequal, Vals, 040004, gosub RmDVDMenu
ifequal, Vals, 03200000, gosub RmVolumePlus
ifequal, Vals, 03400000, gosub RmVolumenMin
ifequal, Vals, 03100000, gosub RmMute
}
;Keyboard's Multimedia Button's Subrutines
;--------------------------------------------------------------------------------------------
KbMyTV:
SendMediaPortalKey("^!L")
return
KbMyMusic:
SendMediaPortalKey("^!G")
return
KbMyPictures:
SendMediaPortalKey("^!Y")
return
KbMyVideo:
SendMediaPortalKey("^!B")
return
KbInternet:
return
KbMail:
return
KbPrevious:
return
KbPlay:
return
KbPause:
return
KbStop:
return
KbNext:
return
KbVolumeMin:
return
KbVolumePlus:
return
KbMute:
return
;Cyberlink's Remote Control Buttons
;--------------------------------------------------------------------------------------------
RmHomePg:
IfWinExist, MediaPortal
{
;SendMediaPortalKey("^!H")
Send, !{F4}
Sleep, 1000
IfWinNotExist, MediaPortal
{
;Enable Windows Mouse Emulation
Run Mouse.exe, , , MousePID
}
}
else
{
if MousePID > 0
{
;Close Windows Mouse Emulation
Process, Close, %MousePID%
}
Run %MediaPortalPath%
}
return
RmRed:
Run Eject.exe
DVD:=!DVD
if(DVD)
{
SendMediaPortalKey("Send, ^!R")
}
return
RmGreen:
SendMediaPortalKey("^!G")
return
RmYellow:
SendMediaPortalKey("^!Y")
return
RmBlue:
SendMediaPortalKey("^!B")
return
RmLiveTV:
SendMediaPortalKey("^!L")
return
RmRecord:
SendMediaPortalKey("^!E")
return
RmRadio:
SendMediaPortalKey("^!A")
return
RmSAP:
SendMediaPortalKey("{F3}")
return
RmTeletxt:
SendMediaPortalKey("^!T")
return
RmLastCH:
SendMediaPortalKey("^!C")
return
RmSubtitle:
SendMediaPortalKey("l")
return
RmLanguage:
SendMediaPortalKey("^!U")
return
RmAngle:
SendMediaPortalKey("^!N")
return
RmBack:
return
RmInfoEPG:
SendMediaPortalKey("^!P")
return
RmDVDMenu:
SendMediaPortalKey("d")
return
RmVolumePlus:
return
RmVolumenMin:
return
RmMute:
return
;--------------------------------------------------------------------------------------------
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
;--------------------------------------------------------------------------------------------
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
}
;--------------------------------------------------------------------------------------------
SendMediaPortalKey(Key)
{
IfWinExist , MediaPortal
{
;Send Key to MediaPortal
Winactivate, MediaPortal
Send, %key%
}
}
return
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<mappings version="3">
<remote family="Cyberlink Remote Control">
<button name="Home" code="111072">
<action layer="0" condition="WINDOW" conproperty="0" command="POWER" cmdproperty="EXIT" sound="click.wav" />
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="0" sound="back.wav" />
</button>
<button name="Red" code="111082">
<action layer="0" condition="*" conproperty="" command="WINDOW" cmdproperty="3001" sound="click.wav" />
</button>
<button name="Green" code="111071">
<action layer="0" condition="*" conproperty="" command="WINDOW" cmdproperty="501" sound="click.wav" />
</button>
<button name="Yellow" code="111089">
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="2" sound="click.wav" />
</button>
<button name="Blue" code="111066">
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="6" sound="click.wav" />
</button>
<button name="LiveTV" code="111076">
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="1" sound="click.wav" />
</button>
<button name="Record" code="111069" />
<button name="Radio" code="111065">
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="30" sound="click.wav" />
</button>
<button name="SAP" code="111083" />
<button name="Teletext" code="111084" />
<button name="LastCH" code="111067">
<action layer="0" condition="WINDOW" conproperty="602" command="ACTION" cmdproperty="111" sound="click.wav" />
</button>
<button name="Subtitle" code="111083" />
<button name="Language" code="111085" />
<button name="Angle" code="111078" />
<button name="EPG" code="111080">
<action layer="0" condition="*" conproperty="-1" command="WINDOW" cmdproperty="600" sound="click.wav" />
</button>
<button name="DVDMenu" code="111068">
<action layer="0" condition="*" conproperty="" command="WINDOW" cmdproperty="3001" sound="click.wav" />
</button>
</remote>
</mappings>
;---------------------------------------------------------------------------
;Simulates mouse moves with remote control.
*up::
IfWinNotExist , MediaPortal
{
MouseMove, 0, -10, 0, R
}
return
*Down::
IfWinNotExist , MediaPortal
{
MouseMove, 0, 10, 0, R
}
return
*Left::
IfWinNotExist , MediaPortal
{
MouseMove, -10, 0, 0, R
}
return
*Right::
IfWinNotExist , MediaPortal
{
MouseMove, 10, 0, 0, R
}
return
*Enter::
IfWinNotExist , MediaPortal
{
Click Left
}
return
*Delete::
IfWinNotExist , MediaPortal
{
Click Right
}
return