Simple question about displaying a window.

I am writing an Automator action the ends with an Applescript for my wife. I have mu iTunes library set up on a NAS. I want it to be as seemless as possible for her. So I am replacing the iTunes application launch with an Automator action. It feeds the IP address in the “Connect to Server” then I have an Applescript launch iTunes (this makes sure the network drive is connected). This is fine if iTunes is not currently running. It connects to the server and then lunches the application and the iTunes window comes up and all is good. The problem is when I close the window (via the red button in the upper left) and then click on my Automator action (the drive could disconnect at any time). When I run the action it connects to the server fine, the menu bar changes to iTunes, but the iTunes window doe snot show up. I have to click on the iTunes icon in the dock to bring it up. I am trying to make it as easy as possible (i changed the Autmator icon to the iTunes icon) and I want to know how to “show” the window with my applescript.


hi drew,

if your script works properly when iTunes is closed, why not close it if it’s open and then reopen? like this:

	do shell script "/usr/bin/killall iTunes"
end try

delay 2

tell application "iTunes" to activate

the ‘delay’ is necessary so that AppleScript waits until iTunes is closed before reopening.


I will try that but I really wouldn’t like to add that time even though it isn’t much. It works fine its just I want the window to show, if I can’t get anything else to work, I will try your solution. Thanks!

New to this but could you not send a command-L some how to show current song? This brings up the window at least. Sorry not sure how you would code this.

Hi drew

Try This!

set p to "itunes"
tell application "System Events" to if process p exists then tell process "Dock"
	tell UI element p of list 1
		(perform action) click
	end tell
end tell

This is one of Kai’s scripts re-jigged a little by me so if it works you have him to thank…
if it doesn’t work you have me to thank…! sorry



tell application “iTunes”
set visible of first browser window to true
end tell


I got it to work using some similar to kel’s post. Thanks everyone for your hel!