Hmm, given the girder source the port should be pretty straightforward. I would modify Core.ahk like this. Note the call to CoInitialize and CoUninitialize. Hope it helps.
P.S. Of course, you'll need to remap RC codes if it works, I haven't touched them.
Code:
/* ----------------------------------------------------------------------------
Initialization, uninitialization, RC timer setup.
*/
; Initialize COM library
DllCall( "ole32\CoInitialize", "Uint", 0 )
; Load averapi.dll
HModule := DllCall( "LoadLibrary", "Str", "averapi.dll", "Cdecl" )
ResDllCall( "averapi.dll", "LoadLibrary" )
if ( HModule = 0 )
{
MsgBox, 16, , averapi.dll could not be loaded
ExitApp
}
; Initialize card
DllCall( "averapi\AVER_HWInit", "Cdecl" )
ResDllCall( "averapi.dll", "AVER_HWInit" )
; Set window title match mode
SetTitleMatchMode, 2
; Form a window group of system windows
GroupAdd, WG_System, Program Manager ahk_class Progman
GroupAdd, WG_System, ahk_class WorkerW
GroupAdd, WG_System, ahk_class Shell_TrayWnd
; Set the subroutine to run on exit
OnExit, UninitAndExit
; Calculate number of signals to skip to ensure repeat delay/interval
NumSignalsRepeatDelay := Round( RCRepeatDelay/RCInterval ) - 1
NumSignalsRepeatInterval := Round( RCRepeatInterval/RCInterval ) - 1
; Initialize RC mode
RCMode = RCM_Wait
CntSignals = 0
; Initialize confirm mode
ConfirmMode = CM_None
; Set timer to check RC state
SetTimer, TimerRC, %RCInterval%
return
; --- The end of auto-execute section of the script ---
; Uninitialize the card on exit
UninitAndExit:
; Uninitialize COM library
DllCall( "ole32\CoUninitialize" )
ExitApp
/* ----------------------------------------------------------------------------
Timer to check the state of the RC. RC key repeat delay and interval are
controlled here.
*/
TimerRC:
Res := DllCall( "averapi\GetRemoteData", "Cdecl Int" )
ResDllCall( "averapi.dll", "GetRemoteData" )
; No button pressed
if ( !Res&2 )
{
RCMode = RCM_Wait
CntSignals = 0
return
}
if ( ( ( RCMode = "RCM_RepeatDelay" ) && ( CntSignals < NumSignalsRepeatDelay ) )
|| ( ( RCMode = "RCM_RepeatInterval" ) && ( CntSignals < NumSignalsRepeatInterval ) ) )
{
CntSignals++
return
}
if ( Res = 0 )
{
RCKey = RCK_0
}
else if ( Res = 1 )
{
RCKey = RCK_1
}
else if ( Res = 2 )
{
RCKey = RCK_2
}
else if ( Res = 3 )
{
RCKey = RCK_3
}
else if ( Res = 4 )
{
RCKey = RCK_4
}
else if ( Res = 5 )
{
RCKey = RCK_5
}
else if ( Res = 6 )
{
RCKey = RCK_6
}
else if ( Res = 7 )
{
RCKey = RCK_7
}
else if ( Res = 8 )
{
RCKey = RCK_8
}
else if ( Res = 9 )
{
RCKey = RCK_9
}
else if ( Res = 10 )
{
RCKey = RCK_Recall
}
else if ( Res = 11 )
{
RCKey = RCK_Up
}
else if ( Res = 12 )
{
RCKey = RCK_Right
}
else if ( Res = 13 )
{
RCKey = RCK_Mode
}
else if ( Res = 14 )
{
RCKey = RCK_Sleep
}
else if ( Res = 15 )
{
RCKey = RCK_Audio
}
else if ( Res = 16 )
{
RCKey = RCK_Info
}
else if ( Res = 17 )
{
RCKey = RCK_TvAv
}
else if ( Res = 18 )
{
RCKey = RCK_Power
}
else if ( Res = 19 )
{
RCKey = RCK_Mute
}
else if ( Res = 20 )
{
RCKey = RCK_Menu
}
else if ( Res = 21 )
{
RCKey = RCK_Down
}
else if ( Res = 22 )
{
RCKey = RCK_Ok
}
else if ( Res = 23 )
{
RCKey = RCK_Teletext
}
else if ( Res = 24 )
{
RCKey = RCK_Left
}
else if ( Res = 26 )
{
RCKey = RCK_ChanUp
}
else if ( Res = 27 )
{
RCKey = RCK_VolUp
}
else if ( Res = 28 )
{
RCKey = RCK_Function
}
else if ( Res = 30 )
{
RCKey = RCK_ChanDown
}
else if ( Res = 31 )
{
RCKey = RCK_VolDown
}
if RCMode = RCM_Wait
{
RCMode = RCM_RepeatDelay
}
else if RCMode = RCM_RepeatDelay
{
RCMode = RCM_RepeatInterval
}
CntSignals = 0
if ( ( RCKey = RCKClose ) && ( RCMode = "RCM_RepeatInterval" ) )
return
Goto, AppManager
/* ----------------------------------------------------------------------------
Application manager - manages remotely controlled applications.
Firstly, the special RC keys for closing applications,
shutdown, etc. are processed. Secondly, the special RC keys each
controlling one application are processed. Thirdly, any other RC keys
are passed to the handler of the active application.
*/
AppManager:
; Find managed application (RCKey = key controlling one of the applications)
AppManaged := ""
Loop
{
App := App%A_Index%
if ( App = "" )
{
break
}
if ( RCKey = RCKApp%A_Index% )
{
AppManaged := App
PathAppManaged := PathApp%A_Index%
if ( PathAppManaged = "" )
{
MsgBox, 16, , Path not specified for %App%
ExitApp
}
WinTitleAppManaged := WinTitleApp%A_Index%
OwnerAppManaged := OwnerApp%A_Index%
}
}
; Find active application
AppActive := ""
Loop
{
App := App%A_Index%
if ( App = "" )
{
break
}
if ( WinTitleApp%A_Index% = "" )
{
continue
}
IfWinActive, % WinTitleApp%A_Index%
{
AppActive := App
HKCloseAppActive := HKCloseApp%A_Index%
break
}
}
; RC key for closing applications is pressed
if ( RCKey = RCKClose )
{
if ( AppActive != "" )
{
if ( HKCloseAppActive != "" )
{
Send, %HKCloseAppActive%
}
else
{
WinClose, A
}
}
else IfWinNotActive, ahk_group WG_System
{
WinClose, A
}
else
{
; No active windows, confirm that the user wants to shutdown the computer
ConfirmMode = CM_Shutdown
OSDText( TextShutdown, TextColorShutdown, FontNameShutdown, FontSizeShutdown, DelayShutdown )
}
return
}
; If confirmed shutdown the computer
if ( ( ConfirmMode = "CM_Shutdown" ) && ( RCKey = RCKConfirm ) )
{
Shutdown, 8
return
}
; RC key to show clock is pressed
if ( RCKey = RCKClock )
{
Gosub, Wake
TextClock = %A_Hour%:%A_Min%
OSDText( TextClock, TextColorClock, FontNameClock, FontSizeClock, DelayClock )
return
}
; A special RC key managing one application is pressed, start/activate the
; application
if ( AppManaged != "" )
{
if ( WinTitleAppManaged = "" )
{
Run, %PathAppManaged%, , UseErrorLevel
ResRun( PathAppManaged )
if ( OwnerAppManaged != "" )
{
Index := AppIndexByName( OwnerAppManaged )
WinWait, % WinTitleApp%Index%
WinActivate
}
}
else IfWinNotExist, %WinTitleAppManaged%
{
Run, %PathAppManaged%, , UseErrorLevel
ResRun( PathAppManaged )
}
else IfWinNotActive
{
WinActivate
}
return
}
; Pass RC key to the handler of the active application
if ( AppActive != "" )
{
LabelApp = %AppActive%
if ( !IsLabel( LabelApp ) )
{
MsgBox, 16, , No handler for %AppActive% application (the handler must be called %LabelApp%)
ExitApp
}
Goto, %LabelApp%
}
return
/* ----------------------------------------------------------------------------
OSD text.
*/
; Show OSD text in the center of the screen
OSDText( Text, TextColor, FontName, FontSize, Delay )
{
global TxtOSD
Gui, Destroy
Gui, +AlwaysOnTop +LastFound +Owner
WinColor = White
Gui, Color, %WinColor%
WinSet, TransColor, %WinColor%
Gui, -Caption
X := 0.05*A_ScreenWidth
W := 0.90*A_ScreenWidth
Gui, Font, s%FontSize%, %FontName%
Gui, Add, Text, x%X% w%W% Center c%TextColor% vTxtOSD, %Text%
Gui, Show, NoActivate
SetTimer, RemoveOSD, %Delay%
return
}
; Remove OSD
RemoveOSD:
SetTimer, RemoveOSD, Off
Gui, Destroy
; Set confirm mode to none in case OSD was used to confirm something
ConfirmMode = CM_None
return
/* ----------------------------------------------------------------------------
Auxilary routines.
*/
; Test the result of DllCall
ResDllCall( DllName, FuncName )
{
if ( ErrorLevel = 0 )
return
if ( ErrorLevel = -1 )
{
MsgBox, 16, , DLL name or function name specified incorrectly when calling function %FuncName% in DLL %DllName%
ExitApp
}
if ( ErrorLevel = -2 )
{
MsgBox, 16, , Return type or argument type specified incorrectly when calling function %FuncName% in DLL %DllName%
ExitApp
}
if ( ErrorLevel = -3 )
{
MsgBox, 16, , %DllName% could not be accessed
ExitApp
}
if ( ErrorLevel = -4 )
{
MsgBox, 16, , Function %FuncName% not found inside %DllName%
ExitApp
}
StringLeft, c, ErrorLevel, 1
StringTrimLeft, n, ErrorLevel, 1
if ( c = "A" )
{
MsgBox, 16, , Size of argument list incorrect by %n% bytes (or cdecl required) when calling function %FuncName% in DLL %DllName%
ExitApp
}
if ( ErrorLevel > 0 )
{
MsgBox, 16, , Fatal exception %ErrorLevel% when calling function %FuncName% in DLL %DllName%
ExitApp
}
return
}
; Test the result of Run/RunWait
ResRun( Path )
{
if ErrorLevel = ERROR
{
MsgBox, 16, , Failed to launch %Path%
ExitApp
}
}
; Get application index by its name
AppIndexByName( App )
{
Loop
{
if ( App%A_Index% = "" )
{
break
}
if ( App = App%A_Index% )
{
return A_Index
}
}
return RES_NotFound
}
; Wake the computer
Wake:
Send, ^#!{F12}
return