Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:41:27+00:00 2026-05-24T03:41:27+00:00

Ok, so I am writing an applescript to do some voice control actions for

  • 0

Ok, so I am writing an applescript to do some voice control actions for me.

I am using Dragon Dictate 2.0 for mac for my voice control and mainly applescript for my coding. I have everything pretty much squared away except for once small issue. When expecting a voice command, I have applescript display a dialog for the text to be dictated into.

eg.

set cmd1 to the text returned of (display dialog "Speak Command:" default answer "")

This displays a dialog box with an empty text field, and the buttons “cancel” and “ok”

My problem is how I can press ok without having to speak an additional phrase.
Currently I have a voice command that listens for me to speak “go” and then runs an applescript that presses the “return” key. This works, but I don’t want to have to have to say “go”.

I know I can add

giving up after 10

to automatically close the dialog box and accept the input after a certain time period, but there has to be a better way.

I have done some research and found that I could have an event handler for “on done editing” to execute a return keystroke. But I have no idea how to do this. If anyone has any input or ideas that would be great. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:41:29+00:00Added an answer on May 24, 2026 at 3:41 am

    The “on done editing” is the best way but then you would have to write your dialog box in Xcode using objective-c or AppleScriptObjC. It seems that is beyond your abilities.

    Something that might be within your abilities… you could simulate your own “on done editing” method. You could have a second applescript launch when your first applescript which shows the dialog box is run. This second applescript could check the text field of the dialog box periodically. When the text stops changing for a certain length of time then it could press the return key. It’s a little complicated because you have to figure out how to target your dialog box from the second applescript, but it wouldn’t be too hard. It might be best to give your dialog box a title, and then use system events to find the window with that title.

    The reason you have to do this in a separate applescript is because your normal applescript pauses all commands while the dialog box is open. So you need a separate process running to check the text field and a second script would be the easiest way.

    EDIT: Here’s how to do it with applescript. First create this script which is your on done editing script. It will dismiss your dialog when the user stops entering text. Save it as a script called onDoneEditing to your desktop.

    set shortDelay to 0.5
    set longDelay to 1
    
    delay longDelay --delay for a moment to let the dialog box from the first script launch
    
    tell application "System Events"
        set theProcess to first process whose frontmost is true
        tell theProcess
            set dialogWindow to first window
    
            -- this repeat loop looks for when the user starts entering text into the dialog box
            repeat
                -- get the current text field value
                set currentValue to value of first text field of dialogWindow
    
                -- if the value has changed we know text is being entered
                if currentValue is not "" then exit repeat
    
                delay shortDelay
            end repeat
    
            -- this repeat loop looks for when the user stops entering text
            -- we know that when the text is the same after 2 checks
            delay longDelay
            repeat
                set newValue to value of first text field of dialogWindow
    
                if newValue is currentValue then
                    keystroke return
                else
                    set currentValue to newValue
                end if
    
                delay longDelay
            end repeat
        end tell
    end tell
    

    Now create this script. This script will launch the above script using the command line tool “osascript” so that it runs in a background process. Then it shows the dialog box for you. You can read my comments in both scripts to understand how each works.

    -- launch the onDoneEditing script
    -- we get the process id (thePID) of the launched process so we can kill it later
    set onDoneEditing to (path to desktop as text) & "onDoneEditing.scpt"
    set thePID to do shell script "osascript " & quoted form of POSIX path of onDoneEditing & " > /dev/null 2>&1 & echo $!"
    
    -- diaplay the dialog and make sure it will be frontmost
    tell me to activate
    display dialog "Speak Command:" default answer ""
    
    -- kill the onDoneEditing to make sure it's not still running
    try
        do shell script "kill " & thePID
    end try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code in AppleScript to glue an Obj-C Cocoa app to some other
Writing some classes for a Framework extension, and I have the following code: public
I'm writing an applescript to automate some tedious work in Aperture, and I'm having
I am writing a mac application that uses the scripting bridge to control iTunes.
I'm writing an Applescript playlist generator. Part of the process is to read the
Writing some test scripts in IronPython, I want to verify whether a window is
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing documentation in html requires some code examples. What to do with characters that
Writing a python program, and I came up with this error while using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.