Applescript to make Desktop become active window

Discussion in 'Mac Programming' started by xharkila, Nov 17, 2009.

  1. xharkila macrumors newbie

    Joined:
    Nov 15, 2009
    #1
    it's easy to make a window become frontmost by click it or tell it to active,
    except Desktop, it won't be the frontmost window of finder when we click on the desktop,
    so,
    is there anyway to make the desktop "active"?
     
  2. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #2
    Code:
    tell application "Finder" to open folder (path to desktop) as string
    
    Save this in your User Scripts folder (Users:you:Library:Scripts:) and it will be available at all times in your AppleScript menu.

    mt
     
  3. SRossi macrumors regular

    Joined:
    May 27, 2009
    Location:
    Glasgow, Scotland
    #3
    Do you need an applescript? Because you could set up expose to use one of the corners to show you the desktop when you scroll to it.

    Apple has a video tutorial at apple.

    Stephen
     
  4. xharkila thread starter macrumors newbie

    Joined:
    Nov 15, 2009
    #4
    Thanks a lot. But what I want is

    "Auto detect the path of folder was clicked", not
    "get the path of desktop",

    If used the script above, then it's unable to detect other folders path.
     
  5. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #5
    Even though AppleScript and Automator are good at detecting changes to folders and then making changes, I think you'll be disappointed at the response at acting on changes you make to your environment, like switching to the Finder.

    It'll mean an "on idle" script, which has to be smart enough to know that you've just made the Finder the frontmost app so you want your Desktop folder visible. It'll also have to be smart enough to know that Finder was previously the frontmost app and you either already have the Desktop folder open or you closed it because you want it closed. That's not terribly complex, but the script will do it for every idle message, which will likely mean your machine becomes sluggish. (But maybe you've got a Mac Pro ::)

    You've got a few of alternatives ...

    Use an Expose hot corner
    Keep the desktop window open at all times
    Add the Desktop window as a stack in your Dock
    Use the script in this thread to activate the Desktop window (You could use something like Butler that would let you activate it with a keystroke.)

    mt
     
  6. Wondersnite macrumors newbie

    Wondersnite

    Joined:
    Jan 14, 2010
    #6
    I think I just discovered the command you wanted... I know you're probably not interested by now, but the "insertion location" command does what you want.

    For example, the script

    Code:
    tell application "Finder"
    	set selectedLocation to insertion location as string
    	display dialog selectedLocation
    end tell
    would tell you your active Finder window, even if it was the desktop!

    Cheers
     

Share This Page