AppleScript to hide an application...

Discussion in 'Mac Basics and Help' started by Will Cheyney, May 15, 2006.

  1. Will Cheyney macrumors 6502a

    Will Cheyney

    Joined:
    Jul 13, 2005
    Location:
    United Kingdom
    #1
    Can somebody tell me the code I need to create an AppleScript that will hide an application when I press a the scroll 'nipple' on my Mighty Mouse?

    I have no AppleScript experience :(


    Many thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    I don't think that will be possible. AppleScript cannot trap and handle generic system wide events like that.
     
  3. Will Cheyney thread starter macrumors 6502a

    Will Cheyney

    Joined:
    Jul 13, 2005
    Location:
    United Kingdom
    #3
    You can't just tell it to hide the front application?

    I found a script that hides all open applications... It's from Apple site.
    http://www.apple.com/applescript/toolbar/
    (Under 'Window management' and called 'Hide Application Windows' - direct download: http://images.apple.com/applescript/toolbar/scripts/hideapps.sit).

    I just want the current app to be hidden though!

    This is the code the script above uses:
    Code:
    tell application "Finder"
    	activate
    	set visible of every process whose visible is true and name is not "Finder" to false
    end tell
     
  4. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #4
    You can use this code to hide the front application:
    Code:
    tell application "Finder" to set visible of every process whose frontmost is true to false
    However, as robbieduncan said, AppleScript can't automatically respond to events such as pressing the scroll button, although there might be a third party application that you could use to run the script when the button is pressed.
     
  5. Will Cheyney thread starter macrumors 6502a

    Will Cheyney

    Joined:
    Jul 13, 2005
    Location:
    United Kingdom
    #5
    Can you not just compile is as an app and then have it set to launch (and therefore run) when a button is pressed (set through System Preferences)?
     
  6. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #6
    I think you're right actually, I don't have such a feature available to me but looking at the resources inside the Keyboard and Mouse preferences pane it looks like it does allow it for Mighty Mouse users.
     

Share This Page