Hello!
I hate it, when I am to get a finder window up in the space I am working on, and I have to go to another space and drag it over, or go looking for it, if I have set “When switching to an application, take me to a space with open windows for the application” turned off or unchecked.
I also want to tell that I use the function cycle through windows Ctrl -F4 / Shift Ctr F4 to move back and forth between windows while I work. It may not be perfect, and I may have to click on windows, to get them into the loop so to speak, but it works perfeclty after a couple of clicks, as long as the applications are well behaved.
It is kind of hard to press Shift Ctrl F4 and Ctrl F4 so I have used a nice utility called KeyRemap4MacBook to put the function onto the key F12 as well, with the added functionality of having one extra Control key when hold down.
The KeyRemap4MacBook is free and can be found here: http://pqrs.org/macosx/keyremap4macbook/
The programmer was so kind as to provide me with the necessary Xml to obtain this functionality, I have pasted it here:
[code]<?xml version="1.0"?>
F12 duplicates control+F4 or is just control_L when held down
<identifier>private.F12forctrlF4</identifier>
<autogen>--HoldingKeyToKey-- KeyCode::F12, KeyCode::F4,ModifierFlag::CONTROL_L, KeyCode::VK_NONE, KeyCode::CONTROL_L</autogen>
</item>
[/code]
Well, here goes the code for getting a Finder window into your current space if it is not there:[/b] it is reusing windows, so if the window is in another space, then it will get it for you, and every other window as well.
You know what to do after that!
The code below works because I have configured Finder to show the posix paths in the title bar I think
You have to enter this in your terminal window, it should work for Leopard and later, but I used to have it this way
in Tiger as well.
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
killall Finder
You can read more about that here:http://hints.macworld.com/article.php?s . 1210524604
Edit I have removed one errant and some superfluos lines.
I also want to state, that sometimes the Finder window, won’t show up as visible, ant that is because some other window is in front, but hitting ctrl F4 brings it to the foreground. This as an alternative to getting all the Finder Windows in front.
openFinderWindowInThisSpace of me for "My Hd:Users:Me:My Project Folder"
to openFinderWindowInThisSpace for folderName
set foundIt to false
if openFinderWindow of me for folderName then
if not character 1 of folderName is "/" then
set pxName to (POSIX path of folderName as text)
else
set pxName to folderName
set folderName to POSIX file pxName as text
end if
set pxName to characters 1 thru -2 of pxName as text
-- check with system events
tell application "System Events" to tell process "Finder"
set wnNames to (get name of its every window) as list
end tell
-- we see if the window name has turned up in this space
repeat with awName in wnNames
if contents of awName is pxName then
set foundIt to true
exit repeat
end if
end repeat
if not foundIt then removeFindersSpaceAssignment()
else
error folderName & "is not a valid folder specifier"
end if
if foundIt then
tell application "Finder" to open folder folderName
-- we had it in our space
tell application "System Events" to tell application process id "com.apple.finder"
-- We tickle the Finder window, to make it colourful and active when we leave
key down control
key code 118
key up control
delay 0.1
end tell
else
tell application "Finder" to activate
end if
end openFinderWindowInThisSpace
on removeFindersSpaceAssignment()
-- not made by Me, but by : Jesse Newland
-- The scripts he has made for Spaces can be found here:
-- http://jnewland.github.com/articles/2007/11/22/spaces-application-assignments-and-applescript/
setFindersSpaceAssignment(65544)
-- 65544 is the code for being assigned to every space
end removeFindersSpaceAssignment
on setFindersSpaceAssignment(spaceNumber)
-- not made by Me, but by : Jesse Newland
-- The scripts he has made for Spaces can be found here:
-- http://jnewland.github.com/articles/2007/11/22/spaces-application-assignments-and-applescript/
set app_construct to (run script "{|" & "com.apple.finder" & "|:" & spaceNumber & "}")
tell application "System Events"
tell spaces preferences of expose preferences
set app_layout to application bindings
end tell
end tell
set app_identifier to bundle identifier of (info for (path to frontmost application))
try
app_layout as number -- causes an error anyway
on error errstr
set app_locations to {}
set {TID, text item delimiters} to {text item delimiters, "{"}
set errstr to text item 2 of errstr
set text item delimiters to "}"
set errstr to text item 1 of errstr
set text item delimiters to ", "
set errstr to text items of errstr
set text item delimiters to TID
repeat with i in errstr
set o to offset of "|:" in i
tell i
set app_location to {}
set end of app_location to text 2 thru (o - 1)
set end of app_location to text (o + 2) thru -1
set end of app_locations to app_location
end tell
end repeat
end try
set spaces_bindings to {}
repeat with i from 1 to count app_locations
if "com.apple.finder" = item 1 of (item i of app_locations) then
--skip it
else
set spaces_bindings to spaces_bindings & (run script "{|" & item 1 of (item i of app_locations) & "|: " & item 2 of (item i of app_locations) & "}")
end if
end repeat
tell application "System Events"
tell expose preferences
tell spaces preferences
set application bindings to spaces_bindings
set spaces_bindings to app_construct & spaces_bindings
set application bindings to spaces_bindings
end tell
end tell
end tell
end setFindersSpaceAssignment
to openFinderWindow for folderName
tell application "Finder"
set aw to (get its every Finder window) as list
set hw to {}
set failed to false
try
set aliasOfit to folderName as alias
on error
try
set aliasOfit to (POSIX file folderName as text) as alias
on error
set failed to true
end try
end try
repeat with w in aw
if (target of w as alias) is aliasOfit then
copy w to end of hw
exit repeat
end if
end repeat
if not hw is {} then
select item 1 of hw
else
open aliasOfit
end if
end tell
return not failed
end openFinderWindow