I use “Elmedia Video Player” as a player.
This application has a shortcut that selects in the Finder the video file that is being played.
I take advantage of the selection to extract information about the video from its name (title, original title, director, etc.).
The problem is that during the process of extracting information, the Finder is placed in front, leaving the player in the background
I have tried hiding (Cmd-h) the Finder while extracting the desired information from the video file name, but I have not been able to get the process done in the background without interfering with the video display.
Any way to achieve this?
The structure of the video file name is as follows:
Year Title (original title) [director] other information.nExt
For a better understanding, here is the handler that copies to the clipboard the original title of the video name.
use AppleScript version "2.4"
use scripting additions
use utTexto : script "Basic Text Utilities"
tell application "System Events" to set nAplic to (name of first application process whose frontmost is true)
if nAplic is "Elmedia Video Player" then
tell application nAplic to activate
tell application "System Events" to tell process nAplic
keystroke "r" using {control down, command down}
--Elmedia Video Player shortcut that selects in Finder the video file being played back.
-- Finder WILL NOW BE IN THE FRONT AND PLAYER IN THE SECOND PLACE.
delay 0.2
end tell
titOriginalFinder()
tell application "Elmedia Video Player" to activate
else if nAplic is "Finder" then
titOriginalFinder()
end if
on titOriginalFinder()
set {esto, eso} to {"(", ")"}
tell application "Finder" to set fName to name of (selection as alias)
set {ATID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "["}
set p1 to first text item of fName -- Porción hasta "["
set AppleScript's text item delimiters to ATID
if p1 does not contain esto then
say "No original title information"
else
set the clipboard to "" -- empty the clipboard if there is an original title (???)
set titOriginal to my betweenThisAndThat(p1, esto, eso) of utTexto -- Segment of p1 enclosed in parentheses = Original Title
set the clipboard to titOriginal as text
say (the clipboard as text)
end if
end titOriginalFinder
I have corrected the translation of the script because some of the word used as a variable is a reserved word for AppleScript.