Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 17, 2013, 07:44 PM   #1
TheMTtakeover
macrumors 6502
 
Join Date: Aug 2011
AppleScript works but returns an error?

Okay the script is:

Code:
tell application "SkyDrive"
	quit
end tell
set the_button to button returned of (display dialog "Did Skydrive close?" buttons {"Yes", "No"} default button 1)
if the_button is "Yes" then tell application "Terminal"
	activate
	do script "cp -av /Users/osx/Desktop/test /Users/osx/Desktop/untitled folder"
end tell
if the_button is "No" then display dialog "Please Try Again"
delay 2
set button_two to button returned of (display dialog "Was the copy successful?" buttons {"Yes", "No"} default button 1)
if button_two is "Yes" then tell application "SkyDrive"
	activate
end tell
if button_two is "No" then display dialog "Please Try Again"
It works fine until when I hit yes that the copy was successful.SkyDrive doesn't start and an error pops up, but then after the error pops up SkyDrive starts. So it has me kind of puzzled because it does work but it just needs the error to pop up first?

the error is:
error "SkyDrive got an error: AppleEvent timed out." number -1712

Any help would be greatly appreciated!
__________________
#TeamTaji

Last edited by TheMTtakeover; Jan 17, 2013 at 08:31 PM.
TheMTtakeover is offline   0 Reply With Quote
Old Jan 17, 2013, 08:27 PM   #2
wrldwzrd89
macrumors G4
 
wrldwzrd89's Avatar
 
Join Date: Jun 2003
Location: Solon, OH
Quote:
Originally Posted by TheMTtakeover View Post
Okay the script is:

Code:
tell application "SkyDrive"
	quit
end tell
set the_button to button returned of (display dialog "Did Skydrive close?" buttons {"Yes", "No"} default button 1)
if the_button is "Yes" then tell application "Terminal"
	activate
	do script "cp -av /Users/osx/Desktop/test /Users/osx/Desktop/untitled folder"
end tell
if the_button is "No" then display dialog "Please Try Again"
delay 2
set button_two to button returned of (display dialog "Was the copy successful?" buttons {"Yes", "No"} default button 1)
if button_two is "Yes" then tell application "SkyDrive"
	activate
end tell
if button_two is "No" then display dialog "Please Try Again"
It works fine until when I hit yes that the copy was successful.SkyDrive doesn't start and an error pops up, but then after the error pops up SkyDrive starts. So it has me kind of puzzled because it does work but it just needs the error to pop up first?

the error is:
error "SkyDrive got an error: AppleEvent timed out." number -1712

Any help would be greatly appreciated!
The problem may be that SkyDrive is taking longer than AppleScript is willing to wait for it. If that's the case, you could fiddle with the time out value - but I have no idea how you set that globally, only for dialog boxes.
__________________
iMac Intel (Rev H, 27"), 1TB HDD, 16GB RAM, 10.8.4
wrldwzrd89 is offline   0 Reply With Quote
Old Jan 17, 2013, 08:31 PM   #3
TheMTtakeover
Thread Starter
macrumors 6502
 
Join Date: Aug 2011
Quote:
Originally Posted by wrldwzrd89 View Post
The problem may be that SkyDrive is taking longer than AppleScript is willing to wait for it. If that's the case, you could fiddle with the time out value - but I have no idea how you set that globally, only for dialog boxes.
Thats what I thought so I changed the code:

Code:
if button_two is "Yes" then with timeout of 10 seconds
	tell application "SkyDrive"
		activate
	end tell
end timeout
and no matter how many seconds I set the timeout for SkyDrive won't reopen until the error message pops up. I cannot figure this thing out at all
__________________
#TeamTaji
TheMTtakeover is offline   0 Reply With Quote
Old Jan 17, 2013, 10:01 PM   #4
TheMTtakeover
Thread Starter
macrumors 6502
 
Join Date: Aug 2011
If anybody comes across this having the same problem the only workaround I was able to find was running it through the terminal so it would end up being
Code:
tell application "SkyDrive"
	quit
end tell
set button_one to button returned of (display dialog "Did Skydrive close?" buttons {"Yes", "No"} default button 1)
if button_one is "Yes" then tell application "Terminal"
	activate
	do script "cp -av /Users/osx/SkyDrive /Volumes/Skydrive/$(date +%Y-%m-%d)"
end tell
if button_one is "No" then error number -128
set button_two to button returned of (display dialog "Was the copy successful?" buttons {"Yes", "No"} default button 1)
if button_two is "Yes" then tell application "Terminal"
	do script "open -a SkyDrive"
end tell
if button_two is "No" then error number -128
__________________
#TeamTaji
TheMTtakeover is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Error when duplicating folders to shared drive in AppleScript tekboi Mac Programming 10 Mar 18, 2014 10:04 AM
Applescript - Button returned error bgrantmyre Mac Programming 1 Jul 30, 2013 07:04 PM
Help with Applescript error watcoh Mac Basics and Help 0 Apr 29, 2013 05:15 PM
Applescript error - stripping file extension AlexFW Mac Programming 11 Feb 18, 2013 01:09 PM
Applescript Error ekulmail71 Mac Programming 0 Nov 7, 2012 03:04 AM

Forum Jump

All times are GMT -5. The time now is 06:52 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC