Script to link DVDPedia and VLC | move process to front

Hi @ all,

after testing out DVDPedia I decided to use this programme for organising my DVD-collection, which I copied on an external HD.

The only thing which doesn’t work as it is supposed to is to open a VIDEO_TS-folder with VLC-player.

So I modified the Applescript provided by the programme’s author to this:

set pathFinal to POSIX path of FILE_PATH
do shell script “/Applications/ dvdnav://” & pathFinal & " -f --video-on-top"

The variable FILE_PATH is defined somewhere else.

My problem is that VLC opens the VTS-folder just perfectly then is the lastmost window. So everytime I have make it the frontmost window.

What did I try so far?

To add "tell application “VLC”, activate, end tell

Result: A second VLC-player opened up. I guess, somehow there is a distinction between the one process VLC started using a command line and the Application startet from the applications folder.

I fiddled around a bit with the “make frontmost”-command: no success.

I would be more then happy, if anyone has a clue how to manage to link those two programmes seemlessly.

All the best


An an example, here is how you can do it with TextEdit:

set shellScript to "/Applications/  &> /dev/null & echo $!"
set pid to do shell script shellScript
delay 0.5 -- give it some time to register so that System Events can see it; may need to change this value
tell application "System Events" to set frontmost of first application process whose unix id is (pid as integer) to true

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari Version 3.2.1 (4525.27.1)
Operating System: Mac OS X (10.4)

Hi Chrys,

thanks for the answer!!!

Unfortunately i doesn’t work.

I even put the delay time up to 2s, yet no postive result.

I’m quite sure that is has something to do with some weird behaviour of VLC: When the player is in fullscreen and you move the mouse, it show’s some navigation options.

Usually it does so only, if it is in front.

Now it shows them even when it’s the last-most app.

Can you think of another way, to put it to front?

All the best


Maybe your app (I do not have it on hand to test with) is forking a new process from the one started by the shell. If that is the case, then finding it by PID will not work. You could try finding it by name instead.

(***** Change these to your app's path and name (as System Events sees it) *)
set appPosixPath to "/Applications/"
set appNameInSystemEvents to "textedit"

do shell script quoted form of appPosixPath & " &> /dev/null &"
repeat 10 times
	tell application "System Events" to set targetRef to a reference to (first application process whose name is appNameInSystemEvents)
	if exists targetRef then
		set frontmost of targetRef to true
		exit repeat
	end if
	delay 1
end repeat

But it could be that this app just is not going to work correctly in this situation (since it looks like you are telling it to start “video on top” (full screen?), maybe it ignores “move to front” requests when it thinks it is in full screen mode).