How to switch to modal window in the background

keyboardquicksilver

I don't know if this problem is specific to Quicksilver or a general problem with modal windows. I use QS to launch an applescript:

"run 'command' with administrator privileges"

But the modal window from QS to enter my password appears without focus. I can't I need to click on the window with the mouse in order to be able to activate it. I would guess that this is because QS has launched the applescript "in the background" as it were, and already returned focus to the previous app.

Is there a way to switch to this modal window using keyboard actions? It's something I need to do every morning and it's very annoying to have to switch over to it with the mouse every time. I can't command-tab to Quicksilver when the dialog is active.

Best Answer

You can focus SecurityAgent:

osascript -e 'do shell script "ls /var/root" with administrator privileges' &
open -a SecurityAgent

Displaying dialogs:

tell application (path to frontmost application as text)
    --activate
    display dialog "" default answer ""
end tell

⌃F6 (Move focus to the floating window) doesn't work with the password dialogs, and Witch doesn't include them either. You might use a script like this though:

tell application "System Events"
    repeat with p in {"SecurityAgent", "CoreServicesUIAgent", "loginwindow"}
        if exists process p then
            tell process p
                if windows is not {} then
                    set frontmost to true
                    exit repeat
                end if
            end tell
        end if
    end repeat
end tell

CoreServicesUIAgent displays Gatekeeper and quarantine dialogs. loginwindow displays many of the dialogs shown when logging out.