Move iTunes visualizer to second display

Hello.

Maybe it can help if you move a regular itunes window to the second display first, and then start the visualizer?

  • Also see to that you have no iTunes windows on your main display?

I really don’t use iTunes that much, so I can’t help you there. :slight_smile:

Hi McUsr,

I did that before and it doesn’t work. When you run iTunes from the second display, the visualizer opens in the first display! :confused: Strange how different iTunes is. Well actually, several apps behave in the same manner I think. :expressionless:

Later,
kel

ps. Ive been trying to help someone else on the Apple site, so posts might be a little delayed.

Does anyone know how to make the menu bar invisible?

Hello Kel.

Maybe you can fix your original problem with changing main display to the external monitor in System Preferences. What I mean is that you drag over the menu bar over to the other display, in the screens preferences. Maybe that will work. Good luck.

Hi McUsr,

Good idea about changing the Display arrangement with the menu bar. I’ll try that later and see what happens.

Thanks a lot,
kel

Think I might have something with the menu bar. Need to experiment with:

Edited: it almost worked. I dragged the Xcode app to the second display and ran it. Only that space didn’t have the menu bar and not the visualizer. Back to the drawing board. I think it has to be done in iTunes.

Success!!! :smiley:

Here’s what you do. After dragging the visualizer to the second display with Mission Control, go to System Preferences. In the Accessibility pane select Display. Then, check Invert colors. Then, uncheck it. All spaces return to default, but the visualizer menu bar disappears I think (or remains black). Quite sure the procedure went like that.

gl,
kel

Finally figured out the easier way. Didn’t know how to make the visualizer not come out of full screen. It needed to be done in the visualizer. This makes it easier. Now just need to move the window. Getting there.

Hi McUsr,

I decided to go with the quick and dirty ui element scripting Dock along with scripting iTunes for now. :slight_smile: The big algorithm had too many pieces. I have most of them, but haven’t put them all together and don’t know what kind of speed I’ll get. Will look into that later.

Will post the quick and dirty and local (according to my setup on the computer) in a little while. Maybe someone can use it as an algorithm for their own setup.

Thanks for the script. I’ve read your posts before and looked at the script about moving the window. That’s what I’m doing with Dock ui element scripting.

Edited: and one thing. I don’t have Script Debugger, so couldn’t run it, but the part about the windows looks interesting.

Edited: thought of a new library script to add to Script Libraries, ScreenLib. That might come in handy later.

Thanks a lot,
kel

Hello Kel.

Add a property named Screens2 right below the toplevel property in the teleport script.
This property should load the screens2. script object.

Then everything should work as expected.

I will convert it into a script library, when I change it for some reason.

Hi McUsr,

Will try the property. Thanks.

Here’s the roughly working quicky in my setup :slight_smile: :

-- macro
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

-- if full screen is true,
-- then that means that the visualizer might have opened in display 1
-- then, need to put the visualizer back in the window
-- then, re-full screen
tell application "iTunes"
	launch
	activate
	set visuals enabled to true
	if full screen then
		say "full screen off" -- this delay maybe needed here
		set full screen to false
	end if
	say "full screen on" -- this delay needed here
	set full screen to true
end tell
delay 2 -- this delay maybe needed here

-- macro
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

tell application "iTunes"
	play
end tell
-- Remember to return focus to iTunes (if you prefer).
-- Activate doesn't work because the focus is already on iTunes in the visualizer.
-- Maybe you can use this as a feature?
-- Remember to reset menu to what it was before.

Needs a lot of tweaking.

Have a good day, :smiley:
kel

Have a good day you too kel, and good luck! :slight_smile:

Thanks McUsr.

Think I have a new idea. I’m wondering if visible is set and unset then the focus will change to the browser. Hope I can sleep. :slight_smile: Nice puzzle.

Later,
kel

Think I have the solution. Need to keystroke out of the visualizer’s space!

Edited: no can’t do that. Then, the visualizer won’t show! How to shift out of display 2? That’s the question.

Edited: by Jove, think I’ve got it. Use the same method!

Edited: figured how to move the focus with keystrokes!!!

Hi McUsr,

We’ve got it now!!! To open iTunes in space 6 on the second display from the first display:

tell application "System Events"
	launch
	key code 22 using control down --  Space 6
	key code 26 using control down -- Space 7
	key code 22 using control down -- Space 6
end tell
tell application "iTunes"
	launch
	activate
end tell

Keystrokes don’t work, but key codes do. Also, if on the second display, space 6 is already the selected space, then nothing will happen with just:

key code 22 using control down --  Space 6

So we need to key code to space 7 and then back to space 6.

This makes everything very easy!!! :smiley:

The only hard part is that I want to move the browser back to the first display. That’s all that is left to do.

Have a good day, :slight_smile:

Edited: it didn’t work. :frowning: The browser still opens in where it was closed. :confused: Back to the drawing board.
Have a good day anyway. :slight_smile:

kel

Hi,

What I wanted to do was Open iTunes browser in Display 1 - Space 5 and the visualizer in Display 2

Here’s the working script if anyone wants to play around with it. I’m running it in AppleScript Editor in Space 4.

-- 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
						-- might need delay here
						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 2 -- this delay needed
	set full screen to false
	delay 2 -- this delay needed
	set full screen to true
end tell
delay 2 -- 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 or 4.
tell application "System Events"
	key code 23 using control down --  Space 5
	key code 21 using control down -- Space 4
	delay 2
	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

Try decreasing the delays if possible.

Edited: btw, Dock is set to always be open. I think that’s all.

Edited: one more thing if someone wants to make it international, then please do and post it. I don’t know how to get the indices for the menu items. Thanks.

gl,
kel :smiley:

Added one more delay and decreased the others:

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
end tell

It should work ok for the time being. Might try speeding it up somehow.

Good Luck.

Hi,

If anyone still want updates, then just say so. I have some ideas on error checking. There is one update you should make though. change the last iTunes tell block to:

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

Because, you want to see the currently playing track.

gl,
kel

ps. really anal retentive huh! :slight_smile: Not pompous.

First of all, we need to check if iTunes is already running.

Something like this:

set is_running to application "iTunes" is running
if is_running then
	display dialog "iTunes is running.
The script can't run if iTunes is running (maybe)
Do you want to quit iTunes or relaunch?"
end if

Hi,

If anyone is interested, I found a bug with the script here in Yosemite. If the current space is space 5 then it gets stuck. It might have been there all the time, but working on the fix. Don’t know yet.

gl,
kel