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