second-state / chat-with-chatgpt

Chat with ChatGPT via GitHub issue comments.
110 stars 13 forks source link

MediaInfo and AutoHotkey #252

Open The-Bart-The opened 1 year ago

The-Bart-The commented 1 year ago

Can you write an AutoHotKey script that takes the file path of a video as a parameter and displays the value of its Title tag if it exists or its parent folder and file name if it doesn't? Use MediaInfo.dll if necessary.

alabulei1 commented 1 year ago

Yes, we can write a script that takes the file path of a video as a parameter and displays the value of its Title tag if it exists or its parent folder and file name if it doesn't.

Here's a sample AutoHotKey script that uses MediaInfo.dll to determine the Title tag of a video file:

; Include the MediaInfo.dll library
MediaInfo_Dll := A_ScriptDir "\MediaInfo.dll"
if not FileExist(MediaInfo_Dll)
    MsgBox, 16, MediaInfo.dll, MediaInfo.dll library not found!
else {
    ; Load the MediaInfo library
    MediaInfo := ComObjCreate(MediaInfo_Dll)
    ; Get the path of the video file as a parameter
    path := %1%
    ; Open the video file
    MediaInfo.Open(path)
    ; Get the value of the Title tag
    title := MediaInfo.Get(Stream_Video, 0, "Title")
    ; Close the video file
    MediaInfo.Close()

    ; If the Title tag exists, display its value
    if title <> ""
        MsgBox, %title%
    ; Otherwise, display the parent folder and file name
    else {
        SplitPath, path, parent, name
        MsgBox, %parent%\%name%
    }
}

To use this script, you can save it in a file with the .ahk extension and run it from the command line with the path of the video file as a parameter:

AutoHotKey.exe MyScript.ahk "C:\Videos\Movie.mp4"

The script will then display the value of the Title tag if it exists, or the parent folder and file name if it doesn't.