• 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: Javascript for automation quastions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Javascript for automation quastions


  • Subject: Re: Javascript for automation quastions
  • From: Yvan KOENIG <email@hidden>
  • Date: Sat, 13 Dec 2014 14:49:28 +0100


Le 11/12/2014 à 21:12, David Steinberg <email@hidden> a écrit :

Hi Deivy,

pathTo can be called with the global object to get the path to the script.

app = Application.currentApplication()
app.includeStandardAdditions = true

pathToScript = app.pathTo(this)

As shown in the release notes, you can turn off parameter type checking to be able to send any kind of parameter to a method.

app = Application.currentApplication()
app.includeStandardAdditions = true

// Turn off parameter type checking
app.strictParameterType = false

// Run script text

scriptText = 'Application("Mail").activate()'
app.runScript(scriptText, { in: '_javascript_' })

// Run a saved script

// Build a path to a script using Standard Additions
pathString = app.pathTo('desktop') + '/foo.scpt'

// ...or build a path to a script using Objective-C
pathString = $('~/Desktop/foo.scpt').stringByExpandingTildeInPath.js

pathObject = Path(pathString)

app.runScript(pathObject)

I hope that helps!

- David

Hello

As I am curious, I pasted this code in Script Editor for see.

The Events log was :

app = Application("Éditeur de script")
app.sysodsct("Application(\"Mail\").activate()", {scsy:"_javascript_"})
app.earsffdr("desk")
app.sysodsct(Path("/Users/yvankoenig/Desktop/foo.scpt"))

no end loop


(1) it appears that when we run _javascript_ non ASCII characters aren't displayed correctly. So we are back several years in the past.
(2) with foo.scpt being a simple AppleScript :
display dialog "I am the foo"
the execution enter a loop with no end so that I was forced to apply Force quit to the editor.

What am'I doing wrongly ?

Yvan KOENIG (VALLAURIS, France) samedi 13 décembre 2014 14:49:24


 _______________________________________________
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

  • Follow-Ups:
    • Re: Javascript for automation quastions
      • From: Deivy Petrescu <email@hidden>
References: 
 >Javascript for automation quastions (From: Deivy Petrescu <email@hidden>)
 >Re: Javascript for automation quastions (From: David Steinberg <email@hidden>)

  • Prev by Date: Re: Javascript for automation quastions
  • Next by Date: Re: AppleScript-Users Digest, Vol 11, Issue 494
  • Previous by thread: Re: Javascript for automation quastions
  • Next by thread: Re: Javascript for automation quastions
  • Index(es):
    • Date
    • Thread