Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance,Force
OnExit, UpdateFile
SelectedRow := 0
Gui +AlwaysOnTop +resize
Gui, Show, x100 y100 w500 h500
Gui, Add, ListView, sort -ReadOnly grid x10 y5 h360 w400 +hscroll vMyListView gMyListview, Title
| Year | Image | Movie URL
Gui, Add, Button, section gAddItem, Add Movie Title
Gui, Add, Text, w52 section , Movie Title
Gui, Add, Edit, w100 ys vTitle1 hwndOne
SetEditCueBanner(One, "Title")
Gui, Add, Text, ys, Year
Gui, Add, Edit, w150 ys vYear1 hwndTwo
SetEditCueBanner(Two, "Year")
pathToPic := ""
GUI Add, Button, w65 ys gpushPic, Add Image
Gui, Add, Picture, w65 h100 ys vNewVar hwndThree, %Newvar%
pathToMovie := ""
GUI Add, Button, w65 ys gpushMovie, Select Movie File
Gui, Add, edit, w65 h100 ys vplaymovie hwndFour, %playmovie%
Gui, Add, Button, Hidden Default, CLICK
IconWidth := 2
IconHeight := 50
IconBitDepth := 24 ;
InitialCount := 1 ; The starting Number of Icons available in ImageList
GrowCount := 1
ImageListID := DllCall( "ImageList_Create", Int,IconWidth, Int,IconHeight
, Int,IconBitDepth, Int,InitialCount
, Int,GrowCount )
LV_SetImageList( ImageListID, 1 ) ; 0 for large icons, 1 for small icons
IfExist, MovieList.txt ;Add data from MovieList.txt to ListView
{
;FileCopy, MovieList.txt, MovieList%A_Now%.txt ;incremental backup
Loop, Read, MovieList.txt
{
If (A_index = 1 and SubStr(A_LoopReadLine, 1, 1) = "x")
{
WinPos := A_LoopReadLine
Continue
}
Else
{
Loop, Parse, A_LoopReadLine , CSV
{
RowData%A_Index% := A_LoopField
}
LV_Add("", RowData1,RowData2,RowData3,RowData4)
}
}
}
SizeCols()
Menu, MyContextMenu, Add, Edit, EditItem
Menu, MyContextMenu, Add, Delete, DeleteItem
Menu, Tray, Add, Show MovieList, ShowMovieList
IfExist, MovieList.txt
{
Gui, Show, %WinPos% , MovieList
}
Else
{
WinGetPos,X1,Y1,W1,H1,Program Manager
X2 := W1-800
Gui, Show, x%x2% y50 , MovieList
}
Hotkey, ^!a, ShowMovieList
Return
ShowMovieList:
Gui, Show,, MovieList
Return
MyListView:
If A_GuiEvent = e ;Finished editing first field of a row
LV_ModifyCol(2,"Sort")
If A_GuiEvent = ColClick ;Clicked column header
{
If A_EventInfo = 2 ;Number of column header clicked
LV_ModifyCol(2,"SortDesc")
}
UpdateFile()
Return
GuiContextMenu: ; Launched in response to a right-click or press of the Apps key.
if A_GuiControl <> MyListView ; Display the menu only for clicks inside the ListView.
Return
LV_GetText(ColText, A_EventInfo,1) ;Gather column data in string EditText
EditText := ColText
Loop 3
{
LV_GetText(ColText, A_EventInfo, A_Index+1)
EditText := EditText . "|" . ColText
}
Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
return
EditItem: ;Move row from ListView columns into edit fields
SelectedRow := LV_GetNext()
StringSplit, RowData, EditText , |
Loop, 9
{
GuiControl, , Rowdata%A_Index%
}
GuiControl, ,Button1, Update
Return
DeleteItem: ;Deletes selected rows
MsgBox, 4100, Delete Movie?, Delete Movie? Click Yes or No?
IfMsgBox No ;Don't delete
Return
RowNumber = 0 ; This causes the first iteration to start the search at the top.
Loop
{
; Since deleting a row reduces the RowNumber of all other rows beneath it,
; subtract 1 so that the search includes the same row number that was previously
; found (in case adjacent rows are selected):
RowNumber := LV_GetNext(RowNumber - 1)
if not RowNumber ; The above returned zero, so there are no more selected rows.
break
LV_Delete(RowNumber) ; Clear the row from the ListView.
}
UpdateFile()
Return
AddItem: ;Add new or update ListView row
Gui, Submit, NoHide
If SelectedRow = 0
{
LV_Add("", Trim(Title1),Trim(Year1),Trim(NewVar),Trim(playmovie))
}
else
{
LV_Modify(SelectedRow,"", Year1,Title1,NewVar,playmovie)
LV_ModifyCol(1,"Sort")
SelectedRow := 0
GuiControl, ,Button1, Add to list
}
SizeCols()
UpdateFile()
Return
UpdateFile: ;When exiting
DetectHiddenWindows On
UpdateFile()
ExitApp
Return
GuiSize: ; Widen or narrow the ListView in response to the user's resizing of the window.
if A_EventInfo = 1 ; The window has been minimized. No action needed.
return
; Otherwise, the window has been resized or maximized. Resize the ListView to match.
GuiControl, Move, MyListView, % "W" . (A_GuiWidth - 20)
Return
UpdateFile() ;Saves data to file when ListView updated
{
FileDelete, MovieList.txt
WinGet, Min, MinMax, MovieList
If Min = -1
WinRestore, MovieList
WinGetPos, X, Y, Width, Height, MovieList
Width -= 16
Height -= 38
FileAppend, x%x% y%y% w%Width% h%Height% `n, MovieList.txt
Loop % LV_GetCount()
{
RowNum := A_Index
Loop, 3
{
LV_GetText(Text, RowNum, A_Index)
TrimText := Trim(Text)
FileAppend, "%TrimText%"`,, MovieList.txt
}
LV_GetText(Text, RowNum, 4)
TrimText := Trim(Text)
FileAppend, "%TrimText%"`n, MovieList.txt
}
}
SizeCols() ;resize all columns, hide Column 9, Column 10 NoSort
{
Loop, 9
{
LV_ModifyCol(A_Index,"AutoHdr")
}
LV_ModifyCol(9, 0)
LV_ModifyCol(10,"AutoHdr")
LV_ModifyCol(10,"NoSort")
}
#IfWinActive, MovieList ; CTRL+A to Select All
^a::LV_Modify(0,"Select")
#IfWinActive
pushPic:
Gui, Submit, NoHide
FileSelectFile, path, 3, % pathToPic, Select a picture, Pictures (*.png; *.jpeg; *.jpg) ; displays a standard dialog that allows the user to choose a picture
NewVar := % path
GuiControl,, Newvar, %Newvar%
return
pushMovie:
Gui, Submit, NoHide
FileSelectFile, path2, 3, % pathToMovie, Select Movie File, (*.mp4; ) ; displays a standard dialog that allows the user to choose a picture
playmovie := % path2
GuiControl,, playmovie, %playmovie%
return
ButtonCLICK:
GuiControlGet, FocusedControl, FocusV
if (FocusedControl != "MyListView")
return
SetTitleMatchMode, 2
run %playmovie%
return
SetEditCueBanner(HWND, Cue)
{
Static EM_SETCUEBANNER := (0x1500 + 1)
Return DllCall("User32.dll\SendMessageW", "Ptr", HWND, "Uint", EM_SETCUEBANNER, "Ptr", True, "WStr", Cue)
}
GuiEventEmpty()
{
GuiControlGet, ConText,, EditCon, Text
MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 2
WinGetClass, ConClass, % "ahk_id" OutputVarControl
if ( ConText = "" )
{
GuiControl,, EditCon, PlaceHolder
GuiControl, Disable, EditCon
OnMessage( 0x111, "" )
}
}
GuiEventLeave()
{
MouseGetPos, OutputVarX, OutputVarY, OutputVarWin, OutputVarControl, 2
WinGetClass, ConClass, % "ahk_id" OutputVarControl
if ( ConClass = "Edit" )
{
GuiControl,, EditCon
GuiControl, Enable, EditCon
Sleep, 1000
OnMessage( 0x111, "GuiEventEmpty" )
}
}