I have a couple of scripts which I have tied to quick keys in order to toggle between communication apps (email, twitter, adium) and the rest of my apps (it hides all the apps I am not viewing). Only problem is, if I enable spaces, and apps are in any space OTHER than #1 then my screen ends up on the last screen where an app is “unhidden.” This defeats the purpose of my applescript which was to very quickly switch between apps within the same space.
Is there ANY way to suppress the call that OS wants to make to go to a space - or even just target the apps in my applescript that are viewable in space#1 so the apps that are on any other screen aren’t affected? Here is the code below:
communication_ON
tell application "System Events"
set visible of (every process whose visible is true) to false
set visible of process "Finder" to false
end tell
tell application "Nambu"
activate
--set the bounds of the first window to {20, 0, 300, 200}
end tell
tell application "Mail"
activate
set the bounds of the first window to {0, 0, 1700, 1000}
end tell
tell application "Adium"
activate
--set the bounds of the first window to {0, 0, 300, 1000}
end tell
--tell application "Skype"
--activate
--set the bounds of the first window to {0, 0, 300, 1000}
--end tell
communication_OFF
tell application "System Events"
set visible of (every process whose visible is false) to true
set visible of process "Finder" to true
end tell
tell application "Finder"
set visible of process "Nambu" to false
set visible of process "Mail" to false
set visible of process "Adium" to false
--set visible of process "Skype" to false
end tell
How can I still use these scripts without having the OS change spaces when it turns an app that is in the visible = false state to visible = true space in a space other than #1? Any help would be GREATLY appreciated!
tell application "System Events"
tell expose preferences
tell spaces preferences
set spaces enabled to false
end tell
end tell
set visible of (every process whose visible is true) to false
set visible of process "Finder" to false
end tell
tell application "Nambu"
activate
--set the bounds of the first window to {20, 0, 300, 200}
end tell
tell application "Mail"
activate
set the bounds of the first window to {0, 0, 1700, 1000}
end tell
tell application "Adium"
activate
--set the bounds of the first window to {0, 0, 300, 1000}
end tell
--tell application "Skype"
--activate
--set the bounds of the first window to {0, 0, 300, 1000}
--end tell
tell application "System Events"
tell expose preferences
tell spaces preferences
set spaces enabled to true
end tell
end tell
set visible of (every process whose visible is false) to true
set visible of process "Finder" to true
end tell
tell application "Finder"
set visible of process "Nambu" to false
set visible of process "Mail" to false
set visible of process "Adium" to false
--set visible of process "Skype" to false
end tell
**EDIT, All in one script for a single toggle
tell application "System Events"
tell expose preferences
tell spaces preferences
set SE to get spaces enabled
log SE
set spaces enabled to (not (SE as boolean))
set SE to get spaces enabled
log SE
end tell
end tell
end tell
if not SE then
my View_only_Chat()
else
my View_Other_Apps()
end if
on View_Other_Apps()
tell application "System Events"
set visible of (every process whose visible is false) to true
set visible of process "Finder" to true
set visible of process "Mail" to false
set visible of process "Spark" to false
set visible of process "Script Editor" to false
end tell
end View_Other_Apps
on View_only_Chat()
tell application "System Events"
set visible of (every process whose visible is true) to false
set visible of process "Finder" to false
tell application "Spark"
activate
--set the bounds of the first window to {20, 0, 300, 200}
end tell
tell application "Mail"
activate
set the bounds of the first window to {0, 0, 1700, 1000}
end tell
tell application "Script Editor"
activate
--set the bounds of the first window to {0, 0, 300, 1000}
end tell
end tell
end View_only_Chat
It looks good, but not getting the right behavior. The behavior is different every time with that script. Sometimes it stops with spaced enabled and sometimes disabled. Sometimes in puts me back to space 1 and sometimes takes me to space 3 or 4. It’s strange, It isn’t behaving consistently with that code (haven’t tried the toggle one yet). I wonder why.
Also, do you know why the screen position wont work for my other apps if I try and put them on my second monitor. only mail will respond correctly, all other apps don’t respond. Is that because placing with a second monitor doesn’t work? you can I see that I commented them out.
The code is yours, apart from the enable and disable spaces part.
Spaces is a work in progress in my opinion and is erratic anyway.
I did write a script when I first read this post, to get the spaces bindings for apps, and store them. Then it would create a new set bindings and a new space for Chat apps, and throw your Chat apps to the new blank space, where you could work.
When done, it would then allow you to revert back to the old set.
This worked well up to an extent, But the buggy-ness of Spaces crept in even here. So I gave up on it. the behavior I was seeing was similar.
No, I only have the one monitor, and did not use the bounds bits as you had them commented out.