Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3816

Problem with executing AppleScript in Shell

$
0
0

Some of my AppleScripts can run longer. Those are getting the mailboxes from Mail or Outlook. If I run the AppleScript in an async shell and some AddHandlers I’ve managed to avoid the beachball when the scripts are running.

This works fine when I show the mailboxes for selection. Before archiving the email I need to get the mailboxes again. This does not run in a thread. But here neither the DataAvailable nor the Completed event of the shell fire.

Why do the shell events not fire and how do I debug this? I’m doing the mailboxes for Mail here which shouldn’t take longer than a second.

Main code:

ScriptResult = ""
dim theShellScript as string = "nohup /usr/bin/osascript -e '" + ScriptText + "'"
dim theShell as new Shell
theShell.ExecuteMode = Shell.ExecuteModes.Asynchronous
theShell.TimeOut = 1000 * 60 * 10
AddHandler theShell.DataAvailable, AddressOf ShellDataAvailable
AddHandler theShell.Completed, AddressOf ShellCompleted
ShellFinished = False
theShell.execute theShellScript
While not ShellFinished
  Thread.SleepCurrent(10)
wend

20 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 3816

Trending Articles