How to Handle Automator Errors with Applescript - applescript

I'm still pretty much a newbie, so I hope my question makes sense.
I created a simple Automator application. I have iCal set to run it during the night. Because other things are running at the same time, I sometimes get "The action "blah blah blah" encountered an error...."
Is there a way (with Applescript) to either: (1) ignore the error and have the application continue or (2) click the "OK" button on the error and restart the application?
EDIT: I basically want Applescript to run the Automator-created app and, if/when that app has a "The action "blah blah blah" encountered an error"-type message, I want Applescript to continue or restart the Automator-created app. This includes getting rid of the error message box that popped up during the running of the Automator-created app.
Thanks.

If your code is within an Applescript, you can try something like this:
repeat with i from 1 to 5
try
--insert your code here
set thrownError to 1 / 0
-- If code completes without error, exit repeat
exit repeat
on error
beep
delay 3
end try
end repeat

If you just want to ignore an error in applescript, just use try
try
--do what ever
on error
--continue with code
end

Related

Component request is being processed

I see this message in VB6 again and again from time to time since I can remember, and now after like 15 years, I would like to ask if somebody knows how to get rid of this message.
I don't know when it occurs, but when it does, I can not click this window away.
It keeps flickering and does not go away:
In English:
"The action cannot be completed because the other application is unavailable. Click 'Switch to' to activate the other application and fix the problem. 'Switch to...', 'Repeat', 'Cancel' "
I don't really know what the message means. I would guess it wants to tell me that it waits for a component to respond.
But no longer how long I wait, it does not finish.
Does anybody know a trick how to close this window?
Sometimes I can still try to close VB6, and it will go away and allow me to save the edited files, but often, I have to terminate VB6 using the task mananger, and then my changes are lost.
I would like to avoid this.
Thank you!
Edit: It seems that the problem occurs when I use the clipboard.
Each time right now when I use Ctrl + V to paste something, this happens.

Application has no verified creator

I am creating a prank, witsh floods the screen with bananas, and ran into a problem that alway occurres, when i create applicationes.
When you try to open it, it shows a message saying:
"Are you sure that you want to open a application witch has no verified creator?"
This Message is very annoying, because, no one will open the banana prank.
Is there a way to get around this problem?

Applescript Error -10810

I have an Applescript that runs fine on my Macbook Retina but fails on a Mac Mini.
Both are running MacOS 10.9.2.
After peeling the onion a bit I'm able to reproduce the problem with a one-line Applescript:
tell application "MidiPipe" to activate
On the Mini that throws the error:
An error of type -10810 has occurred.
On the Macbook the MidiPipe application opens.
MidiPipe works normally on the Mini when started from the Finder or from Launchpad.
Google provides no insight into this error.
Well, I found this: http://www.thexlab.com/faqs/error-10810.html and this: http://osxdaily.com/2010/02/09/mac-error-10810/ and this: http://forums.adobe.com/thread/1389805 . At least one of these suggests a RAM problem.
But just to make sure you've tried every weird variation, have you tried the following:
1) using a full path:
tell application "Full:Path:To:MidiPipe.app" --(probably "YourHDName:Applications:MidiPipe.app"?
2) using an actual tell block:
tell application "MidiPipe"--or full path
activate
end tell
3) using the Finder:
tell application "Finder" to open "Full:Path:To:MidiPipe.app"
4) using shell:
do shell script "open /Applications/MidiPipe.app"
?
After looking at the links in CRGreen's answer, it looks like this is likely being caused by the process table being full on the mini. This, in turn, prevents any new applications from opening. According to The X Lab:
Error -10810 is a Launch Services result code indicating an unknown error. One cause of this error is that the MacĀ® OS X process table is full. When the process table is full, new (not currently running) applications cannot be opened until another running application ends. Programming errors in third-party applications can fill-up the process table, leading to the -10810 error when opening an application.
I would start by restarting the mini to see if that clears the process table, allowing you to to start MidiPipe.
If that doesn't work, you should look at your Activity Monitor to see if there is a specific program filling up your process table.
Could be nothing more than another mysterious grieving crap from Apple.
Today I have faced this myself, first time after using four different Mac Minis as build servers for Continuous Integration of Mobile apps for about two years or so.
My Jenkins runs the osascript from the bash script to build the app.
A few days ago the office experienced the power outage and all Macs went down. After powering them back on I have got this error at osascript execution on one of my Macs.
I have tried just to re-build - with the same result.
First thing I stumbled upon was https://jacobsalmela.com/2014/08/04/infamous-execution-error-error-type-10810-occurred-10810/ , but none of them applied to me.
Then I googled more general 10810 issue occurrences and went through couple of questions here on SO.
Still no luck.
Next I reached to the server via SSH using PuTTY and tried telling Terminal to do the very basic script like
osascript -e 'tell application "Terminal"
activate
tell window 1
do script "counter=0; while true; do if [ \"$counter\" -gt \"10\" ]; then
break; else counter=$((counter + 1)); sleep 1; fi; done; exit;"
end tell
end tell'
This worked fine.
Then I tried to run the whole bash script that Jenkins used to execute. Everything went just perfect and the app was uploaded to HockeyApp as the result.
I came with the thought that the issue is that Jenkins runs it remotely on that Mac and finally I have tried just to re-build again and it magically worked fine this time.
No idea what it was, but since then I have performed three or more builds already and all of them were successful.
Note I haven't changed anything, and my script:
1) never used a full path;
2) always used an actual tell block;
3,4) nothing like that from the accepted answer was ever used.
So... Go away mysterious grieving crap! Go away! :)

