Applescript: Does it understand that another app is running an export?

Joined
Mar 18, 2016
Messages
4
Reaction score
0
Points
1
Can AppleScript understand that an application that the script's code is "handling" is busy with something else - busy with exporting for example - and only upon finishing the export to execute a part of the script?

Bare in mind I do not want to use the 'wait' command.

I am using tell "System Events" to handle an otherwise non-scriptable application and I would be interested to be able to set a loop when exporting (to perform multiple exports). But I'd need the script to understand that the application has finished an export first before going for the next.

Again, the 'wait' command cannot be used in this specific instance.


Thanks in advance!
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Since the application is not talking to AppleScript and providing details of what it is doing and when it'll be done, my guess is that your only option is to wait in your script until the tasks are done before proceeding.
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
As RazorEdge has stated, the AppleScript is not notified when the export procedure has completed, nor is there a way of the AppleScript to be notified.

But you have two other options to explore.
Firstly you could use the "delay" AppleScript command, but would have to guess the delay time needed for the application to complete it's task, before moving on to the next export procedure, and this may need some experimentation to find a suitable delay time.

Code:
delay 2 -- a 2 second delay
delay (0.5) -- a half second delay

Secondly, you could check that the exported item exists before moving onto the next item.

I guessing your using an AppleScript repeat loop to process a list of items to export.
If that is the case, then run a second repeat loop nested within the first, in which, you test for the existance of exported item on disk, followed by a small delay command, and if or when the exported item does exist, then you exit the nested repeat loop, giving the control back to the outer repeat loop.

Hope this helps.

Regards Mark
 
OP
S
Joined
Mar 18, 2016
Messages
4
Reaction score
0
Points
1
Many thanks for the reply back and apologies for not replying earlier.

What about this:

I am trying to use the SystemUIServer to access several UI options. Is there away to make the script aware that there is a window open (the export window in this case) and only proceed with the script once that window has disappeared? My only issue for the time being, is that the particular export window does not have a title.

Many thanks once again!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top