• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: can I run an applescript within another applescript based on text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can I run an applescript within another applescript based on text?


  • Subject: Re: can I run an applescript within another applescript based on text?
  • From: waynemelrose <email@hidden>
  • Date: Sun, 07 Oct 2012 16:03:39 +1100


On 07/10/2012, at 3:32 PM, Porter Slice <email@hidden> wrote:

Is it possible to run an applescript within a script based on text entered by the user, For example say I have a script that runs in the background as a handler, I open the script and it would have a dialog box asking for a command by entering text. I have a script written that will launch iTunes, when the dialog box appears I want to be able to type in "launch iTunes" and run the iTunes script, how would I do this?

Any help would be greatly appreciated,

Porter 


I have a feeling you need to be more specific.. But you can run applescript commands that are entered as text.. here's how you'd do it based on what you said.. thing is, you'd want to make sure you enter correct applescript syntax, otherwise of course it would error.. 

set strTextCommand to the text returned of (display dialog "Enter command" default answer "beep")

run script strTextCommand




Another way around doing what you're asking would be making a list of choices for the user.



set {strResult} to choose from list {"Launch iTunes", "Launch Mail"}

if strResult is "Launch Mail" then
tell application "Mail" to activate
else if strResult is "Launch iTunes" then
tell application "iTunes" to activate
else
--> do default
end if
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >can I run an applescript within another applescript based on text? (From: Porter Slice <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 9, Issue 398
  • Next by Date: what's wrong with this script
  • Previous by thread: can I run an applescript within another applescript based on text?
  • Next by thread: what's wrong with this script
  • Index(es):
    • Date
    • Thread