VBScript Isn't Recognizing Speak Command?

I need help. I'm trying to make a personal assistant with batch, and for effect, I want my computer to speak. I've used the speaking code before, even on this computer, but for some reason, when I try to use the speak command now, it doesn't seem to work. Here's the code I usually use:
Set objVoice=CreateObject("SAPI.SpVoice")
objVoice.Speak("Insert Message Here")
I don't know what happened, but when I run the script, I get this error:
Line: 2
Char: 1
Error: The handle is invalid.
Code 89970006
Source (null)
Please help me fix this error. Thanks in advance.
BY THE WAY, I do have Speech API, and my text to speech in Control Panel works. It seems to be the .vbs file.
Try This:
Set Speak = CreateObject("sapi.spvoice")
Speak.Speak "Text Goes Here"
Or, If you want to have it say something you enter you can do this,
Dim Message, Speak
Set Speak=CreateObject("sapi.spvoice")
Message=InputBox("Enter text","Speak")
Speak.Speak Message

ApplescriptObjC call to NSMakePoint results in exc_bad_access error

This problem really puzzles me, since AppleScriptObjC should handle garbage collection just fine on its own.
Anyway, the steps to reproduce this error are:
Create a new Cocoa-AppleScript-Application project
Insert single call to NSMakePoint anywhere in the project's nameAppDelegate.applescript file. The file should now look something like this:
script testAppDelegate
property parent : class "NSObject"
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
set single_point to NSMakePoint(5, 10) of current application
display alert "X-value of point: " & x of single_point
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
display alert "Terminating"
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
Run the application
The above application will launch and display the alert "X-value of point: 5.0" (as expected), but immediately after the alert it will crash with the following EXC_BAD_ACCESS error in the file main.m: main.m error
Thus, somewhere a call is being made to an object that no longer exists. If we profile the application with NSZombies enabled, it confirms that a zombie has been messaged and gives this additional info: zombie info
I've also tried the same thing with NSMakeRange and NSMakeRect instead, and it gives exactly the same result. I suspect every call to a Core Foundation function will crash the application this way. However, if we as an example call stringValue() of a NSTextField, it works just fine.
Putting the call outside of applicationWillFinishLaunching_ does not solve it either. So what am I doing wrong?
I'm using XCode 4.3.3 on OSX Lion 1.7.4
EDIT: After some further research, I realized I do not need to call NSMakePoint, I could just create an AppleScript record like {|x|:0, |y|:0} and it will work just like an NSPoint object. So that solves it, I guess.

Resources