1

I'd like to be able to get the current playing time of a file in VLC media player and insert it as a timestamp into a word processor - so something like a hotkey combination that will output "[HH:MM:SS]" at the current cursor position.

Is there any existing way to do this? If not, given something like AutoHotkey, how would I go about getting the current time out of VLC?

2
  • I suppose this would be possible, as AutoHotkey should be able to extract such information from the UI. However, Superuser is not a script writing service. Dig into the AutoHotkey documentation and forums and try out how far you get. Then someone might be able to help you. A Google search turned up this SU answer: superuser.com/questions/1026248/… Commented Jul 2, 2016 at 20:13
  • I wasn't looking for a script-writing service - just guidance, as someone who currently doesn't know how to write such a script, that this is the right tree to be barking up, or that someone else hasn't done this but using terms I don't know about and therefore can't search for :D So, cheers, I'll keep going this way and see what I can work out.
    – shermarama
    Commented Jul 3, 2016 at 22:36

1 Answer 1

1

I'm using AutoHotKey as shown below.

But this is somehow tricky since AFAIK there is no way to predict and positionate the focus in the time field. I think this is (at least in the german version) because there is no Alt-Key combination for it. There are only (aparently) two Alt-Key combinations: for the button "Los" (german for "OK") and for "Abbrechen (german for "Cancel"). The next problem is that the dialog is not modal and pressing Alt-Keys activates the menues on the main window.

Therefore I'm using MouseClick to click the time field. The coordinates may vary depending on the screen resolution. Please change this for your screen resolution. Evtl. use AutoHotKey's WindowSpy to get your coordinates

Furthermore I store the original contents of the clipboard and the mouse position at the beginning of the script and restore them at the end.

; # Insert Timestamp from VLC
#ifWinActive ahk_exe WINWORD.EXE
F8::
    ; GoToTimeDialogName:="Zu Zeitpunkt gehen" ; # german name of "Go to Time" dialog
    GoToTimeDialogName:="Go to Time" ; # english name of "Go to Time" dialog
    ClipSaved := ClipboardAll ; # Save the entire clipboard
    MouseGetPos x, y ; # get current mouse position
    if WinExist("ahk_exe vlc.exe") { ; # if vlc existst, i.e. vlc is running
        WinActivate ; # activate vlc window
        Send, {Esc} ; # make sure you are not in other dialogs
        Send, ^t ; # open the "Go to Time" dialog
        if WinExist(GoToTimeDialogName) { ; # if the "Go to Time" dialog exists
            WinActivate ; # activate "Go to Time" dialog exists
            MouseClick, left, 120, 48 ; # click on time field (change this for other screen resolutions)
            Send, ^a ; # select time field
            Send, ^c ; # copy to clipboard
            ClipWait ; # Wait for the clipboard to contain text.
            ts:=clipboard ; # get content of clipboard to var "ts"
            Send, ^t ; # quit "Go to Time" dialog
        }
    }
    if WinExist("ahk_exe WINWORD.EXE") { ; # if word exists
        WinActivate  ; # activate word window
        Send, [%ts%]{space} ; # insert the timestamp surrounded by brackets and a space
    }
    Clipboard := ClipSaved   ; # Restore the original clipboard
    MouseMove %x%, %y% ; # move mouse to original position
Return

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .