Friday, 20 February 2015

New to Applescript


hello all, i'm new here thought best place ask this.

iv started using applescript editor , need help. have written string of commands (activating applications followed keystrokes ect.) , wanted know if there way make sure script waits each command finish before starts next?

i.e. if takes long time load app script wait until loaded before hits enter key.

if can great.

thanks, ed

helpful know how focus particular app app selector (command tab). @ moment i'm using series of key strokes select 1 wont , it's not working need.

again
 

you can use applescript delay command wait specific amount of time,
this.

code:
 --long process code  delay 3    --wait 3 seconds  --another not long process  delay 0.5    -- wait half second 
also check application active using repeat loop,
this.

code:
 set runningapps {} list tell application "system events" 	repeat until runningapps contains "textedit" 		set runningapps name of every application process visible equal true 		delay 1 	end repeat end tell 
but aware, repeat loop go forever until textedit app started.

adapt run repeat number of times,
this

code:
 set runningapps {} list tell application "system events" 	repeat 30 times 		set runningapps name of every application process visible equal true 		if runningapps contains "textedit" 			exit repeat 		end if 		delay 1 	end repeat end tell 
this version runs repeat loop 30 times, or 30 seconds, before it
stops checking textedit app, if app starts before 30 seconds
up, script exit.

hope of help.

regards mark
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment