Created
May 17, 2026 12:49
-
-
Save EncodeTheCode/f2f06723fdde20a53ca599c49a21910f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <GUIConstantsEx.au3> | |
| #include <WindowsConstants.au3> | |
| #include <GUIListView.au3> | |
| #include <File.au3> | |
| #include <GUITab.au3> | |
| #include <Array.au3> | |
| Global $C1 = "Game Title", $C2 = "Game ID", $C3 = "Serial", $C4 = "Release Date", $C5 = "Version" | |
| Global $Columns = String($C1 & "|" & $C2 & "|" & $C3 & "|" & $C4 & "|" & $C5) | |
| ; --- Toast settings you can customize --- | |
| Global $g_iToastWidth = 360 | |
| Global $g_iToastHeight = 92 | |
| Global $g_iToastRadius = 18 | |
| Global $g_iToastStayMs = 6000 | |
| Global $g_iToastFadeInMs = 440 | |
| Global $g_iToastFadeOutMs = 1350 | |
| Global $g_iToastEdgePad = 9 | |
| Global $g_bToastRunning = False | |
| Global $g_hToast = 0 | |
| ; Create GUI and Tab Control | |
| Global $hAppT = "List View Manager" | |
| Global $hGUI = GUICreate("PlayStation One - Game Library - " & $hAppT, 850, 650) | |
| Global $hTab = GUICtrlCreateTab(10, 10, 830, 630) | |
| Global $hTab1 = GUICtrlCreateTabItem("PAL") | |
| Global $hListView1 = GUICtrlCreateListView($Columns, 20, 40, 808, 580, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView1, $LVS_REPORT) | |
| GUICtrlCreateTabItem("NTSC-U (America)") | |
| Global $hListView2 = GUICtrlCreateListView($Columns, 20, 40, 808, 580, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView2, $LVS_REPORT) | |
| GUICtrlCreateTabItem("NTSC-J (Asia/Japan)") | |
| Global $hListView3 = GUICtrlCreateListView($Columns, 20, 40, 808, 580, $LVS_SHOWSELALWAYS) | |
| GUICtrlSetStyle($hListView3, $LVS_REPORT) | |
| GUICtrlCreateTabItem("") | |
| Global $btnDelete1 = GUICtrlCreateButton("Delete Items on Tab 1", 265, 12, 150, 19) | |
| Global $btnDelete2 = GUICtrlCreateButton("Delete Items on Tab 2", 418, 12, 150, 19) | |
| Global $btnDelete3 = GUICtrlCreateButton("Delete Items on Tab 3", 571, 12, 150, 19) | |
| Global $g_aSortOrder[3][5] | |
| For $iLV = 0 To 2 | |
| For $iCol = 0 To 4 | |
| $g_aSortOrder[$iLV][$iCol] = 0 | |
| Next | |
| Next | |
| GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") | |
| GUISetState(@SW_SHOW, $hGUI) | |
| Func _ReadCSV($sFilePath, $hListView) | |
| Local $aLines, $aFields, $iIndex, $iRow | |
| $aLines = FileReadToArray($sFilePath) | |
| If @error Then Return False | |
| _GUICtrlListView_DeleteAllItems($hListView) | |
| For $iIndex = 0 To UBound($aLines) - 1 | |
| If StringStripWS($aLines[$iIndex], 3) = "" Then ContinueLoop | |
| $aFields = StringSplit($aLines[$iIndex], "|") | |
| If $aFields[0] < 1 Then ContinueLoop | |
| $iRow = _GUICtrlListView_AddItem($hListView, $aFields[1]) | |
| For $i = 2 To $aFields[0] | |
| _GUICtrlListView_AddSubItem($hListView, $iRow, $aFields[$i], $i - 1) | |
| Next | |
| Next | |
| Return True | |
| EndFunc | |
| Func _GUICtrlListView_CreateArray($hListView) | |
| Local $iItemCount = _GUICtrlListView_GetItemCount($hListView) | |
| If $iItemCount <= 0 Then Return SetError(1, 0, 0) | |
| Local $aItems[$iItemCount][5] | |
| For $i = 0 To $iItemCount - 1 | |
| $aItems[$i][0] = _GUICtrlListView_GetItemText($hListView, $i, 0) | |
| For $j = 1 To 4 | |
| $aItems[$i][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) | |
| Next | |
| Next | |
| Return $aItems | |
| EndFunc | |
| Func __SwapRows(ByRef $aData, $iA, $iB) | |
| Local $aTemp[5] | |
| For $i = 0 To 4 | |
| $aTemp[$i] = $aData[$iA][$i] | |
| $aData[$iA][$i] = $aData[$iB][$i] | |
| $aData[$iB][$i] = $aTemp[$i] | |
| Next | |
| EndFunc | |
| Func __QuickSort2D(ByRef $aData, $iLeft, $iRight, $iColumn, $bDescending) | |
| Local $i = $iLeft, $j = $iRight | |
| Local $sPivot = $aData[Int(($iLeft + $iRight) / 2)][$iColumn] | |
| Local $bAsc = Not $bDescending | |
| While $i <= $j | |
| If $bAsc Then | |
| While StringCompare($aData[$i][$iColumn], $sPivot, 0) < 0 | |
| $i += 1 | |
| WEnd | |
| While StringCompare($aData[$j][$iColumn], $sPivot, 0) > 0 | |
| $j -= 1 | |
| WEnd | |
| Else | |
| While StringCompare($aData[$i][$iColumn], $sPivot, 0) > 0 | |
| $i += 1 | |
| WEnd | |
| While StringCompare($aData[$j][$iColumn], $sPivot, 0) < 0 | |
| $j -= 1 | |
| WEnd | |
| EndIf | |
| If $i <= $j Then | |
| If $i <> $j Then __SwapRows($aData, $i, $j) | |
| $i += 1 | |
| $j -= 1 | |
| EndIf | |
| WEnd | |
| If $iLeft < $j Then __QuickSort2D($aData, $iLeft, $j, $iColumn, $bDescending) | |
| If $i < $iRight Then __QuickSort2D($aData, $i, $iRight, $iColumn, $bDescending) | |
| EndFunc | |
| Func _SortListView($hListView, $iColumn, $bDescending) | |
| Local $aItems = _GUICtrlListView_CreateArray($hListView) | |
| If @error Then Return | |
| __QuickSort2D($aItems, 0, UBound($aItems) - 1, $iColumn, $bDescending) | |
| _GUICtrlListView_DeleteAllItems($hListView) | |
| For $i = 0 To UBound($aItems) - 1 | |
| Local $iRow = _GUICtrlListView_AddItem($hListView, $aItems[$i][0]) | |
| For $j = 1 To 4 | |
| _GUICtrlListView_AddSubItem($hListView, $iRow, $aItems[$i][$j], $j) | |
| Next | |
| Next | |
| EndFunc | |
| Func _GetWorkAreaRect() | |
| Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") | |
| DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 0x0030, "uint", 0, "ptr", DllStructGetPtr($tRect), "uint", 0) | |
| Return $tRect | |
| EndFunc | |
| Func _SetRoundedCorners($hWnd, $iWidth, $iHeight, $iRadius) | |
| Local $aRgn = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", _ | |
| "int", 0, "int", 0, "int", $iWidth + 1, "int", $iHeight + 1, _ | |
| "int", $iRadius, "int", $iRadius) | |
| If Not @error Then | |
| DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hWnd, "handle", $aRgn[0], "int", True) | |
| EndIf | |
| EndFunc | |
| ; =========================== | |
| ; 🔥 FIX 1: allow GUI exit during fade | |
| ; =========================== | |
| Func _ToastFade($hWnd, $iFrom, $iTo, $iDuration) | |
| Local $iSteps = 20 | |
| Local $iDelay = Int($iDuration / $iSteps) | |
| For $i = 0 To $iSteps | |
| Local $iAlpha = Int($iFrom + (($iTo - $iFrom) * $i / $iSteps)) | |
| WinSetTrans($hWnd, "", $iAlpha) | |
| ; 🔥 ADDED: allow exit event processing | |
| If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit | |
| Sleep($iDelay) | |
| If Not WinExists($hWnd) Then ExitLoop | |
| Next | |
| EndFunc | |
| ; =========================== | |
| ; 🔥 FIX 2: allow exit during toast hold | |
| ; =========================== | |
| Func _ShowToast($sText) | |
| If $g_bToastRunning Then Return | |
| $g_bToastRunning = True | |
| Local $tWork = _GetWorkAreaRect() | |
| Local $iLeft = DllStructGetData($tWork, "Right") - $g_iToastWidth - $g_iToastEdgePad | |
| Local $iTop = DllStructGetData($tWork, "Bottom") - $g_iToastHeight - $g_iToastEdgePad | |
| $g_hToast = GUICreate("", $g_iToastWidth, $g_iToastHeight, $iLeft, $iTop, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_LAYERED)) | |
| GUISetBkColor(0x1E1E1E, $g_hToast) | |
| Local $idLabel = GUICtrlCreateLabel($sText, 16, 14, $g_iToastWidth - 32, $g_iToastHeight - 28) | |
| GUICtrlSetColor($idLabel, 0xFFFFFF) | |
| GUISetState(@SW_SHOW, $g_hToast) | |
| _SetRoundedCorners($g_hToast, $g_iToastWidth, $g_iToastHeight, $g_iToastRadius) | |
| WinSetTrans($g_hToast, "", 0) | |
| _ToastFade($g_hToast, 0, 255, $g_iToastFadeInMs) | |
| Local $tStart = TimerInit() | |
| While TimerDiff($tStart) < $g_iToastStayMs | |
| ; 🔥 ADDED: allows main window to close while toast is active | |
| If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit | |
| If Not WinExists($g_hToast) Then ExitLoop | |
| Sleep(50) | |
| WEnd | |
| If WinExists($g_hToast) Then | |
| _ToastFade($g_hToast, 255, 0, $g_iToastFadeOutMs) | |
| GUIDelete($g_hToast) | |
| EndIf | |
| $g_bToastRunning = False | |
| EndFunc | |
| Func SetColumnWidth() | |
| Local $s = [25, 50, 85, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350] | |
| _GUICtrlListView_SetColumnWidth($hListView1, 0, $s[10]) | |
| _GUICtrlListView_SetColumnWidth($hListView1, 1, $s[2]) | |
| _GUICtrlListView_SetColumnWidth($hListView1, 2, $s[8]) | |
| _GUICtrlListView_SetColumnWidth($hListView1, 3, $s[4]) | |
| _GUICtrlListView_SetColumnWidth($hListView1, 4, $s[3]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, 0, $s[10]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, 1, $s[2]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, 2, $s[8]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, 3, $s[4]) | |
| _GUICtrlListView_SetColumnWidth($hListView2, 4, $s[3]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, 0, $s[10]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, 1, $s[2]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, 2, $s[8]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, 3, $s[4]) | |
| _GUICtrlListView_SetColumnWidth($hListView3, 4, $s[3]) | |
| EndFunc | |
| SetColumnWidth() | |
| Local $bPAL = _ReadCSV("PAL.csv", $hListView1) | |
| Local $bNTSCU = _ReadCSV("NTSC-U.csv", $hListView2) | |
| Local $bNTSCJ = _ReadCSV("NTSC-J.csv", $hListView3) | |
| ; Show toast only when all CSVs loaded correctly | |
| If $bPAL And $bNTSCU And $bNTSCJ Then | |
| Local $iPALCount = _GUICtrlListView_GetItemCount($hListView1) | |
| Local $iNTSCUCount = _GUICtrlListView_GetItemCount($hListView2) | |
| Local $iNTSCJCount = _GUICtrlListView_GetItemCount($hListView3) | |
| _ShowToast( _ | |
| $hAppT & @CRLF & _ | |
| "" & @CRLF & _ | |
| "Number of PAL game entries: " & $iPALCount & @CRLF & _ | |
| "Number of NTSC-U game entries: " & $iNTSCUCount & @CRLF & _ | |
| "Number of NTSC-J game entries: " & $iNTSCJCount _ | |
| ) | |
| EndIf | |
| ; FIXED WM_NOTIFY (stable toggle) | |
| Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) | |
| Local $tNMLV = DllStructCreate($tagNMLISTVIEW, $lParam) | |
| If @error Then Return $GUI_RUNDEFMSG | |
| If DllStructGetData($tNMLV, "Code") <> $LVN_COLUMNCLICK Then Return $GUI_RUNDEFMSG | |
| Local $hFrom = DllStructGetData($tNMLV, "hWndFrom") | |
| Local $iColumn = DllStructGetData($tNMLV, "SubItem") | |
| Local $iListIndex = -1 | |
| Switch $hFrom | |
| Case GUICtrlGetHandle($hListView1) | |
| $iListIndex = 0 | |
| Case GUICtrlGetHandle($hListView2) | |
| $iListIndex = 1 | |
| Case GUICtrlGetHandle($hListView3) | |
| $iListIndex = 2 | |
| EndSwitch | |
| If $iListIndex = -1 Then Return $GUI_RUNDEFMSG | |
| If $iColumn < 0 Or $iColumn > 4 Then Return $GUI_RUNDEFMSG | |
| Local $bDesc = $g_aSortOrder[$iListIndex][$iColumn] | |
| _SortListView($hFrom, $iColumn, $bDesc) | |
| $g_aSortOrder[$iListIndex][$iColumn] = Not $bDesc | |
| Return $GUI_RUNDEFMSG | |
| EndFunc | |
| While 1 | |
| Local $msg = GUIGetMsg() | |
| Switch $msg | |
| Case $GUI_EVENT_CLOSE | |
| Exit | |
| Case $btnDelete1 | |
| _GUICtrlListView_DeleteAllItems($hListView1) | |
| Case $btnDelete2 | |
| _GUICtrlListView_DeleteAllItems($hListView2) | |
| Case $btnDelete3 | |
| _GUICtrlListView_DeleteAllItems($hListView3) | |
| EndSwitch | |
| WEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment