*** A special note for Dragon for Mac Forum Users ***

Nuance is pleased to announce our new Product Forum User Community - the new Dragon Dictate community will replace these existing Dragon for Mac Forums.

To access the new Online Forums, you must first sign up for an account through our Support Portal here. After activating your new account, or if you already have an account, you may use THIS LINK to log into the Community.

Please note that as of June 18, 2012 this Dragon for Mac Forum has been set to read-only in order to retain all historical information and post details. Any new content or updates to existing content will no longer be permitted at this time. Please visit the new community link listed above to post new content and start new topics of discussion.

Dragon for Mac Forums and Discussion » Dragon Dictate » Extending Dictate

Importing Existing Applescripts Via An AppleScript

(4 posts)
  • Started 3 years ago by Koder Kev
  • Latest reply from freedomcoach
  1. Koder Kev
    Member

    I've created a command so that you can import existing Applescripts using a simple voice command. The script is in its early stages, and I've run into a few glitches. While MacSpeech Dictate's AppleScript dictionary defines commands as belonging to groups, it doesn't tie those groups to an application, or to a context. The upshot of this is that this script works for importing commands into the global group and any existing application groups. If you try to assign a script to a group that doesn't exist, it tries to create a group and fails and so does the script import.

    I looked through the manual, and while it says that I can import scripts by dragging them into the window, that's still rather laborious process for someone like me, since I have tons of scripts that I've used for years with Apple's built-in speech recognition. If anyone with deeper knowledge of Dictate's scripting dictionary can help me connect the dots, I'd appreciate it.

    The other element that is missing is the ability to compile the script under program control without opening the commands window and clicking the "compile" button. I think I've tried not compiling the script, closing Dictate, and reopening it and that this compiles the script, but of course that's the long way around.

    I just called the command "Import Applescript into Dictate." Here's the script:

    tell application "MacSpeech Dictate"
    	activate
    	set theFiles to choose file with prompt ¬
    		"Choose script(s) to import" of type {"com.apple.applescript.script", "osas"} ¬
    		with multiple selections allowed without invisibles
    end tell
    repeat with aFile in theFiles
    	tell application "Finder" to set theName to displayed name of aFile
    	tell application "MacSpeech Dictate"
    		activate
    		set theGroup to display dialog ¬
    			"What group should the command " & (quoted form of theName) & ¬
    			" belong to?" default answer "Global"
    	end tell
    	try
    		-- create alias
    		set theAlias to aFile as alias
    		-- get short name
    
    		-- get contents
    		tell application "Finder" to open theAlias
    		tell application "AppleScript Editor"
    			set theContents to contents of document theName
    			close document theName
    		end tell
    		-- make script
    		tell application "MacSpeech Dictate"
    			set newCommand to make new command with properties ¬
    				{name:theName, description:"Imported script", content:theContents, active:true, language:"en_US", command type:AppleScript, application name:theGroup}
    		end tell
    	on error the error_message number the error_number
    		display dialog "Error: " & the error_number & ". " & ¬
    			the error_message buttons {"Cancel"} default button 1
    	end try
    end repeat
    tell application "AppleScript Editor" to quit

    Kevin

    Posted 3 years ago #
  2. AMeit
    Member

    Thank you very much. Please contact me off list at: meitnik at gmail dot com. I want to work with you to do more. Thanks

    Posted 3 years ago #
  3. abledoc
    Member

    Yes, thank you very much for this contribution. excellent.

    Posted 3 years ago #
  4. freedomcoach
    Member

    AMeit, you seem to have a great knack with writing AppleScript's. I'd like to chat with you about a very simple AppleScript that I have been attempting to create for some time without success. Please let me know if you're open to a discussion about it. You can e-mail me at howard@breakthroughcoaching.cc.

    Sincerely,
    Howard

    Posted 2 years ago #

RSS feed for this topic