#include #include #include #include #include #Include #include #Include #Include #include #cs Title: Rapid Menu Writer Filename: Rapid Menu Writer.au3 Description: A wizard for creating very simple DVD menus. Author: seangriffin Version: V1.3 Last Update: 21/09/09 Requirements: AutoIt3 3.2 or higher, Windows 95 / 98 / ME / NT4 / 2000 / XP (32-bit) / 2003 (32-bit) / Vista (32-bit) / 2008 (32-bit), PgcEdit versions 8.5, 8.6 or 9.2 (unregistered), DVDStyler v1.7.2 (or similar version) Changelog: ---------21/09/09---------- v1.3 Fixed the Back buttons (broken from v1.1). Fixed the Finished message at the end to be shown (was previously hidden). Changed the DVDStyler Preview message to include Yes and No buttons to continue or go back. Added an error message when the DVD player doesn't exist when Play DVD is clicked. Updated the error messages for missing PgcEdit and DVDStyler executables to include the path. Added a "Restore Defaults" button to the Options GUI. Updated the help file. Added verbose logging to the "Assign commands to the menu buttons" section. Changed the style of menu buttons to use frames with borders. Changed the default menu colour scheme to be blue buttons with white text and borders. ---------18/09/09---------- v1.2 Changed the size of menus to fit within the DVDStyler safe TV area. Changed Preview window to playback at normal speed (improving performance). Changed Preview window behaviour to give control back to the Main GUI once started. Fixed a bug where the OK button for "Select the IFO file with the menu to import" and "Browse for Folder" is not selected first time. ---------14/09/09---------- v1.1 Back button is currently broken. Changed previews to move the Main GUI side-by-side with the Preview window. Fixed the bad check for the "Find BOVs (Buttons Over Video..." popup following the "PgcEdit: Save DVD" popup. Titles menu checkbox re-enabled - titleset only menus now working. ---------13/09/09---------- v1.0 Titles menu checkbox is forced on (checked) at the moment. Changed the default paths of PgcEdit, DVDStyler & DVD Player to use the current Program Files path. Removed the storage and retrieval of button labels. Updated the system requirements to include 32 bit Windows. Added keyboard mnemonics (shortcuts) to all buttons and menu items. Fixed the Next button. It was missing the ">" sign. Added a Tool menu item to start PgcEdit. Added a Tool menu item to start DVDStyler. Updated tooltips to warn user about using the mouse and keyboard. Updated help. Fixed paths with spaces issue. Added a donation button to the About GUI and last page of the Main GUI. Changed the default DVD player to Media Player Classic Home Cinema. Added menu titles (headings on each menu screen). Added video preview button. Added title menus (major update). ---------24/08/09---------- v0.5 Added a help file and help menu item. Added more logging commands. Moved the "Open Log" button to the "Tools" menu. Fixed the Back button to be disabled on the first wizard page. ---------18/08/09---------- v0.4 Added a heading picture to Main and About GUIs. Added the ability to work with DVDs that already have a menu. Added an "Open PgcEdit" button to view the DVD if PgcEdit afterwards. Added a NSIS installer and uninstaller. ---------17/08/09---------- v0.3 Changed the Options and About GUI to be modal. Changed the path of the DVD player to be read from the Options window. Changed the DVDStyler XML to use the path to DVDStyler from the Options window. Added support for PgcEdit versions 8.5 and 8.6. Added a DVDStyler preview option. ---------16/08/09---------- v0.2 Added PgcEdit and DVDStyler program checks. Added an About window. ---------15/08/09---------- v0.1 Initial release. #ce ;------------------------------------------------------------------ ; Constants and Variables ;------------------------------------------------------------------ Const $delay = 150, $safe_tv_area_indent = 30, $max_button_width = 740 - ($safe_tv_area_indent * 2), $max_button_height = 580 - ($safe_tv_area_indent * 2) ;$max_button_width = 740, $max_button_height = 580 Const $main_gui_width = 300, $main_gui_height = 200, $std_button_width = 70, $std_button_height = 20, $std_button_gap = 10, $std_input_width = 200 const $screen_centre_x = abs($max_button_width / 2), $screen_centre_y = abs($max_button_height / 2), $button_margin = 20 Const $ini_filename = @ScriptDir & "\data\Rapid Menu Writer.ini" Const $log_filename = @ScriptDir & "\data\Rapid Menu Writer.log" Const $xml_filename = @TempDir & "\dvd_menu.xml" Const $pgceditpreview_filename = @TempDir & "\PgcEditPreview.ini" Const $defaultpgceditpath = @ProgramFilesDir & "\PgcEdit\PgcEdit.exe" Const $defaultdvdstylerpath = @ProgramFilesDir & "\DVDStyler\bin\DVDStyler.exe" Const $defaultdvdplayerpath = @ProgramFilesDir & "\MPC HomeCinema\mpc-hc.exe" Const $defaultdvdstylerpreview = $GUI_UNCHECKED Const $defaultpreviewscale = "30" Const $dvdstyler_head1 = "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF Const $dvdstyler_menus1 = " " & @CRLF Const $dvdstyler_menus_pgc1 = " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF Const $dvdstyler_menus_pgc2 = " " & @CRLF Const $dvdstyler_menus_pgc3 = " " & @CRLF Const $dvdstyler_menus_pgc4 = " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF Const $dvdstyler_menus2 = " " & @CRLF Const $dvdstyler_foot1 = " " & @CRLF & _ " " & @CRLF Const $dvdstyler_foot2 = " " & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "" & @CRLF dim $msg, $videotsselectbutton = 999, $pgceditedit = 999, $button_width, $videotspath, $pgc_list, $start_time, $main_gui dim $curr_gui, $menu_exists, $res, $num_menus, $vts_num, $ttn_num, $pgc_list_cell_header dim $menu_import_next_win_title = "Select the IFO file with the menu to import" dim $pgcedit_pgc_list_keys = "{ALTDOWN}i{ALTUP}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}" dim $pgcedit_import_menu_keys = "{ALTDOWN}m{ALTUP}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}" dim $pgcedit_import_all_commands_keys = "{ALTDOWN}f{ALTUP}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{DOWN}{DOWN}{DOWN}{ENTER}" dim $pgcedit_save_dvd_win_title = "PgcEdit: Save DVD" dim $dvdstyler_output_path = _TempFile() dim $pgc_commands_path = _TempFile() Dim $szDrive, $szDir, $szFName, $szExt Global $pgcdict = ObjCreate("Scripting.Dictionary") Global $vtstlist, $ttnlist, $ttnlistitem[100][100], $curr_vtst, $listview_clicked ;------------------------------------------------------------------ ; Configure the GUIs ;------------------------------------------------------------------ ; Main $main_gui = GUICreate("Rapid Menu Writer", $main_gui_width, $main_gui_height) $filemenu = GUICtrlCreateMenu("&File") $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $toolsmenu = GUICtrlCreateMenu("&Tools") $pgcedititem = GUICtrlCreateMenuItem("Run &PgcEdit", $toolsmenu) $dvdstyleritem = GUICtrlCreateMenuItem("Run &DVDStyler", $toolsmenu) $logfileitem = GUICtrlCreateMenuItem("&View Log", $toolsmenu) $optionsitem = GUICtrlCreateMenuItem("&Options", $toolsmenu) $helpmenu = GUICtrlCreateMenu("&Help") $contentsitem = GUICtrlCreateMenuItem("&Contents", $helpmenu) $aboutitem = GUICtrlCreateMenuItem("&About", $helpmenu) $backbutton = GUICtrlCreateButton("< &Back", $main_gui_width - ($std_button_width * 3) - ($std_button_gap * 2), $main_gui_height - $std_button_height - 25, $std_button_width, $std_button_height) $nextbutton = GUICtrlCreateButton("&Next >", $main_gui_width - ($std_button_width * 2) - ($std_button_gap * 2), $main_gui_height - $std_button_height - 25, $std_button_width, $std_button_height) $cancelbutton = GUICtrlCreateButton("&Cancel", $main_gui_width - $std_button_width - $std_button_gap, $main_gui_height - $std_button_height - 25, $std_button_width, $std_button_height) $headinglabel = GUICtrlCreateLabel("", $std_button_gap, 10, $main_gui_width - ($std_button_gap * 2), 15, $SS_CENTER) GUICtrlSetFont($headinglabel, 8.5, 800) $headingpic = GUICtrlCreatePic(@ScriptDir & "\data\Rapid Menu Writer.gif", 0, 5, $main_gui_width, 40) $msg1label = GUICtrlCreateLabel("", 0, 0) ; Other $videotsedit = GUICtrlCreateInput("", $std_button_gap, 70, $std_input_width, $std_button_height) $videotsselectbutton = GUICtrlCreateButton("&Select", $std_button_gap + $std_input_width + $std_button_gap, 70, $std_button_width, $std_button_height) $titlesetbuttonslabel = GUICtrlCreateLabel("Titleset buttons", 10, 25, 120, 20) $vtstlist = GUICtrlCreateListView(" ", 10, 40, 120, 70, BitOr($LVS_NOCOLUMNHEADER, $LVS_EDITLABELS, $LVS_SINGLESEL)) $titlebuttonslabel = GUICtrlCreateLabel("Title buttons", 160, 25, 120, 20) $ttnlist = GUICtrlCreateListView(" ", 160, 40, 120, 70, BitOr($LVS_NOCOLUMNHEADER, $LVS_EDITLABELS, $LVS_SINGLESEL)) $titlemenucheckbox = GUICtrlCreateCheckbox("Title &menus?", 10, 120, 80, 20) $renamebutton = GUICtrlCreateButton("&Rename", 100, 120, $std_button_width, $std_button_height) $previewbutton = GUICtrlCreateButton("&Preview", 180, 120, $std_button_width, $std_button_height) $opendvdbutton = GUICtrlCreateButton("&Play DVD", ($main_gui_width / 2) - ($std_button_width / 2), 80, $std_button_width, $std_button_height) $openpgceditbutton = GUICtrlCreateButton("&Open DVD in PgcEdit", ($main_gui_width / 2) - (120 / 2), 100, 120, $std_button_height) $maindonatebutton = GUICtrlCreateButton("Please &Donate", ($main_gui_width / 2) - (120 / 2), 120, 120, $std_button_height) ; Options $options_gui = GUICreate("Rapid Menu Writer - Options", 500, 200, -1, -1, -1, -1, $main_gui) GUICtrlCreateLabel("PgcEdit Program Path", 10, 30, 130) $pgceditedit = GUICtrlCreateInput(IniRead($ini_filename, "config", "pgceditpath", $defaultpgceditpath), 140, 30, 250, 20) $pgceditselectbutton = GUICtrlCreateButton("&Select", 400, 30, 50, 20) GUICtrlCreateLabel("DVDStyler Program Path", 10, 50, 130) $dvdstyleredit = GUICtrlCreateInput(IniRead($ini_filename, "config", "dvdstylerpath", $defaultdvdstylerpath), 140, 50, 250, 20) $dvdstylerselectbutton = GUICtrlCreateButton("S&elect", 400, 50, 50, 20) GUICtrlCreateLabel("DVD Player Program Path", 10, 70, 130) $dvdplayeredit = GUICtrlCreateInput(IniRead($ini_filename, "config", "dvdplayerpath", $defaultdvdplayerpath), 140, 70, 250, 20) $dvdplayerselectbutton = GUICtrlCreateButton("Se&lect", 400, 70, 50, 20) $dvdstylerpreviewcheckbox = GUICtrlCreateCheckbox("&Preview and Edit in DVDStyler", 140, 90, 250, 20) GUICtrlSetState($dvdstylerpreviewcheckbox, IniRead($ini_filename, "config", "dvdstylerpreview", $defaultdvdstylerpreview)) GUICtrlCreateLabel("Preview Scale (0 to 150)", 10, 110, 130) $previewscaleinput = GUICtrlCreateInput(IniRead($ini_filename, "config", "previewscale", $defaultpreviewscale), 140, 110, 50, 20) $configclosebutton = GUICtrlCreateButton("&Close", 50, 170, 70, 20) $restoredefaultsbutton = GUICtrlCreateButton("&Restore Defaults", 130, 170, 100, 20) ; About $about_gui = GUICreate("Rapid Menu Writer - About", 380, 170, -1, -1, -1, -1, $main_gui) $aboutpic = GUICtrlCreatePic(@ScriptDir & "\data\Rapid Menu Writer.gif", 0, 5, 380, 50) GUICtrlCreateLabel( "Version 1.3 (21th September 2009)" & @CRLF & _ "Freeware (donations welcome)", 10, 60, 370, 30, $SS_CENTER) GUICtrlCreateLabel( "Author: Sean Griffin" & @CRLF & _ "WWW: http://www.autoitscript.com/forum/index.php?showtopic=100260" & @CRLF & _ "Email: seangriffin@aanet.com.au", 10, 90, 370, 50) $aboutclosebutton = GUICtrlCreateButton("&Close", 160, 140, 70, 20) $aboutdonatebutton = GUICtrlCreateButton("Please &Donate", 240, 140, 120, 20) ;------------------------------------------------------------------ ; Display the Main GUI ;------------------------------------------------------------------ ; Get the default browser $default_browser_path = RegRead('HKCR\' & RegRead('HKCR\.html', '') & '\shell\open\command', '') If StringLeft($default_browser_path, 1) = '"' Then $default_browser_path = StringRegExpReplace($default_browser_path, '\A"+|".*\z', '') Else $default_browser_path = StringRegExpReplace($default_browser_path, '\A\s+|\s.*\z', '') EndIf $curr_gui = $main_gui GUISwitch($curr_gui) hide_controls() GUICtrlSetState($backbutton, $GUI_DISABLE) GUICtrlSetState($nextbutton, $GUI_FOCUS) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") FileDelete($log_filename) _FileWriteLog($log_filename, "Log started.") _FileWriteLog($log_filename, "INI file path: " & $ini_filename) _FileWriteLog($log_filename, "Log file path: " & $log_filename) _FileWriteLog($log_filename, "XML file path: " & $xml_filename) _FileWriteLog($log_filename, "DVDStyler output path: " & $dvdstyler_output_path) _FileWriteLog($log_filename, "PGC commands path: " & $pgc_commands_path) if FileExists($ini_filename) Then _FileWriteLog($log_filename, "Contents of INI file:" & @CRLF & @CRLF & FileRead($ini_filename) & @CRLF) EndIf $step_num = -1 $msg = $nextbutton While 1 if $msg = $pgcedititem Then $res = ShellExecute(GUICtrlRead($pgceditedit)) _FileWriteLog($log_filename, "Executing " & GUICtrlRead($pgceditedit) & ". Result = " & $res) EndIf if $msg = $dvdstyleritem Then ShellExecute(GUICtrlRead($dvdstyleredit)) _FileWriteLog($log_filename, "Executing " & GUICtrlRead($dvdstyleredit) & ". Result = " & $res) EndIf if $msg = $logfileitem Then $res = ShellExecute("notepad.exe", $log_filename) _FileWriteLog($log_filename, "Executing ""notepad.exe " & $log_filename & """. Result = " & $res) EndIf if $msg = $optionsitem Then ; Disable the Main GUI, and enable the Options GUI GUISetState(@SW_DISABLE) $curr_gui = $options_gui GUISwitch($curr_gui) GUISetState(@SW_SHOW) EndIf if $msg = $aboutitem Then ; Disable the Main GUI, and enable the About GUI GUISetState(@SW_DISABLE) $curr_gui = $about_gui GUISwitch($curr_gui) GUISetState(@SW_SHOW) GUICtrlSetState($aboutdonatebutton, $GUI_FOCUS) EndIf if $msg = $contentsitem Then $res = ShellExecute(@ScriptDir & "\data\Rapid Menu Writer.chm") _FileWriteLog($log_filename, "Executing """ & @ScriptDir & "\data\Rapid Menu Writer.chm"". Result = " & $res) EndIf if $msg = $pgceditselectbutton Then $tmp_path = FileOpenDialog("Select the PgcEdit Executable", @ProgramFilesDir, "Executables (*.exe)", "", "PgcEdit.exe") if StringCompare($tmp_path, "") <> 0 Then GUICtrlSetData($pgceditedit, $tmp_path) EndIf EndIf if $msg = $dvdstylerselectbutton Then $tmp_path = FileOpenDialog("Select the DVD Styler Executable", @ProgramFilesDir, "Executables (*.exe)", "", "DVDStyler.exe") if StringCompare($tmp_path, "") <> 0 Then GUICtrlSetData($dvdstyleredit, $tmp_path) EndIf EndIf if $msg = $dvdplayerselectbutton Then $tmp_path = FileOpenDialog("Select the DVD Player Executable", @ProgramFilesDir, "Executables (*.exe)", "", "wmplayer.exe") if StringCompare($tmp_path, "") <> 0 Then GUICtrlSetData($dvdplayeredit, $tmp_path) EndIf EndIf if $msg = $configclosebutton Then ; Store the options IniWrite($ini_filename, "config", "pgceditpath", GUICtrlRead($pgceditedit)) IniWrite($ini_filename, "config", "dvdstylerpath", GUICtrlRead($dvdstyleredit)) IniWrite($ini_filename, "config", "dvdplayerpath", GUICtrlRead($dvdplayeredit)) IniWrite($ini_filename, "config", "dvdstylerpreview", GUICtrlRead($dvdstylerpreviewcheckbox)) IniWrite($ini_filename, "config", "previewscale", GUICtrlRead($previewscaleinput)) ; Disable the Options GUI, and enable the Main GUI GUISetState(@SW_HIDE) $curr_gui = $main_gui GUISwitch($curr_gui) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) EndIf if $msg = $restoredefaultsbutton Then GUICtrlSetData($pgceditedit, $defaultpgceditpath) GUICtrlSetData($dvdstyleredit, $defaultdvdstylerpath) GUICtrlSetData($dvdplayeredit, $defaultdvdplayerpath) GUICtrlSetState($dvdstylerpreviewcheckbox, $defaultdvdstylerpreview) GUICtrlSetData($previewscaleinput, $defaultpreviewscale) EndIf if $msg = $aboutclosebutton Then ; Disable the About GUI, and enable the Main GUI GUISetState(@SW_HIDE) $curr_gui = $main_gui GUISwitch($curr_gui) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) EndIf if $msg = $aboutdonatebutton Then ShellExecute($default_browser_path, "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ZW6JVU9HJ4TG4&lc=AU&item_name=Rapid%20Menu%20Writer¤cy_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted") EndIf if $msg = $titlemenucheckbox Then if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then GUICtrlSetState($ttnlist, $GUI_SHOW) GUICtrlSetState($titlebuttonslabel, $GUI_SHOW) Else GUICtrlSetState($ttnlist, $GUI_HIDE) GUICtrlSetState($titlebuttonslabel, $GUI_HIDE) EndIf GUICtrlSetState($vtstlist, $GUI_FOCUS) EndIf if $msg = $renamebutton Then if StringCompare($listview_clicked, "vts") = 0 Then _GUICtrlListView_EditLabel($vtstlist, _GUICtrlListView_GetSelectionMark($vtstlist)) EndIf if StringCompare($listview_clicked, "ttn") = 0 Then _GUICtrlListView_EditLabel($ttnlist, _GUICtrlListView_GetSelectionMark($ttnlist)) EndIf EndIf if $msg = $previewbutton Then _PathSplit(GUICtrlRead($pgceditedit), $szDrive, $szDir, $szFName, $szExt) $pgceditpreview_path = $szDrive & $szDir & "bin\PgcEditPreview.exe" $preview_title = "Rapid Menu Writer Preview" if StringCompare($listview_clicked, "vts") = 0 Then $cell_start = $pgcdict.item("VTS " & $curr_vtst & " TTN 1 sector start") $cell_end = $pgcdict.item("VTS " & $curr_vtst & " TTN " & $pgcdict.item("VTS " & $curr_vtst & " num TTNs") & " sector end") FileDelete($pgceditpreview_filename) FileWrite($pgceditpreview_filename, _ "[PgcEditPreview]" & @CRLF & _ "VOBFileName = " & GUICtrlRead($videotsedit) & "\VTS_" & StringFormat("%02s", $curr_vtst) & "_1.VOB" & @CRLF & _ "NumCells = 1" & @CRLF & _ "DAR = 16" & @CRLF & _ "Scale = " & GUICtrlRead($previewscaleinput) & @CRLF & _ "PGCTitle = " & $preview_title & @CRLF & _ "DefaultFileName = " & $pgceditpreview_filename & @CRLF & _ "CellNumber = 1" & @CRLF & _ "StartPlay = 1" & @CRLF & _ "AutoLocate = 500" & @CRLF & _ "NoOverlay = 0" & @CRLF & _ "RealTimePlayback = 1" & @CRLF & _ "AutoQuit = 1" & @CRLF & _ "BlankString = ""Blank this cell""" & @CRLF & _ "SleepOnSingleFrame = 3000" & @CRLF & _ "ThisID = 3140" & @CRLF & _ "ExitStopButton = 1" & @CRLF & _ "MinDisplayTime = 2000" & @CRLF & _ "ReturnFilePath = C:/temp/preview_return.tcl" & @CRLF & _ "StartSize=0" & @CRLF & _ "" & @CRLF & _ "[CellStartEnds]" & @CRLF & _ "1=0 999999") EndIf if StringCompare($listview_clicked, "ttn") = 0 Then $cell_start = $pgcdict.item("VTS " & $curr_vtst & " TTN " & (_GUICtrlListView_GetSelectionMark($ttnlist) + 1) & " sector start") $cell_end = $pgcdict.item("VTS " & $curr_vtst & " TTN " & (_GUICtrlListView_GetSelectionMark($ttnlist) + 1) & " sector end") FileDelete($pgceditpreview_filename) FileWrite($pgceditpreview_filename, _ "[PgcEditPreview]" & @CRLF & _ "VOBFileName = " & GUICtrlRead($videotsedit) & "\VTS_" & StringFormat("%02s", $curr_vtst) & "_1.VOB" & @CRLF & _ "NumCells = 1" & @CRLF & _ "DAR = 16" & @CRLF & _ "Scale = " & GUICtrlRead($previewscaleinput) & @CRLF & _ "PGCTitle = " & $preview_title & @CRLF & _ "DefaultFileName = " & $pgceditpreview_filename & @CRLF & _ "CellNumber = 1" & @CRLF & _ "StartPlay = 1" & @CRLF & _ "AutoLocate = 500" & @CRLF & _ "NoOverlay = 0" & @CRLF & _ "RealTimePlayback = 1" & @CRLF & _ "AutoQuit = 1" & @CRLF & _ "BlankString = ""Blank this cell""" & @CRLF & _ "SleepOnSingleFrame = 3000" & @CRLF & _ "ThisID = 3140" & @CRLF & _ "ExitStopButton = 1" & @CRLF & _ "MinDisplayTime = 2000" & @CRLF & _ "ReturnFilePath = C:/temp/preview_return.tcl" & @CRLF & _ "StartSize=0" & @CRLF & _ "" & @CRLF & _ "[CellStartEnds]" & @CRLF & _ "1=" & $cell_start & " " & $cell_end) EndIf ; Close any existing preview windows While ProcessExists("PgcEditPreview.exe") ProcessClose("PgcEditPreview.exe") WEnd ; Get the RMW window position $rmw_win_pos = WinGetPos($main_gui) ; Start the preview ShellExecute($pgceditpreview_path, $pgceditpreview_filename);, "", "open", @SW_MINIMIZE) WinWait("Rapid Menu Writer Preview") $preview_win_pos = WinGetPos("Rapid Menu Writer Preview") ; If there is room to place the Preview window next to the Main GUI if ($preview_win_pos[0] - $rmw_win_pos[2]) > 0 Then ; Move the Main GUI to be next to the Preview window. WinMove($main_gui, "", $preview_win_pos[0] - $rmw_win_pos[2], $preview_win_pos[1]) ; Activate the Main GUI, to allow the user to perform other functions. WinActivate($main_gui) if StringCompare($listview_clicked, "vts") = 0 Then ControlFocus($main_gui, "", $vtstlist) EndIf if StringCompare($listview_clicked, "ttn") = 0 Then ControlFocus($main_gui, "", $ttnlist) EndIf EndIf EndIf if $msg = $backbutton Then $step_num = $step_num - 1 if $msg = $nextbutton Then $step_num = $step_num + 1 if $msg = $backbutton Or $msg = $nextbutton Then ; Step 0 (Main window) if $step_num = 0 Then ; Display the GUI for the current step hide_controls() GUICtrlSetState($backbutton, $GUI_DISABLE) GUICtrlSetState($headingpic, $GUI_SHOW) GUICtrlSetPos($msg1label, $std_button_gap, 50, $main_gui_width - ($std_button_gap * 2), 100) GUICtrlSetData($msg1label, "This is a wizard for creating very simple DVD menus." & @crlf & @crlf & _ "This menu writer is fast and efficient. It can add a menu" & @crlf & _ "to a DVD in seconds, and uses only a fraction of your disk" & @crlf & _ "space." & @crlf & @crlf & _ "To continue, click Next.") GUICtrlSetState($msg1label, $GUI_SHOW) EndIf ; Step 1 if $step_num = 1 Then ; Validation of required executables if FileExists(GUICtrlRead($pgceditedit)) = false then MsgBox(262160, "Rapid Menu Writer - Error", "Could not find PgcEdit at the following path:" & @CRLF & @CRLF & _ GUICtrlRead($pgceditedit) & @CRLF & @CRLF & _ "Follow these steps to fix this problem:" & @CRLF & @CRLF & _ "1. Click OK below to close this message." & @CRLF & _ "2. Download PgcEdit (try http://download.videohelp.com/r0lz/pgcedit)." & @CRLF & _ "3. Put the file PgcEdit.exe into a folder on your computer (ie. C:\Program Files\PgcEdit)." & @CRLF & _ "4. In the Rapid Menu Writer window, click the Tools menu, and then Options." & @CRLF & _ "5. In the Rapid Menu Writer - Options window, type or select the path to PgcEdit.exe." & @CRLF & _ "6. Click Close, and then try clicking the Next button again.") $step_num = $step_num - 1 Else if FileExists(GUICtrlRead($dvdstyleredit)) = false then MsgBox(262160, "Rapid Menu Writer - Error", "Could not find DVDStyler at the following path:" & @CRLF & @CRLF & _ GUICtrlRead($dvdstyleredit) & @CRLF & @CRLF & _ "Follow these steps to fix this problem:" & @CRLF & @CRLF & _ "1. Click OK below to close this message." & @CRLF & _ "2. Download DVDStyler (try http://www.dvdstyler.de)." & @CRLF & _ "3. Install DVDStyler" & @CRLF & _ "4. In the Rapid Menu Writer window, click the Tools menu, and then Options." & @CRLF & _ "5. In the Rapid Menu Writer - Options window, type or select the path to DVDStyler.exe." & @CRLF & _ "6. Click Close, and then try clicking the Next button again.") $step_num = $step_num - 1 Else $start_time = TimerInit() ; Get the config for the current step $videotseditpath = IniRead($ini_filename, "config", "videotspath", "") _FileWriteLog($log_filename, "Reading INI file videotspath key. Result = " & $videotseditpath) ; Display the GUI for the current step hide_controls() GUICtrlSetData($headinglabel, "Select the DVD folder") GUICtrlSetPos($msg1label, $std_button_gap, 30, $main_gui_width - ($std_button_gap * 2), 30) GUICtrlSetData($msg1label, "Select the VIDEO_TS folder of the DVD you wish to add" & @CRLF & "the menu to.") GUICtrlSetState($msg1label, $GUI_SHOW) GUICtrlSetData($videotsedit, $videotseditpath) GUICtrlSetState($videotsedit, $GUI_SHOW) GUICtrlSetState($videotsselectbutton, $GUI_SHOW) GUICtrlSetState($backbutton, $GUI_ENABLE) EndIf EndIf EndIf ; Step 2 if $step_num = 2 Then _FileWriteLog($log_filename, "User selected DVD folder " & GUICtrlRead($videotsedit)) ; Store the config for the previous step $res = IniWrite($ini_filename, "config", "videotspath", GUICtrlRead($videotsedit)) _FileWriteLog($log_filename, "Writing INI file videotspath key. Result = " & $res) ; Display the GUI for the current step hide_controls() GUICtrlSetData($headinglabel, "Edit the labels for the buttons of the new menus") GUICtrlSetState($msg1label, $GUI_HIDE) GUICtrlSetState($titlesetbuttonslabel, $GUI_SHOW) GUICtrlSetState($vtstlist, $GUI_SHOW) GUICtrlSetState($titlebuttonslabel, $GUI_SHOW) GUICtrlSetState($ttnlist, $GUI_SHOW) GUICtrlSetState($titlemenucheckbox, $GUI_SHOW) GUICtrlSetState($titlemenucheckbox, $GUI_CHECKED) GUICtrlSetState($renamebutton, $GUI_SHOW) GUICtrlSetState($previewbutton, $GUI_SHOW) GUISetState(@SW_MINIMIZE) $res = DirRemove(GUICtrlRead($videotsedit) & "\PgcEdit_backup", 1) _FileWriteLog($log_filename, "Removing the folder " & GUICtrlRead($videotsedit) & "\PgcEdit_backup. Result = " & $res) ;------------------------------------------------------------------ ; Open the DVD in PgcEdit ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Opening the DVD in PgcEdit.", 30) While ProcessExists("PgcEdit.exe") ProcessClose("PgcEdit.exe") _FileWriteLog($log_filename, "Closing PgcEdit.exe process.") WEnd $res = ShellExecute(GUICtrlRead($pgceditedit), """" & GUICtrlRead($videotsedit) & """") _FileWriteLog($log_filename, "Executing " & GUICtrlRead($pgceditedit) & " """ & GUICtrlRead($videotsedit) & """. Result = " & $res) ; Wait for a donation window (v9.x), or main window (v8.x) to exist. while WinExists("PgcEdit -") = False and WinExists("PgcEdit Donation Reminder") = False _FileWriteLog($log_filename, "Waiting for ""PgcEdit -"" or ""PgcEdit Donation Reminder"" windows.") sleep(500) WEnd ; While the donation window is open, keep selecting Remind Me Later. while WinExists("PgcEdit Donation Reminder") sleep(1000) $res = ControlFocus("PgcEdit Donation Reminder", "", "[CLASS:Button; INSTANCE:2]") _FileWriteLog($log_filename, "Clicking ""PgcEdit Donation Reminder"" window ""Remind me later"" button. Result = " & $res) WEnd $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) While WinExists("Verify number of streams") _FileWriteLog($log_filename, """Verify number of streams"" window exists.") $res = WinClose("Verify number of streams") _FileWriteLog($log_filename, "Closing ""Verify number of streams"" window. Result = " & $res) WEnd $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) While WinExists("Find BOVs (Buttons Over Video") _FileWriteLog($log_filename, """Find BOVs (Buttons Over Video"" window exists.") $res = WinClose("Find BOVs (Buttons Over Video") _FileWriteLog($log_filename, "Closing ""Find BOVs (Buttons Over Video"" window. Result = " & $res) WEnd ;------------------------------------------------------------------ ; Get the PgcEdit version ;------------------------------------------------------------------ ; Keep trying to select Info -> PGC list, until another window appears. $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) Do ; If the following window appears, when another menu already exists (v9.2+) if WinExists("Multiple sets of buttons") Then _FileWriteLog($log_filename, """Multiple sets of buttons"" window exists.") $res = WinClose("Multiple sets of buttons") _FileWriteLog($log_filename, "Closing ""Multiple sets of buttons"" window. Result = " & $res) EndIf SendKeepActive("PgcEdit -") $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) $res = ControlSend("PgcEdit -", "", "", "{ESC}") _FileWriteLog($log_filename, "Sending {ESC} to the ""PgcEdit -"" window . Result = " & $res) $res = ControlSend("PgcEdit -", "", "", "{ALTDOWN}h{ALTUP}{DOWN}{DOWN}{ENTER}") _FileWriteLog($log_filename, "Sending {ALTDOWN}h{ALTUP}{DOWN}{DOWN}{ENTER} to the ""PgcEdit -"" window . Result = " & $res) sleep($delay) until WinActive("PgcEdit Versions History") = True SendKeepActive("PgcEdit Versions History") $res = WinActivate("PgcEdit Versions History") _FileWriteLog($log_filename, "Activating the ""PgcEdit Versions History"" window. Result = " & $res) $res = ControlSend("PgcEdit Versions History", "", "", "{CTRLDOWN}a{CTRLUP}") _FileWriteLog($log_filename, "Sending {CTRLDOWN}a{CTRLUP} to the ""PgcEdit Versions History"" window . Result = " & $res) sleep($delay) $res = ControlSend("PgcEdit Versions History", "", "", "{CTRLDOWN}c{CTRLUP}") _FileWriteLog($log_filename, "Sending {CTRLDOWN}c{CTRLUP} to the ""PgcEdit Versions History"" window . Result = " & $res) sleep($delay) $res = ControlSend("PgcEdit Versions History", "", "", "{ESC}") _FileWriteLog($log_filename, "Sending {ESC} to the ""PgcEdit Versions History"" window . Result = " & $res) $pgc_list = ClipGet() _FileWriteLog($log_filename, "The first 500 characters of text in the ""PgcEdit Versions History"" window:" & @CRLF & @CRLF & StringLeft($pgc_list, 500) & @CRLF & @CRLF) $pgc_list_line = StringSplit($pgc_list, @crlf, 1) $pgcedit_version = StringLeft($pgc_list_line[9], StringInStr($pgc_list_line[9], " ")-1) _FileWriteLog($log_filename, "Detected the PgcEdit version as " & $pgcedit_version & ".") if $pgcedit_version <= 8.6 Then $pgcedit_import_all_commands_keys = "{ALTDOWN}f{ALTUP}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{DOWN}{DOWN}{DOWN}{ENTER}" EndIf ;------------------------------------------------------------------ ; Get the PGC information ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Getting the PGCs of the DVD.", 30) ; Keep trying to select Info -> PGC list, until another window appears. Do SendKeepActive("PgcEdit -") $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) $res = ControlSend("PgcEdit -", "", "", "{ESC}") _FileWriteLog($log_filename, "Sending {ESC} to the ""PgcEdit -"" window . Result = " & $res) $res = ControlSend("PgcEdit -", "", "", $pgcedit_pgc_list_keys) _FileWriteLog($log_filename, "Sending " & $pgcedit_pgc_list_keys & " to the ""PgcEdit -"" window . Result = " & $res) sleep($delay) until WinExists("DVD PGCs Info") = True SendKeepActive("DVD PGCs Info") $res = WinActivate("DVD PGCs Info") _FileWriteLog($log_filename, "Activating the ""DVD PGCs Info"" window. Result = " & $res) $res = ControlSend("DVD PGCs Info", "", "", "{CTRLDOWN}a{CTRLUP}") _FileWriteLog($log_filename, "Sending {CTRLDOWN}a{CTRLUP} to the ""DVD PGCs Info"" window . Result = " & $res) sleep($delay) $res = ControlSend("DVD PGCs Info", "", "", "{CTRLDOWN}c{CTRLUP}") _FileWriteLog($log_filename, "Sending {CTRLDOWN}c{CTRLUP} to the ""DVD PGCs Info"" window . Result = " & $res) sleep($delay) $res = ControlSend("DVD PGCs Info", "", "", "{ESC}") _FileWriteLog($log_filename, "Sending {ESC} to the ""DVD PGCs Info"" window . Result = " & $res) $pgc_list = ClipGet() _FileWriteLog($log_filename, "The PGC list from the ""DVD PGCs Info"" window:" & @CRLF & @CRLF & $pgc_list & @CRLF) $pgc_list_line = StringSplit($pgc_list, @crlf, 1) $pgc_list_cell_header = False $ttn_num = 0 $vts_num = 0 for $each in $pgc_list_line if StringCompare(StringLeft($each, 14), "Number of VTS:") = 0 Then $pgcdict.item("num VTSs") = Number(StringReplace($each, "Number of VTS: ", "")) EndIf if StringCompare(StringLeft($each, 4), "VTS ") = 0 Then if $vts_num > 0 Then $pgcdict.item("VTS " & $vts_num & " num TTNs") = $ttn_num EndIf $vts_num = Number(StringReplace(StringReplace(StringReplace($each, "VTS ", ""), " (", ""), ")", "")) $pgcdict.item("VTS " & $vts_num & " label") = "Titleset " & $vts_num $pgcdict.item("VTS " & $vts_num & " filename") = StringReplace(StringRegExpReplace($each, "VTS [0-9]* \(", ""), ")", "") EndIf if StringCompare(StringLeft($each, 19), " ************ VTST ") = 0 Then $ttn_num = Number(StringStripWS(StringMid($each, StringInStr($each, " TTN ")+4, 3), 8)) $pgcdict.item("VTS " & $vts_num & " TTN " & $ttn_num & " label") = "Title " & $ttn_num EndIf if $pgc_list_cell_header = True And StringRegExp($each, " [0-9\?]") = 1 Then $pgc_list_cell_header = False $pgcdict.item("VTS " & $vts_num & " TTN " & $ttn_num & " sector start") = Number(StringStripWS(StringMid($each, 84, 8), 8)) $pgcdict.item("VTS " & $vts_num & " TTN " & $ttn_num & " sector end") = Number(StringStripWS(StringMid($each, 111, 8), 8)) EndIf if StringCompare(StringLeft($each, 22), " BOVs Chap. Prog. Cell") = 0 Then $pgc_list_cell_header = True EndIf Next $pgcdict.item("VTS " & $vts_num & " num TTNs") = $ttn_num ; If there is already a menu on the DVD if StringInStr($pgc_list, "VMGM: no menu") > 0 Then $menu_exists = False Else $menu_exists = True EndIf ;------------------------------------------------------------------ ; Update the Rapid Menu Writer GUI ;------------------------------------------------------------------ ; Wipe any items from a previous run $res = _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($vtstlist)) $res = _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ttnlist)) ; Populate the VTST list for $vts_num = 1 to $pgcdict.item("num VTSs") GUICtrlCreateListViewItem($pgcdict.item("VTS " & $vts_num & " label"), $vtstlist) Next ; Populate the TTN list for VTS 1 for $ttn_num = 1 to $pgcdict.item("VTS 1 num TTNs") GUICtrlCreateListViewItem($pgcdict.item("VTS 1 TTN " & $ttn_num & " label"), $ttnlist) Next $curr_vtst = 1 $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) $res = WinSetState("PgcEdit -", "", @SW_MINIMIZE) _FileWriteLog($log_filename, "Minimising the ""PgcEdit -"" window. Result = " & $res) ; If only one titleset exists if $pgcdict.item("num VTSs") = 1 Then ; then force the use of the titleset menu (the main menu will be skipped in the resulting DVD) GUICtrlSetState($titlemenucheckbox, $GUI_CHECKED) GUICtrlSetState($titlemenucheckbox, $GUI_DISABLE) GUICtrlSetState($ttnlist, $GUI_SHOW) GUICtrlSetState($vtstlist, $GUI_FOCUS) _GUICtrlListView_SetItemSelected($ttnlist, 0, True, True) Else ; focus the titlesets GUICtrlSetState($vtstlist, $GUI_FOCUS) _GUICtrlListView_SetItemSelected($vtstlist, 0, True, True) EndIf TrayTip("Rapid Menu Writer", "", 0) $res = GUISetState(@SW_RESTORE) _FileWriteLog($log_filename, "Restoring the ""Rapid Menu Writer"" window. Result = " & $res) EndIf ; Step 3 if $step_num = 3 Then While ProcessExists("DVDStyler.exe") ProcessClose("DVDStyler.exe") _FileWriteLog($log_filename, "Closing DVDStyler.exe process.") WEnd GUISetState(@SW_MINIMIZE) _FileWriteLog($log_filename, "Minimising the ""Rapid Menu Writer"" window. Result = " & $res) ;------------------------------------------------------------------ ; Create the DVDStyler load file ;------------------------------------------------------------------ $file = FileOpen($xml_filename, 2) _FileWriteLog($log_filename, "Creating the DVDStyler XML file " & $xml_filename & ". Result = " & $file) FileWriteLine($file, $dvdstyler_head1) ; Define the Menus FileWriteLine($file, $dvdstyler_menus1) ; ; MAIN MENU Page(s) ; Note:- more than one if the number of titlesets exceeds 12. ; $vts_num = 0 $vts_num2 = 0 $vts_num3 = 0 $num_main_menus = Ceiling($pgcdict.item("num VTSs") / 12) $num_menus = $num_main_menus ; For each main menu page. for $main_menu_num = 1 to $num_main_menus $obj_num = 0 $button_num = 0 $num_vts_in_curr_page = _Min(12, $pgcdict.item("num VTSs") - (($main_menu_num-1) * 12)) FileWriteLine($file, $dvdstyler_menus_pgc1) ; Define the menu title $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " MAIN MENU") FileWriteLine($file, " ") ; Define the Titleset button names on the Main Menu page ; $num_vts_in_curr_page=12 for all pages except the last one, which is whatever is left over. for $i = 1 to $num_vts_in_curr_page $vts_num = $vts_num + 1 ; Titleset button $button_num = $button_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " " & _GUICtrlListView_GetItemText($vtstlist, ($vts_num-1)) & "") FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then ; If the number of titles in the titleset is greater than 1 (then it's worth adding a titleset menu) if $pgcdict.item("VTS " & $vts_num & " num TTNs") > 1 Then ; Add a Titleset menu button $button_num = $button_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Menu") FileWriteLine($file, " ") EndIf EndIf Next ; Left arrow and Back label if $main_menu_num > 1 Then $button_num = $button_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Back") FileWriteLine($file, " ") EndIf ; Right arrow and Next label if $main_menu_num < $num_main_menus Then $button_num = $button_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Next") FileWriteLine($file, " ") EndIf FileWriteLine($file, $dvdstyler_menus_pgc2) ; Define the Titleset button locations on the Main Menu $button_xml = " " & @CRLF $obj_xml = " " & @CRLF $obj_num = 0 $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " & @CRLF if $num_vts_in_curr_page <= 4 Then $button_width = Abs($max_button_width / $num_vts_in_curr_page) $button_height = Abs($max_button_height / $num_vts_in_curr_page) $row1_button_y = $screen_centre_y - (Abs($max_button_height / $num_vts_in_curr_page) / 2) EndIf if $num_vts_in_curr_page > 4 and $num_vts_in_curr_page < 9 Then $button_width = Abs($max_button_width / 4) $button_height = Abs($max_button_height / 4) $row1_button_y = $screen_centre_y - (Abs($max_button_height / 4)) EndIf if $num_vts_in_curr_page >= 9 Then $button_width = Abs($max_button_width / 4) $button_height = Abs($max_button_height / 4) $row1_button_y = $screen_centre_y - (Abs($max_button_height / 4)) - Abs((Abs($max_button_height / 4)) / 2) EndIf $button_width_new = $button_width - ($button_margin * 2) $button_height_new = $button_height - ($button_margin * 2) $button_num = 0 for $i = 1 to $num_vts_in_curr_page $vts_num2 = $vts_num2 + 1 ; Determine button locations if $i <= 4 Then $button_x = 10 + ($button_width * ($i - 1)) $button_y = $row1_button_y EndIf if $i > 4 and $i < 9 Then $button_x = 10 + ($button_width * (($i - 4) - 1)) $button_y = $row1_button_y + $button_height EndIf if $i >= 9 Then $button_x = 10 + ($button_width * (($i - 8) - 1)) $button_y = $row1_button_y + ($button_height * 2) EndIf ; Indent button x and y to be inside the DVDStyler "safe TV area" $button_x = $button_x + $safe_tv_area_indent $button_y = $button_y + $safe_tv_area_indent ; Titleset button $button_num = $button_num + 1 $button_xml = $button_xml & " " $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " & @CRLF ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then ; If the number of titles in the titleset is greater than 1 (then it's worth adding a titleset menu) if $pgcdict.item("VTS " & $vts_num2 & " num TTNs") > 1 Then ; Titleset menu button $button_num = $button_num + 1 $button_xml = $button_xml & " " EndIf EndIf Next if $main_menu_num > 1 Then $button_num = $button_num + 1 $button_xml = $button_xml & " " $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " EndIf if $main_menu_num < $num_main_menus Then $button_num = $button_num + 1 $button_xml = $button_xml & " " $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " EndIf $button_xml = $button_xml & " " & @CRLF $obj_xml = $obj_xml & " " & @CRLF ; Write the objects XML before the buttons XML (to ensure the button text is displayed on top) FileWriteLine($file, $obj_xml) FileWriteLine($file, $button_xml) FileWriteLine($file, $dvdstyler_menus_pgc3) $button_num = 0 $obj_num = 1 for $i = 1 to $num_vts_in_curr_page $vts_num3 = $vts_num3 + 1 ; Titleset button $button_num = $button_num + 1 FileWriteLine($file, " ") ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then ; If the number of titles in the titleset is greater than 1 (then it's worth adding a titleset menu) if $pgcdict.item("VTS " & $vts_num3 & " num TTNs") > 1 Then ; Titleset menu button $button_num = $button_num + 1 FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " rectangle.xml") FileWriteLine($file, " ") EndIf EndIf Next if $main_menu_num > 1 Then $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " text.xml") FileWriteLine($file, " ") $button_num = $button_num + 1 FileWriteLine($file, " ") EndIf if $main_menu_num < $num_main_menus Then $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " text.xml") FileWriteLine($file, " ") $button_num = $button_num + 1 FileWriteLine($file, " ") EndIf FileWriteLine($file, $dvdstyler_menus_pgc4) Next ; ; TITLESET MENU Page(s) ; Note:- more than one per titleset if the number of titles in a set exceeds 12. ; ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then ; Define the Title button names on each Titleset Menu $button_num = 0 ; For each titleset menu. for $i = 1 to $pgcdict.item("num VTSs") $title_num = 0 $num_titleset_menu_pages = Ceiling($pgcdict.item("VTS " & $i & " num TTNs") / 12) ; For each titleset menu page. ; There will be more than one page if the number of titles in a titleset menu exceeds 12. for $titleset_menu_page_num = 1 to $num_titleset_menu_pages $num_titles_in_curr_page = _Min(12, $pgcdict.item("VTS " & $i & " num TTNs") - (($titleset_menu_page_num-1) * 12)) $obj_num = 0 $num_menus = $num_menus + 1 FileWriteLine($file, $dvdstyler_menus_pgc1) ; Define the titleset menu title $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " " & StringUpper(_GUICtrlListView_GetItemText($vtstlist, ($i-1))) & " MENU") FileWriteLine($file, " ") for $j = 1 to $num_titles_in_curr_page $title_num = $title_num + 1 ; Title button FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " " & $pgcdict.item("VTS " & $i & " TTN " & $title_num & " label") & "") FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") next ; Left arrow and Back label if $titleset_menu_page_num > 1 Then FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") $j = $j + 1 $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Back") FileWriteLine($file, " ") EndIf ; If more than one titleset exists if $pgcdict.item("num VTSs") > 1 Then ; Menu button (to return to the MAIN MENU) FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Main Menu") FileWriteLine($file, " ") $j = $j + 1 EndIf ; Right arrow and Next label if $titleset_menu_page_num < $num_titleset_menu_pages Then FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " ") $j = $j + 1 $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " ") FileWriteLine($file, " Next") FileWriteLine($file, " ") EndIf FileWriteLine($file, $dvdstyler_menus_pgc2) ; Define the Title button locations on the Titleset Menu $button_xml = " " & @CRLF $obj_xml = " " & @CRLF $obj_num = 0 $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " & @CRLF if $num_titles_in_curr_page <= 4 Then $button_width = Abs($max_button_width / $num_titles_in_curr_page) $button_height = Abs($max_button_height / $num_titles_in_curr_page) $row1_button_y = $screen_centre_y - (Abs($max_button_height / $num_titles_in_curr_page) / 2) EndIf if $num_titles_in_curr_page > 4 and $num_titles_in_curr_page < 9 Then $button_width = Abs($max_button_width / 4) $button_height = Abs($max_button_height / 4) $row1_button_y = $screen_centre_y - (Abs($max_button_height / 4)) EndIf if $num_titles_in_curr_page >= 9 Then $button_width = Abs($max_button_width / 4) $button_height = Abs($max_button_height / 4) $row1_button_y = $screen_centre_y - (Abs($max_button_height / 4)) - Abs((Abs($max_button_height / 4)) / 2) EndIf $button_width_new = $button_width - ($button_margin * 2) $button_height_new = $button_height - ($button_margin * 2) for $j = 1 to $num_titles_in_curr_page ; Determine button locations if $j <= 4 Then $button_x = 10 + ($button_width * ($j - 1)) $button_y = $row1_button_y EndIf if $j > 4 and $j < 9 Then $button_x = 10 + ($button_width * (($j - 4) - 1)) $button_y = $row1_button_y + $button_height EndIf if $j >= 9 Then $button_x = 10 + ($button_width * (($j - 8) - 1)) $button_y = $row1_button_y + ($button_height * 2) EndIf ; Indent button x and y to be inside the DVDStyler "safe TV area" $button_x = $button_x + $safe_tv_area_indent $button_y = $button_y + $safe_tv_area_indent ; Title button $button_xml = $button_xml & " " $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " & @CRLF Next if $titleset_menu_page_num > 1 Then $button_xml = $button_xml & " " $j = $j + 1 $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " EndIf ; If more than one titleset exists if $pgcdict.item("num VTSs") > 1 Then ; Menu button (to return to the MAIN MENU) $button_xml = $button_xml & " " $j = $j + 1 EndIf if $titleset_menu_page_num < $num_titleset_menu_pages Then $button_xml = $button_xml & " " $j = $j + 1 $obj_num = $obj_num + 1 $obj_xml = $obj_xml & " " EndIf $button_xml = $button_xml & " " & @CRLF $obj_xml = $obj_xml & " " & @CRLF ; Write the objects XML before the buttons XML (to ensure the button text is displayed on top) FileWriteLine($file, $obj_xml) FileWriteLine($file, $button_xml) FileWriteLine($file, $dvdstyler_menus_pgc3) $obj_num = 1 for $j = 1 to $num_titles_in_curr_page ; Title button FileWriteLine($file, " ") $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " rectangle.xml") FileWriteLine($file, " ") Next if $titleset_menu_page_num > 1 Then $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " text.xml") FileWriteLine($file, " ") FileWriteLine($file, " ") $j = $j + 1 EndIf ; If more than one titleset exists if $pgcdict.item("num VTSs") > 1 Then ; Menu button (to return to the MAIN MENU) FileWriteLine($file, " ") $j = $j + 1 EndIf if $titleset_menu_page_num < $num_titleset_menu_pages Then $obj_num = $obj_num + 1 FileWriteLine($file, " ") FileWriteLine($file, " text.xml") FileWriteLine($file, " ") FileWriteLine($file, " ") $j = $j + 1 EndIf FileWriteLine($file, $dvdstyler_menus_pgc4) Next Next EndIf FileWriteLine($file, $dvdstyler_menus2) FileWriteLine($file, $dvdstyler_foot1) $empty_mpg_path = StringReplace(GUICtrlRead($dvdstyleredit), "bin\DVDStyler.exe", "data\empty_pal_ac3.mpg") FileWriteLine($file, " ") FileWriteLine($file, $dvdstyler_foot2) $res = FileClose($file) _FileWriteLog($log_filename, "Closing the DVDStyler XML file " & $xml_filename & ". Result = " & $res) _FileWriteLog($log_filename, "The DVDStyler XML file:" & @CRLF & @CRLF & FileRead($xml_filename) & @CRLF) ;------------------------------------------------------------------ ; Create the menu with DVDStyler ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling DVDStyler", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Creating the menu with DVDStyler.", 30) ShellExecute(GUICtrlRead($dvdstyleredit), $xml_filename) _FileWriteLog($log_filename, "Executing " & GUICtrlRead($dvdstyleredit) & " " & $xml_filename & ". Result = " & $res) $res = WinWait("DVDStyler -") _FileWriteLog($log_filename, "Waiting for the ""DVDStyler -"" window. Result = " & $res) $res = 6 ; Yes if GUICtrlRead($dvdstylerpreviewcheckbox) = $GUI_CHECKED Then $res = MsgBox(262212, "Rapid Menu Writer - Paused", "You may now preview the menu in DVDStyler," & @CRLF & _ "and make any adjustments." & @CRLF & @CRLF & _ "Would you like to continue?" & @CRLF & _ "Click Yes to continue, or No to go back.") EndIf if $res = 6 Then ; Display the GUI for the current step hide_controls() GUICtrlSetData($headinglabel, "Writing the DVD menu") GUICtrlSetPos($msg1label, $std_button_gap, 30, $main_gui_width - ($std_button_gap * 2), 10) GUICtrlSetState($msg1label, $GUI_SHOW) GUICtrlSetData($msg1label, "") $res = WinActivate("DVDStyler -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) SendKeepActive("DVDStyler -") $res = ControlSend("DVDStyler -", "", "", "{F9}") _FileWriteLog($log_filename, "Sending {F9} to the ""DVDStyler -"" window . Result = " & $res) $res = WinWait("Burn") _FileWriteLog($log_filename, "Waiting for the ""Burn"" window. Result = " & $res) $res = WinActivate("Burn") _FileWriteLog($log_filename, "Activating the ""Burn"" window. Result = " & $res) $res = ControlSetText("Burn", "", 2001, $dvdstyler_output_path) _FileWriteLog($log_filename, "Setting the text of the ""Burn"" window ""Temp directory"" field. Result = " & $res) $res = ControlClick("Burn", "", 2003) _FileWriteLog($log_filename, "Clicking ""Burn"" window ""just generate"" button. Result = " & $res) $res = ControlClick("Burn", "", 5100) _FileWriteLog($log_filename, "Clicking ""Burn"" window ""Start"" button. Result = " & $res) $res = WinWait("Generate DVD") _FileWriteLog($log_filename, "Waiting for the ""Generate DVD"" window. Result = " & $res) $res = WinActivate("Generate DVD") _FileWriteLog($log_filename, "Activating the ""Generate DVD"" window. Result = " & $res) While StringCompare(ControlGetText("Generate DVD", "", 5101), "Close") <> 0 _FileWriteLog($log_filename, "Waiting for the ""Close"" button.") sleep(1000) WEnd $generate_dvd_summary = ControlGetText("Generate DVD", "", "[CLASS:RICHEDIT50W; INSTANCE:1]") _FileWriteLog($log_filename, "DVDStyler burn summary:" & @CRLF & @CRLF & $generate_dvd_summary & @CRLF) $generate_dvd_details = ControlGetText("Generate DVD", "", "[CLASS:RICHEDIT50W; INSTANCE:2]") _FileWriteLog($log_filename, "DVDStyler burn details:" & @CRLF & @CRLF & $generate_dvd_details & @CRLF) $res = ControlClick("Generate DVD", "", 5101) _FileWriteLog($log_filename, "Clicking ""Generate DVD"" window ""Close"" button. Result = " & $res) $res = WinWait("DVDStyler -") _FileWriteLog($log_filename, "Waiting for the ""DVDStyler -"" window. Result = " & $res) ProcessClose("DVDStyler.exe") $res = ProcessWaitClose("DVDStyler.exe") _FileWriteLog($log_filename, "Waiting for the DVDStyler.exe process to close. Result = " & $res) ;------------------------------------------------------------------ ; Import the menu with PGCEdit ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Importing the menu with PgcEdit.", 30) if $menu_exists Then $menu_import_next_win_title = "PgcEdit: Import Menu" Else $menu_import_next_win_title = "Select the IFO file with the menu to import" EndIf Do SendKeepActive("PgcEdit -") $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) $res = ControlSend("PgcEdit -", "", "", "{ESC}") _FileWriteLog($log_filename, "Sending {ESC} to the ""PgcEdit -"" window . Result = " & $res) $res = ControlSend("PgcEdit -", "", "", $pgcedit_import_menu_keys) _FileWriteLog($log_filename, "Sending " & $pgcedit_import_menu_keys & " to the ""PgcEdit -"" window . Result = " & $res) sleep($delay) until WinExists($menu_import_next_win_title) = True if $menu_exists Then $res = WinWait("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = WinActivate("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = ControlFocus("PgcEdit: Import Menu", "", "[CLASS:Button; INSTANCE:2]") _FileWriteLog($log_filename, "Clicking ""PgcEdit: Import Menu"" window ""Yes"" button. Result = " & $res) EndIf $res = WinWait("Select the IFO file with the menu to import") _FileWriteLog($log_filename, "Waiting for the ""Select the IFO file with the menu to import"" window. Result = " & $res) $res = WinActivate("Select the IFO file with the menu to import") _FileWriteLog($log_filename, "Activating the ""Select the IFO file with the menu to import"" window. Result = " & $res) $res = ControlSetText("Select the IFO file with the menu to import", "", "[CLASS:Edit; INSTANCE:1]", $dvdstyler_output_path & "\dvd\VIDEO_TS\VTS_01_0.IFO") _FileWriteLog($log_filename, "Setting the text of the ""Select the IFO file with the menu to import"" window ""Path"" field. Result = " & $res) while WinExists("Select the IFO file with the menu to import") $res = ControlClick("Select the IFO file with the menu to import", "", "[CLASS:Button; INSTANCE:2]") WEnd _FileWriteLog($log_filename, "Clicking ""Select the IFO file with the menu to import"" window ""OK"" button. Result = " & $res) $res = WinWait("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = WinActivate("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = ControlFocus("PgcEdit: Import Menu", "", "[CLASS:Button; INSTANCE:2]") _FileWriteLog($log_filename, "Clicking ""PgcEdit: Import Menu"" window ""Yes"" button. Result = " & $res) if $pgcedit_version = 8.4 Then $res = WinWait("PgcEdit: Button Information") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Button Information"" window. Result = " & $res) $res = WinActivate("PgcEdit: Button Information") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Button Information"" window. Result = " & $res) $res = ControlFocus("PgcEdit: Button Information", "", "[CLASS:Button; INSTANCE:2]") _FileWriteLog($log_filename, "Clicking ""PgcEdit: Button Information"" window ""Yes"" button. Result = " & $res) EndIf $res = WinWait("PgcEdit: Save DVD") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Save DVD"" window. Result = " & $res) $res = WinActivate("PgcEdit: Save DVD") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Save DVD"" window. Result = " & $res) $res = ControlFocus("PgcEdit: Save DVD", "", "[CLASS:Button; INSTANCE:1]") _FileWriteLog($log_filename, "Clicking ""PgcEdit: Save DVD"" window ""OK"" button. Result = " & $res) $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) $res = WinWaitNotActive("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window to not be active. Result = " & $res) ; Need to loop for the "Find BOVs..." window because on large DVDs it can take some time to appear. Do if WinExists("Find BOVs (Buttons Over Video") Then $res = WinClose("Find BOVs (Buttons Over Video") _FileWriteLog($log_filename, "Closing the ""Find BOVs (Buttons Over Video"" window. Result = " & $res) EndIf Until WinExists("PgcEdit: Import Menu") if $pgcedit_version > 8.4 Then $res = WinWait("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = WinActivate("PgcEdit: Import Menu") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Import Menu"" window. Result = " & $res) $res = ControlFocus("PgcEdit: Import Menu", "", "[CLASS:Button; INSTANCE:1]") _FileWriteLog($log_filename, "Clicking ""PgcEdit: Import Menu"" window ""OK"" button. Result = " & $res) EndIf $res = DirRemove($dvdstyler_output_path, 1) _FileWriteLog($log_filename, "Removing the directory """ & $dvdstyler_output_path & """. Result = " & $res) ;------------------------------------------------------------------ ; Create the new PGC commands (as import files) ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Creating the new PGC commands.", 30) $res = DirCreate($pgc_commands_path) _FileWriteLog($log_filename, "Creating the directory """ & $pgc_commands_path & """. Result = " & $res) ; VMG First-Play PGC $handle = FileOpen($pgc_commands_path & "\vmg_fp.pgc", 2) _FileWriteLog($log_filename, "Creating the file """ & $pgc_commands_path & "\vmg_fp.pgc" & """. Result = " & $handle) ; If there is only one titleset if $pgcdict.item("num VTSs") = 1 Then ConsoleWrite($pgc_commands_path & "\vmg_fp.pgc") ; Jump immediately to the titleset menu following the main menu. FileWrite($handle, "{* pre} {30 06 00 " & Hex(($num_main_menus + 1), 2) & " 00 C0 00 00} {* post} {* cell}") Else ; else jump to the main menu FileWrite($handle, "{* pre} {30 06 00 00 00 42 00 00} {* post} {* cell}") EndIf $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $pgc_commands_path & "\vmg_fp.pgc" & """. Result = " & $res) ; VMGM menus for $menu_num = 1 to $num_menus $handle = FileOpen($pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc", 2) _FileWriteLog($log_filename, "Creating the file """ & $pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc" & """. Result = " & $handle) FileWrite($handle, "{* pre} {56 00 00 00 04 00 00 00} {* post} {30 01 00 00 00 00 00 00} {* cell}") $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc" & """. Result = " & $res) Next ; VMGM dummy menu $handle = FileOpen($pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc", 2) _FileWriteLog($log_filename, "Creating the file """ & $pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc" & """. Result = " & $handle) FileWrite($handle, "{* pre} {61 00 00 0e 00 0f 00 00} {71 00 00 0f 00 00 00 00} {20 a4 00 0e 7b 00 00 01} {20 a4 00 0e 7f 00 00 01} {20 a4 00 0e 01 00 00 01} {71 00 00 0d 81 00 00 00} {30 23 00 00 00 01 0e 0d} {71 00 00 0d 81 01 00 00} {30 25 00 01 00 01 0e 0d} {20 04 00 00 00 00 00 01} {* post} {* cell}") $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $pgc_commands_path & "\vmg_menu1_" & StringFormat("%02s", $menu_num) & ".pgc" & """. Result = " & $res) ; Titles for $titleset_num = 1 to $pgcdict.item("num VTSs") for $titlesettitle_num = 1 to ($pgcdict.item("VTS " & $titleset_num & " num TTNs") - 1) $handle = FileOpen($pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc", 2) _FileWriteLog($log_filename, "Creating the file """ & $pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc" & """. Result = " & $handle) FileWrite($handle, "{* pre} {* post} {30 03 00 00 00 " & Hex(($titlesettitle_num + 1), 2) & " 00 00} {* cell}") $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc" & """. Result = " & $res) Next ; The final title in the titleset points back to the main menu. $handle = FileOpen($pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc", 2) _FileWriteLog($log_filename, "Creating the file """ & $pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc" & """. Result = " & $handle) ; If there is only one titleset if $pgcdict.item("num VTSs") = 1 Then ; Jump immediately to the titleset menu following the main menu. FileWrite($handle, "{* pre} {* post} {30 08 00 " & Hex(($num_main_menus + 1), 2) & " 01 C0 00 00} {* cell}") Else ; else jump to the main menu FileWrite($handle, "{* pre} {* post} {30 08 00 00 01 42 00 00} {* cell}") EndIf $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $pgc_commands_path & "\vts" & StringFormat("%02s", $titleset_num) & "_ttn" & StringFormat("%02s", $titlesettitle_num) & ".pgc" & """. Result = " & $res) Next ;Exit ;------------------------------------------------------------------ ; Import the new PGC commands ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Importing the new PGC commands.", 30) $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) SendKeepActive("PgcEdit -") $res = ControlSend("PgcEdit -", "", "", $pgcedit_import_all_commands_keys) _FileWriteLog($log_filename, "Sending """ & $pgcedit_import_all_commands_keys & """ to the ""PgcEdit -"" window . Result = " & $res) $res = WinWait("PgcEdit: Import All PGC commands") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Import All PGC commands"" window. Result = " & $res) $res = WinActivate("PgcEdit: Import All PGC commands") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Import All PGC commands"" window. Result = " & $res) $res = ControlSend("PgcEdit: Import All PGC commands", "", "", "{ENTER}") _FileWriteLog($log_filename, "Sending ""{ENTER}"" to the ""PgcEdit: Import All PGC commands"" window . Result = " & $res) $res = WinWait("Browse for Folder") _FileWriteLog($log_filename, "Waiting for the ""Browse for Folder"" window. Result = " & $res) $res = WinActivate("Browse for Folder") _FileWriteLog($log_filename, "Activating the ""Browse for Folder"" window. Result = " & $res) $res = ControlSetText("Browse for Folder", "", 14148, $pgc_commands_path) _FileWriteLog($log_filename, "Setting the text of the ""Browse for Folder"" window ""Path"" field to """ & $pgc_commands_path & """. Result = " & $res) while WinExists("Browse for Folder") $res = ControlClick("Browse for Folder", "", 1) WEnd _FileWriteLog($log_filename, "Clicking ""Browse for Folder"" window ""OK"" button. Result = " & $res) ;------------------------------------------------------------------ ; Save the DVD and shutdown PgcEdit ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer is controlling PgcEdit", "Please avoid using the mouse and keyboard." & @CRLF & @CRLF & "Saving the DVD and closing PgcEdit.", 30) $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) SendKeepActive("PgcEdit -") $res = ControlSend("PgcEdit -", "", "", "{CTRLDOWN}s{CTRLUP}") _FileWriteLog($log_filename, "Sending ""{CTRLDOWN}s{CTRLUP}"" to the ""PgcEdit -"" window . Result = " & $res) $res = WinWait("PgcEdit: Save DVD") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit: Save DVD"" window. Result = " & $res) $res = WinActivate("PgcEdit: Save DVD") _FileWriteLog($log_filename, "Activating the ""PgcEdit: Save DVD"" window. Result = " & $res) SendKeepActive("PgcEdit: Save DVD") $res = ControlSend("PgcEdit: Save DVD", "", "", "{ENTER}") _FileWriteLog($log_filename, "Sending ""{ENTER}"" to the ""PgcEdit: Save DVD"" window . Result = " & $res) $res = WinWait("PgcEdit -") _FileWriteLog($log_filename, "Waiting for the ""PgcEdit -"" window. Result = " & $res) $res = WinActivate("PgcEdit -") _FileWriteLog($log_filename, "Activating the ""PgcEdit -"" window. Result = " & $res) ProcessClose("PgcEdit.exe") $res = ProcessWaitClose("PgcEdit.exe") _FileWriteLog($log_filename, "Waiting for the PgcEdit.exe process to close. Result = " & $res) $res = DirRemove($pgc_commands_path, 1) _FileWriteLog($log_filename, "Removing the """ & $pgc_commands_path & """ folder. Result = " & $res) $res = DirRemove(GUICtrlRead($videotsedit) & "\PgcEdit_backup", 1) _FileWriteLog($log_filename, "Removing the """ & GUICtrlRead($videotsedit) & "\PgcEdit_backup" & """ folder. Result = " & $res) ;------------------------------------------------------------------ ; Assign commands to the menu buttons ;------------------------------------------------------------------ TrayTip("Rapid Menu Writer", "Please wait." & @CRLF & @CRLF & "Updating the DVD menu button commands.", 30) $vts_vob_filename = GUICtrlRead($videotsedit) & "\VIDEO_TS.VOB" ; READ THE DVD MENU (VIDEO_TS.VOB) $handle = FileOpen($vts_vob_filename, 16) _FileWriteLog($log_filename, "Opening the file """ & $vts_vob_filename & """. Result = " & $handle) $tmp = FileRead($handle) $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $vts_vob_filename & """. Result = " & $res) ; Split the VOB into each menu (VMGM) ; $vmgm_hex[0] = number of VMGMs (+1) ; $vmgm_hex[1] = hex identifier (0x) ; $vmgm_hex[2+] = VMGMs $vmgm_hex = StringSplit($tmp, "000001BA4400040004", 1) _FileWriteLog($log_filename, "Splitting the file using delimiter ""000001BA4400040004"". Result = " & $vmgm_hex[0]) ; ; MAIN MENU Page(s) ; Note:- more than one if the number of titlesets exceeds 12. ; $num_menus = 1 $vts_num = 0 _FileWriteLog($log_filename, "$pgcdict.item(""num VTSs"") = " & $pgcdict.item("num VTSs")) $num_main_menus = Ceiling($pgcdict.item("num VTSs") / 12) _FileWriteLog($log_filename, "$num_main_menus = " & $num_main_menus) $vmgm_num = $num_main_menus + 1 $title_num = 1 ; For each main menu page. for $main_menu_num = 1 to $num_main_menus _FileWriteLog($log_filename, "$main_menu_num = " & $main_menu_num) $num_vts_in_curr_page = _Min(12, $pgcdict.item("num VTSs") - (($main_menu_num-1) * 12)) _FileWriteLog($log_filename, "$num_vts_in_curr_page = " & $num_vts_in_curr_page) $button_pos = 1 ; For each (titleset) button in the main menu. for $i = 1 to $num_vts_in_curr_page _FileWriteLog($log_filename, "$i = " & $i) $vts_num = $vts_num + 1 _FileWriteLog($log_filename, "$vts_num = " & $vts_num) ; Titleset button ; The hex code for a titleset button to replace is "NNXXXXXX3003000000010000", ; where "NN" is the two digit button number. ; The replacement hex code is for a "Jump to Title" command. $button_pos = StringInStr($vmgm_hex[$main_menu_num+1], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$main_menu_num+1], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "3002000000" & Hex($title_num, 2) & "0000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$main_menu_num+1] = StringReplace($vmgm_hex[$main_menu_num+1], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & ($main_menu_num+1) & "]. Number of replacements = " & @extended) $title_num = $title_num + $pgcdict.item("VTS " & $vts_num & " num TTNs") _FileWriteLog($log_filename, "$title_num = " & $title_num) ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then ; If the number of titles in the titleset is greater than 1 (then it's worth adding a titleset menu) _FileWriteLog($log_filename, "$pgcdict.item(""VTS "" & $vts_num & "" num TTNs"") = " & $pgcdict.item("VTS " & $vts_num & " num TTNs")) if $pgcdict.item("VTS " & $vts_num & " num TTNs") > 1 Then ; Titleset menu button ; The hex code for a titleset menu button to replace is "NNXXXX3003000000010000", ; where "NN" is the two digit button number. ; The replacement hex code is for a "Jump to VMGM" command. $button_pos = StringInStr($vmgm_hex[$main_menu_num+1], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$main_menu_num+1], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "300600" & Hex($vmgm_num, 2) & "00C00000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$main_menu_num+1] = StringReplace($vmgm_hex[$main_menu_num+1], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & ($main_menu_num+1) & "]. Number of replacements = " & @extended) EndIf EndIf $num_titleset_menu_pages = Ceiling($pgcdict.item("VTS " & $vts_num & " num TTNs") / 12) _FileWriteLog($log_filename, "$num_titleset_menu_pages = " & $num_titleset_menu_pages) $vmgm_num = $vmgm_num + $num_titleset_menu_pages _FileWriteLog($log_filename, "$vmgm_num = " & $vmgm_num) Next ; Left arrow and Back label if $main_menu_num > 1 Then $back_vmgm_num = $main_menu_num - 1 _FileWriteLog($log_filename, "$back_vmgm_num = " & $back_vmgm_num) $button_pos = StringInStr($vmgm_hex[$main_menu_num+1], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$main_menu_num+1], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "300600" & Hex($back_vmgm_num, 2) & "00C00000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$main_menu_num+1] = StringReplace($vmgm_hex[$main_menu_num+1], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & ($main_menu_num+1) & "]. Number of replacements = " & @extended) EndIf ; Right arrow and Next label if $main_menu_num < $num_main_menus Then $next_vmgm_num = $main_menu_num + 1 _FileWriteLog($log_filename, "$next_vmgm_num = " & $next_vmgm_num) $button_pos = StringInStr($vmgm_hex[$main_menu_num+1], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$main_menu_num+1], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "300600" & Hex($next_vmgm_num, 2) & "00C00000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$main_menu_num+1] = StringReplace($vmgm_hex[$main_menu_num+1], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & ($main_menu_num+1) & "]. Number of replacements = " & @extended) EndIf Next ; ; TITLESET MENU Page(s) ; Note:- more than one if the number of titles exceeds 12. ; ; If title menus are requested if GUICtrlRead($titlemenucheckbox) = $GUI_CHECKED Then $title_num = 1 $vts_num = 0 $vmgm_num = $num_main_menus + 2 _FileWriteLog($log_filename, "$vmgm_num = " & $vmgm_num) ; For each titleset menu. ; Titleset menus begin after the main menus. for $i = 1 to $pgcdict.item("num VTSs") _FileWriteLog($log_filename, "$i = " & $i) _FileWriteLog($log_filename, "$pgcdict.item(""VTS "" & $i & "" num TTNs"") = " & $pgcdict.item("VTS " & $i & " num TTNs")) $num_titleset_menu_pages = Ceiling($pgcdict.item("VTS " & $i & " num TTNs") / 12) _FileWriteLog($log_filename, "$num_titleset_menu_pages = " & $num_titleset_menu_pages) ; For each titleset menu page. ; There will be more than one page if the number of titles in a titleset menu exceeds 12. for $titleset_menu_page_num = 1 to $num_titleset_menu_pages _FileWriteLog($log_filename, "$titleset_menu_page_num = " & $titleset_menu_page_num) $num_titles_in_curr_page = _Min(12, $pgcdict.item("VTS " & $i & " num TTNs") - (($titleset_menu_page_num-1) * 12)) _FileWriteLog($log_filename, "$num_titles_in_curr_page = " & $num_titles_in_curr_page) $num_menus = $num_menus + 1 _FileWriteLog($log_filename, "$num_menus = " & $num_menus) ; For each (title) button in the titleset menu. for $button_num = 1 to $num_titles_in_curr_page _FileWriteLog($log_filename, "$button_num = " & $button_num) ; Title button ; The hex code for a titleset button to replace is "NNXXXXXX3003000000010000", ; where "NN" is the two digit button number. ; The replacement hex code is for a "Jump to Title" command. $button_pos = StringInStr($vmgm_hex[$vmgm_num], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$vmgm_num], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "3002000000" & Hex($title_num, 2) & "0000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$vmgm_num] = StringReplace($vmgm_hex[$vmgm_num], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & $vmgm_num & "]. Number of replacements = " & @extended) $title_num = $title_num + 1 _FileWriteLog($log_filename, "$title_num = " & $title_num) Next ; Back button if $titleset_menu_page_num > 1 Then $back_vmgm_num = $vmgm_num - 2 _FileWriteLog($log_filename, "$back_vmgm_num = " & $back_vmgm_num) $button_pos = StringInStr($vmgm_hex[$vmgm_num], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$vmgm_num], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "300600" & Hex($back_vmgm_num, 2) & "00C00000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$vmgm_num] = StringReplace($vmgm_hex[$vmgm_num], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & $vmgm_num & "]. Number of replacements = " & @extended) EndIf ; If more than one titleset exists if $pgcdict.item("num VTSs") > 1 Then ; Menu button (to return to the MAIN MENU) ; The hex code for a titleset button to replace is "NNXXXXXX3003000000010000", ; where "NN" is the two digit button number. ; The replacement hex code is for a "Jump to Title" command. $button_pos = StringInStr($vmgm_hex[$vmgm_num], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$vmgm_num], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "3006000000420000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$vmgm_num] = StringReplace($vmgm_hex[$vmgm_num], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & $vmgm_num & "]. Number of replacements = " & @extended) EndIf ; Next button if $titleset_menu_page_num < $num_titleset_menu_pages Then $next_vmgm_num = $vmgm_num _FileWriteLog($log_filename, "$next_vmgm_num = " & $next_vmgm_num) $button_pos = StringInStr($vmgm_hex[$vmgm_num], "3003000000010000") - 8 _FileWriteLog($log_filename, "$button_pos = " & $button_pos) $button_hex = StringMid($vmgm_hex[$vmgm_num], $button_pos, 24) _FileWriteLog($log_filename, "$button_hex = " & $button_hex) $new_button_hex = StringLeft($button_hex, 8) & "300600" & Hex($next_vmgm_num, 2) & "00C00000" _FileWriteLog($log_filename, "$new_button_hex = " & $new_button_hex) ; replace all instances of it with a new command $vmgm_hex[$vmgm_num] = StringReplace($vmgm_hex[$vmgm_num], $button_hex, $new_button_hex) _FileWriteLog($log_filename, "Replacing " & $button_hex & " with " & $new_button_hex & " in $vmgm_hex[" & $vmgm_num & "]. Number of replacements = " & @extended) EndIf $vmgm_num = $vmgm_num + 1 _FileWriteLog($log_filename, "$vmgm_num = " & $vmgm_num) Next Next EndIf ; WRITE THE DVD MENU (VIDEO_TS.VOB) $handle = FileOpen($vts_vob_filename, 18) _FileWriteLog($log_filename, "Opening the file """ & $vts_vob_filename & """. Result = " & $handle) ; write each menu back to the file. for $i = 2 to $vmgm_hex[0] FileWrite($handle, "0x000001BA4400040004" & $vmgm_hex[$i]) _FileWriteLog($log_filename, "Writing $vmgm_hex[" & $i & "].") Next $res = FileClose($handle) _FileWriteLog($log_filename, "Closing the file """ & $vts_vob_filename & """. Result = " & $res) ;------------------------------------------------------------------ ; Update the Rapid Menu Writer GUI ;------------------------------------------------------------------ GUICtrlSetPos($msg1label, $std_button_gap, 30, $main_gui_width - ($std_button_gap * 2), 50) GUICtrlSetData($msg1label, "Finished!" & @crlf & @crlf & _ "The whole process took " & Round((TimerDiff($start_time) / 1000 / 60), 1) & " minutes.") _FileWriteLog($log_filename, "Finished!") _FileWriteLog($log_filename, "The whole process took " & Round((TimerDiff($start_time) / 1000 / 60), 1) & " minutes.") GUICtrlSetState($opendvdbutton, $GUI_SHOW) GUICtrlSetState($openpgceditbutton, $GUI_SHOW) GUICtrlSetState($maindonatebutton, $GUI_SHOW) GUICtrlSetState($maindonatebutton, $GUI_FOCUS) GUICtrlSetState($backbutton, $GUI_DISABLE) GUICtrlSetState($nextbutton, $GUI_DISABLE) GUICtrlSetData($cancelbutton, "&Close") Else $step_num = $step_num - 1 ProcessClose("DVDStyler.exe") $res = ProcessWaitClose("DVDStyler.exe") _FileWriteLog($log_filename, "Waiting for the DVDStyler.exe process to close. Result = " & $res) EndIf TrayTip("Rapid Menu Writer", "", 0) $res = GUISetState(@SW_RESTORE) _FileWriteLog($log_filename, "Restoring the ""Rapid Menu Writer"" window. Result = " & $res) EndIf GUICtrlSetData($nextbutton, "&Next >") EndIf if $msg = $videotsselectbutton Then $videotspath = FileSelectFolder("Select the VIDEO_TS folder", "") if StringCompare($videotspath, "") <> 0 Then GUICtrlSetData($videotsedit, $videotspath) EndIf EndIf if $msg = $opendvdbutton Then ; Validation of required executables if FileExists(GUICtrlRead($dvdplayeredit)) = false then MsgBox(262160, "Rapid Menu Writer - Error", "Could not find the following DVD Player on your computer:" & @CRLF & @CRLF & _ GUICtrlRead($dvdplayeredit) & @CRLF & @CRLF & _ "Follow these steps to fix this problem:" & @CRLF & @CRLF & _ "1. Click OK below to close this message." & @CRLF & _ "2. In the Rapid Menu Writer window, click the Tools menu, and then Options." & @CRLF & _ "3. In the Rapid Menu Writer - Options window, type or select the path to the DVD Player's EXE file." & @CRLF & _ "4. Click Close, and then try clicking the Play DVD button again.") Else $res = ShellExecute(GUICtrlRead($dvdplayeredit), """" & GUICtrlRead($videotsedit) & "\VIDEO_TS.IFO""") _FileWriteLog($log_filename, "Executing """ & GUICtrlRead($dvdplayeredit) & " """ & GUICtrlRead($videotsedit) & "\VIDEO_TS.IFO"""". Result = " & $res) EndIf EndIf if $msg = $openpgceditbutton Then $res = ShellExecute(GUICtrlRead($pgceditedit), """" & GUICtrlRead($videotsedit) & """") _FileWriteLog($log_filename, "Executing """ & GUICtrlRead($pgceditedit) & " """ & GUICtrlRead($videotsedit) & """"". Result = " & $res) EndIf if $msg = $maindonatebutton Then ShellExecute($default_browser_path, "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ZW6JVU9HJ4TG4&lc=AU&item_name=Rapid%20Menu%20Writer¤cy_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted") EndIf If $msg = $GUI_EVENT_CLOSE or $msg = $exititem or $msg = $cancelbutton Then ; If the Main GUI was closed, then exit the script if $curr_gui = $main_gui Then ExitLoop Else ; Other GUIs are disabled, and the Main GUI enabled. GUISetState(@SW_HIDE) $curr_gui = $main_gui GUISwitch($curr_gui) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) EndIf EndIf $msg = GUIGetMsg() WEnd GUIDelete() Func hide_controls() GUICtrlSetState($headingpic, $GUI_HIDE) GUICtrlSetState($videotsedit, $GUI_HIDE) GUICtrlSetState($videotsselectbutton, $GUI_HIDE) GUICtrlSetState($titlesetbuttonslabel, $GUI_HIDE) GUICtrlSetState($vtstlist, $GUI_HIDE) GUICtrlSetState($titlebuttonslabel, $GUI_HIDE) GUICtrlSetState($ttnlist, $GUI_HIDE) GUICtrlSetState($titlemenucheckbox, $GUI_HIDE) GUICtrlSetState($renamebutton, $GUI_HIDE) GUICtrlSetState($previewbutton, $GUI_HIDE) GUICtrlSetState($opendvdbutton, $GUI_HIDE) GUICtrlSetState($openpgceditbutton, $GUI_HIDE) GUICtrlSetState($maindonatebutton, $GUI_HIDE) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2, $tInfo $hWndListView = $vtstlist If Not IsHWnd($vtstlist) Then $hWndListView = GUICtrlGetHandle($vtstlist) $hWndListView2 = $ttnlist If Not IsHWnd($ttnlist) Then $hWndListView2 = GUICtrlGetHandle($ttnlist) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom ; VTS list Case $hWndListView Switch $iCode Case $LVN_ENDLABELEDIT, $LVN_ENDLABELEDITW ; The end of label editing for an item return True Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $listview_clicked = "vts" Case $LVN_ITEMCHANGED ; An item has changed $listview_clicked = "vts" ; This will catch both mouse and keyboard selections of an item. $curr_item_num = $curr_vtst - 1 $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $new_item_num = DllStructGetData($tInfo, "Item") ; If the currently selected item has moved to a new item (by mouse or keyboard) if $curr_item_num <> $new_item_num Then ; Store the current list of titles for $i = 0 to ($pgcdict.item("VTS " & $curr_vtst & " num TTNs") - 1) $pgcdict.item("VTS " & $curr_vtst & " TTN " & ($i+1) & " label") = _GUICtrlListView_GetItemText($ttnlist, $i) Next ; Get the current item selected $curr_vtst = $new_item_num + 1 ; Wipe the title list $res = _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ttnlist)) ; Create the title list for the titleset selected for $i = 0 to ($pgcdict.item("VTS " & $curr_vtst & " num TTNs") - 1) _GUICtrlListView_AddItem($ttnlist, $pgcdict.item("VTS " & $curr_vtst & " TTN " & ($i+1) & " label")) Next EndIf Case $LVN_KEYDOWN ; A key has been pressed $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam) ; If F2 is pressed, rename the item if DllStructGetData($tInfo, "VKey") = 3932273 Then _GUICtrlListView_EditLabel($vtstlist, _GUICtrlListView_GetSelectionMark($vtstlist)) EndIf ; If right arrow is pressed, move focus to the TTN list if DllStructGetData($tInfo, "VKey") = 21823527 Then $listview_clicked = "ttn" GUICtrlSetState($ttnlist, $GUI_FOCUS) _GUICtrlListView_SetItemSelected($ttnlist, 0, True, True) EndIf EndSwitch ; TTN list Case $hWndListView2 Switch $iCode Case $LVN_ENDLABELEDIT, $LVN_ENDLABELEDITW ; The end of label editing for an item return True Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $listview_clicked = "ttn" Case $LVN_KEYDOWN ; A key has been pressed $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam) ; If F2 is pressed, rename the item if DllStructGetData($tInfo, "VKey") = 3932273 Then _GUICtrlListView_EditLabel($ttnlist, _GUICtrlListView_GetSelectionMark($ttnlist)) EndIf ; If left arrow is pressed, move focus to the VTS list if DllStructGetData($tInfo, "VKey") = 21692453 Then $listview_clicked = "vts" GUICtrlSetState($vtstlist, $GUI_FOCUS) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY