Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there any way (using apple script or by using settings on chrome) to open Google Chrome in incognito mode.

share|improve this question

4 Answers 4

up vote 13 down vote accepted

This can be achieved with the following in script editor:

do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"

Save it as an application, throw the alias in the dock. Tested this in 10.6.8.

Only works if you don't have chrome open already.

share|improve this answer
    
1  
Didn't even get a mention. –  Digitalchild Aug 6 '13 at 10:57

Another workaround:

mode (text) : Represents the mode of the window which can be 'normal' or 'incognito', can be set only once during creation of the window.

tell application "Google Chrome"
    close windows
    make new window with properties {mode:"incognito"}
    activate
end tell
share|improve this answer
    

I combined Lyken and user3936 answer to open a new chrome incognito window if it does not exist, and if a incognito window exists the script will bring it to the foreground.

on is_running(appName)
    tell application "System Events" to (name of processes) contains appName
end is_running

set chrome_running to is_running("Google Chrome")
if chrome_running then
    tell application "Google Chrome"
        repeat with w in (windows)
                if mode of w is "incognito" then
                    set index of w to 1
                    tell application "System Events" to tell process "Google Chrome"
                        perform action "AXRaise" of window 1
                    end tell
                    activate
                    return
                end if
        end repeat
    end tell
    tell application "Google Chrome"
        make new window with properties {mode:"incognito"}
        activate
    end tell
else
    do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
end if
share|improve this answer

I quickly created an app with platypus to launch Chrome incognito.

You can download it from: http://ente.limmat.ch/ftp/pub/software/applications/GoogleChromeIncognito/

It works for me. (OS X 10.6+ required).

Feel free to report back any error.

The script inside the app is the following:

#!/bin/bash

# (c) 2012 by Adrian Zaugg under GNU GPL v.2

CHROMENAME="Google Chrome"

MYPATH="$(dirname "$(dirname "$0" | sed -e "s%/Contents/Resources$%%")")"
MYAPPNAME="$(basename "$(dirname "$0" | sed -e "s%/Contents/Resources$%%")" | sed -e "s/\.app$//")"
# Ask Spotlight where Chrome is located, chose top entry since this was the latest opened Chrome version
CHROMEPATH="$(mdfind 'kMDItemContentType == "com.apple.application-bundle" && kMDItemFSName = "'"$CHROMENAME.app"'"' | head -1)"

# Expect Chrome next to me, if the system doesn't know where it is.
if [ -z "$CHROMEPATH" ]; then
    CHROMEPATH="$MYPATH/$CHROMENAME.app"
fi

if [ -e "$CHROMEPATH" ]; then
    # Is there an instance already running?
    if [ $(ps -u $(id -u) | grep -c "$CHROMEPATH/Contents/MacOS/Google Chrome") -gt 1 ]; then
        # use apple script to open a new incognito window
        osascript -e 'tell application "'"$CHROMENAME"'"' \
                  -e '  set IncogWin to make new window with properties {mode:"incognito"}' \
                  -e '  set URL of active tab of IncogWin to "about:blank"' \
                  -e 'end tell'
    else
        # just open Chrome in incognito mode
        open -n "$CHROMEPATH" --args --incognito --new-window "about:blank"
    fi

    # bring Chrome to front
    osascript -e 'tell application "'"$CHROMENAME"'" to activate'

else
    # Chrome not found
    osascript -e 'tell app "'"$MYAPPNAME"'" to display dialog "Place me next to '"$CHROMENAME"', please!" buttons "OK" default button 1 with title "'"$MYAPPNAME"'" with icon stop'
fi

exit 0
share|improve this answer
    
Can you explain how to do this rather than just give a link –  Mark Oct 19 '12 at 12:53
    
You can take the shell script from the first answer, then using Platypus (sveinbjorn.org/platypus) wrap it up in an app you can run like any other app. Platypus is very handy and very powerful, but cannot be described here in the detail you need. Experiment! –  IconDaemon Oct 19 '12 at 13:31
    
Download and right-click the app, choose "Show Package Contents": You'll find then the script under Contents/Resources/script. How it works: The script asks LaunchService for the location of Google Chrome. Like this it should find Chrome even when Chrome is not located in the /Application folder or when its name has been altered. –  Adrian Zaugg Oct 21 '12 at 1:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.