iTunes dock options don't work for screens and desktops

Hi,

Can someone verify that the dock options don’t work for launching iTunes on different screens so I can send a bug report.

Thanks,
kel

Nevermind, I think I know how it works now.

Thanks anyway,
kel

ps. the problem is in the display 1 not showing up when iTunes is in display 2. Very frustrating!

ps. if anybody has a better way to show the visualizer on display 2 and switch the browser to display 1 in this new system, please tell.

Thanks,
kel

The problem is that the script works sometimes. I can get the browser in display one and the visualizer in display 2, but I can’t pinpoint the exact situation when it works all the time.

Forgot to post the script :):

property delay1 : 1.5
property delay2 : 0.5

-- iTunes' browser opens in the display where it was closed.
-- Set iTunes to open in display 2.
tell application "System Events"
	tell process "Dock"
		tell list 1
			tell UI element "iTunes"
				perform action "AXShowMenu"
				tell menu 1
					tell menu item "Options"
						click
						tell menu "Options"
							tell menu item "Desktop on Display 2"
								click
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

-- First move to space 5 where we want iTunes to open.
tell application "System Events"
	key code 23 using control down
end tell

-- Open iTunes and enable the visualizer.
-- If the visualizer opens in full screen, it might have opened in display 1.
-- So, take it out of full screen and into the browser.
-- Now go back into full screen and the visualizer should open in display 2.
-- Focus is now on the visualizer.
tell application "iTunes"
	launch
	activate
	set visuals enabled to true
	delay delay1 -- this delay needed
	set full screen to false
	delay delay1 -- this delay needed
	set full screen to true
end tell
delay delay1 -- this delay needed

-- Move the browser back to display 1.
tell application "System Events"
	tell process "Dock"
		tell list 1
			tell UI element "iTunes"
				perform action "AXShowMenu"
				tell menu 1
					tell menu item "Options"
						click
						tell menu "Options"
							tell menu item "Desktop on Display 1"
								click
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

-- The focus is on display 2, last space (no index).
-- Set the focus on display 1, space 5.
tell application "System Events"
	key code 23 using control down --  Space 5
	key code 21 using control down -- Space 4
	delay delay1
	key code 23 using control down -- Space 5
end tell

-- Reset where iTunes should open to None.
tell application "System Events"
	tell process "Dock"
		tell list 1
			tell UI element "iTunes"
				perform action "AXShowMenu"
				tell menu 1
					tell menu item "Options"
						click
						tell menu "Options"
							tell menu item "None"
								click
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell
delay delay2

tell application "iTunes"
	activate
	play
	reveal current track
end tell

It’s the same script, but I can’t figure out what changed. Actually, I figured out what changed by the error, but I can’t figure out why it is changing.

Thanks,
kel

Darn, think I’ve found the answer. Originally, I had 5 spaces in display 1 and 2 spaces in display 2. If there is only 1 space in display 2 then it won’t work. I need to find some way to check how many spaces are set in display 2.

The reason this started happening is because there is a bug where the desktops in display 2 will shift to display 1. For instance, say you have 5 spaces in display 1 and 2 spaces in display 2, when sleep or shutdown occurs, the spaces from display 2 shifts to display 1. So, you would have 6 or seven spaces in display 1. Then display 2 will have have only 1 space. It’s a bad bug. I wrote Apple about the bug, but it’s not fixed yet.

Edited: and btw, the fix is to make sure there are at least 2 spaces in display 2.

Thanks anyway,
kel

The main problem is that I don’t know how to create a space on a display.

What I was thinking was to go back to the original idea of scripting Mission Control and adding buttons (spaces).

Edited: one more thing is that you can’t launch the app from desktop 5 on display 1. Think I can fix that, but trying to get to the main hurdles.

Trying to fix this before new years. :slight_smile:

Edited: btw, the best visualizer to use is the newest iTunes visualizer. It uses the least memory and is the most efficient. I checked the cpu usage.

Wish me luck,
kel