Jump to content

Hauppauge IR Config - Help Needed


Recommended Posts

Hello,

I am making an app to config my hauppauge remote,

I need to replace the text between ;APPS_S & ;APPS_E

I don't know how to put the update just a bit of the file, any help would be greatly welcomed.

Thanks,

Keith

; Happauge Hotkeys
#include <GUIConstants.au3>
#include <File.au3>
#include <GuiList.au3>
Dim $IR

#Region ### START Koda GUI section ### Form=c:\documents and settings\kog media\desktop\hauppauge.kxf
$Form1_1 = GUICreate("Hauppauge IR", 442, 585, 315, 94)
GUISetFont(9, 400, 0, "Verdana")
$Tab1 = GUICtrlCreateTab(8, 8, 425, 569)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$TabSheet1 = GUICtrlCreateTabItem("APPS")
$AppList = GUICtrlCreateList("", 16, 41, 409, 482, BitOR($WS_HSCROLL,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$AddName = GUICtrlCreateInput("", 16, 529, 289, 22)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$AddApps = GUICtrlCreateButton("Add", 304, 529, 41, 25, 0)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$Save = GUICtrlCreateButton("Save", 352, 528, 73, 25, 0)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$PROGRAM = GUICtrlCreateTabItem("PROGRAM")
GUICtrlSetState(-1,$GUI_SHOW)
$Edit = GUICtrlCreateEdit("", 16, 48, 401, 497)
GUICtrlSetData(-1, StringFormat("[Program Name]\r\nGRNPOWER=\r\nGO=\r\n\r\nTV=\r\nVIDEOS=\r\nMUSIC=\r\nPICTURES=\r\nGUIDE=\r\nRADIO=\r\nBACK=\r\nMENU=\r\n\r\nNAVDOWN=\r\nNAVLEFT=\r\nNAVRIGHT=\r\nNAVUP=\r\nOK=\r\n\r\nREC=\r\nPLAY=\r\nPAUSE=\r\nSTOP=\r\nREWIND=\r\nFASTFWD=\r\nSKIPREV=\r\nSKIPFWD=\r\n\r\n14=\r\n16=\r\n17=\r\nCHNLUP=\r\nCHNLDOWN=\r\nCHNLPREV=\r\n\r\n0=0\r\n1=1\r\n2=2\r\n3=3\r\n4=4\r\n5=5\r\n6=6\r\n7=7\r\n8=8\r\n9=9\r\nTEXT=\r\nSUBCC=\r\n\r\nRED=\r\nGREEN=\r\nYELLOW=\r\nBLUE="))
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
$AddProgram = GUICtrlCreateButton("Add", 344, 544, 73, 25, 0)
GUICtrlSetFont(-1, 9, 400, 0, "Verdana")
GUICtrlCreateTabItem("")
$contextmenu = GUICtrlCreateContextMenu($AppList)
$deleteitem     = GUICtrlCreateMenuitem ("Delete", $contextmenu)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; Buid AppList
$file = FileOpen("Irremote.txt", 0)
$IR = FileRead($file)
FileClose($file)
$appStartLine = StringInStr($IR,";APPS_S",0,-1)
$appEndLine = StringInStr($IR,";APPS_E",0,1)
$app_txt = StringMid ( $IR, $appStartLine+7 , ($appEndLine - $appStartLine)-7 )
$app_i = StringRegExpReplace($app_txt,@CRLF,",")
$app_i = StringSplit($app_i,",",1)
For $x = 0 To UBound($app_i)-1
_GUICtrlListAddItem ($AppList,$app_i[$x])
Next

;

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $AddApps
            _GUICtrlListAddItem ($AppList,GUICtrlRead($AddName))
        Case $Save
            WriteApps()
            ConsoleWrite($AppList)
        Case $deleteitem
            $sel_item = _GUICtrlListSelectedIndex( $AppList )
            If $sel_item = -1 Then
            MsgBox(0,"Error","No item selected.")
            Else
            $sel_text = _GUICtrlListGetText ( $AppList, $sel_item )
            #Region --- CodeWizard generated code Start ---
            ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=Question
            If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
            $iMsgBoxAnswer = MsgBox(35,"Delete","Delete "&$sel_text&"?")
            If $iMsgBoxAnswer = 6 Then _GUICtrlListDeleteItem ( $AppList, $sel_item )
            EndIf
EndSwitch
WEnd

;$IR = StringReplace($IR,$app_i,$app_o)
ConsoleWrite(@extended)


Func WriteApps()
    $file = FileOpen("Apps.txt", 2)
        If $file = -1 Then ; Check if file opened for writing OK
                MsgBox(0, "Error", "Unable to open file.")
                Exit
        EndIf
    FileWrite($file, ";APPS_S"&@CRLF)
    $c = _GUICtrlListCount ( $AppList )
    For $x = 0 To ($c-1)
    $tmp = _GUICtrlListGetText ( $AppList, $x )
    FileWrite($file, $tmp&@CRLF)
    Next
    FileWrite($file, ";APPS_E"&@CRLF)
    FileClose($file)
    MsgBox(0,"Saved","IR Updated")
EndFunc
[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...