Getting keystrokes on VLC via AppleScript I have an AppleScript file which works like a charm, except for the part where I use keystrokes to make VLC run fullscreen. The filename has been changed for privacy reasons, but the rest of the code is the exact same. My code goes as this:

tell application "Finder"
    set MyFile to ((path to me as text) &amp; "File.mkv") as text
end tell
tell application "VLC"
    open MyFile
end tell
tell application "System Events"
    tell application process "VLC"
        set frontmost to true
        keystroke "f" using command down
    end tell
end tell
You don't need to tell VLC to perform the keystroke.

tell application "VLC"
    open MyFile
    activate
end tell
tell application "System Events"
    keystroke "f" using command down
end tell




I understand you say the rest of the script works, but without more information, I don't see how.

path to me will return the path to the actual script, not the containing folder. This means you'll end up with the equivalent of path:to:script.scptFile.mkv, which can't be true. Instead, you need to get the container:

tell application "Finder"
    set MyFile to ((container of (path to me) as text) &amp; "File.mkv") as text
end tell


This will return path:to:File.mkv. Make sure your mkv is actually in this location.



Full script:

tell application "Finder"
    set MyFile to ((container of (path to me) as text) &amp; "File.mkv") as text
end tell
tell application "VLC"
    open MyFile
    activate
end tell
tell application "System Events"
    keystroke "f" using command down
end tell