Collin Alpert
Collin Alpert

Reputation: 505

Make the "display dialog" window the front window in applescript

I want to display a dialog. This works, but it is never the front window. I want it to be more like an alert sign. So when I want to type text in the dialog box, I always have to click on it first. Is there any way to display the dialog as the frontmost window and have the cursor preset in the the text field? Here's my code:

display dialog "type password" buttons {"Submit!", "No"} default answer "" default button 1 with hidden answer

if the button returned of the result is "Submit!" then
    set x to text returned of the result
    if x is "Password" then
        tell application "Firefox"
            activate
        end tell
    else
        tell application "Finder"
            activate
            say "wrong password"
        end tell
    end if
else
    tell application "Finder"
        activate
        say "okay"
    end tell
end if

Upvotes: 2

Views: 3938

Answers (1)

pbell
pbell

Reputation: 3095

just before the display dialog instruction, make your script active using :

tell me to activate

Upvotes: 3

Related Questions