Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global appName
- property fileTypes : {"com.apple.application-bundle"}
- property plistFileItem : " <key>LSUIElement</key>" & linefeed & " <true/>"
- property theLibrary : (path to home folder as text) & "Library:Script Libraries:Log_If_App_Is_Background_Only_Library.scpt"
- set logBackgroundOnly to load script alias theLibrary
- activate
- set chosenApp to (choose application with prompt ¬
- "Choose The Application You Want Hidden From The Dock While It Is Running" as alias)
- tell application "System Events" to set appName to name of chosenApp
- set plistFile to ((POSIX path of chosenApp) & "Contents/info.plist") as string
- set plistFileContents to (read plistFile)
- set plistFileItemExists to plistFileItem is in plistFileContents
- if plistFileItemExists then
- activate
- set theChoice to button returned of (display dialog ¬
- "Would you like to un-hide " & quote & appName & quote & ¬
- " from the Dock while it's running?" buttons {"Cancel", "Un-Hide"} ¬
- default button 2 cancel button 1 with title "Make A Choice")
- else
- activate
- set theChoice to button returned of (display dialog ¬
- "Would you like to hide " & quote & appName & quote & ¬
- " from the Dock while it's running?" buttons {"Cancel", "Hide"} ¬
- default button 2 cancel button 1 with title "Make A Choice")
- end if
- if theChoice is "Hide" then
- tell application "System Events" to tell contents of property list file plistFile ¬
- to make new property list item at end with properties ¬
- {kind:string, name:"LSUIElement", value:true}
- try
- run logBackgroundOnly's logAppSetToRunInBackgroundOnly(appName)
- end try
- else if theChoice is "Un-Hide" then
- tell application "System Events" to tell contents of property list file plistFile ¬
- to make new property list item at end with properties ¬
- {kind:string, name:"LSUIElement", value:false}
- try
- run logBackgroundOnly's removeLogEntry(appName)
- end try
- else
- compileAppScript(chosenApp)
- return
- end if
- compileAppScript(chosenApp)
- on open of theFiles
- -- Executed when files are dropped on the script
- set logBackgroundOnly to load script alias theLibrary
- repeat with chosenApp in theFiles
- tell application "System Events" to set appName to name of chosenApp
- set plistFile to ((POSIX path of chosenApp) & "/Contents/info.plist") as string
- set plistFileContents to (read plistFile)
- set plistFileItemExists to plistFileItem is in plistFileContents
- if plistFileItemExists then
- activate
- set theChoice to button returned of (display dialog ¬
- "Would you like to un-hide " & quote & appName & quote & ¬
- " from the Dock while it's running?" buttons {"Cancel", "Un-Hide"} ¬
- default button 2 cancel button 1 with title "Make A Choice")
- else
- activate
- set theChoice to button returned of (display dialog ¬
- "Would you like to hide " & quote & appName & quote & ¬
- " from the Dock while it's running?" buttons {"Cancel", "Hide"} ¬
- default button 2 cancel button 1 with title "Make A Choice")
- end if
- if theChoice is "Hide" then
- tell application "System Events" to tell contents of property list file plistFile ¬
- to make new property list item at end with properties ¬
- {kind:string, name:"LSUIElement", value:true}
- try
- run logBackgroundOnly's logAppSetToRunInBackgroundOnly(appName)
- end try
- else if theChoice is "Un-Hide" then
- tell application "System Events" to tell contents of property list file plistFile ¬
- to make new property list item at end with properties ¬
- {kind:string, name:"LSUIElement", value:false}
- try
- run logBackgroundOnly's removeLogEntry(appName)
- end try
- else
- compileAppScript(chosenApp)
- return
- end if
- compileAppScript(chosenApp)
- end repeat
- end open
- to compileAppScript(chosenApp)
- try
- tell application "Script Debugger"
- set theApp to open chosenApp
- delay 0.1
- set succesfulCompile to compile theApp with showing errors
- delay 0.1
- close theApp saving yes
- end tell
- end try
- return succesfulCompile
- end compileAppScript
Advertisement
Add Comment
Please, Sign In to add comment