AppleScript Question

viewsonic

Registered
I'm trying to make a script and have run into a small problem. I'm running sales order numbers from excel into a production system software program and sometimes, depending on the kind of information that sales order number has tied to it, the production system will take a really long time to process the command I'm scripting.

Basically, what I want to know how to do is find some way to script a fix for this. Whenever I run the program, if I see that the production system is taking a really long time to bring an order up because it's one of those special numbers, I just hit "apple+"."" and that immediately stops what's going on and causes the program to move on to the next sales order number.

So what I'm trying to do is find a way to input that "apple+"."" command into my program ... I'm hoping that's just a basic apple command for quiting out of frozen programs. So first, I wanted to know if anyone knew the Mac OS X command in applescript for quitting out of a frozen program? And second, in order for this script to be self-sufficient, I'll need it to know when to use that "apple+"."" command ... I was thinking if there was a way to write a line of code in AppleScript that translates to "if program pauses for more than 5 seconds, press "apple+".""
 
'Ugh, I guess some people just can't read. This thread belongs in Software Programming & Web Scripting where it will get far more attention.' ... ugh, maybe so; however, those of us who visit 'http://macosx.com' and respond to the most recent entries, see all forum entries - unknowing of which specific forum the entry is actually posted to, until viewing the selected post.

-----

The initial post - seeking specific 'AppleScript' code is too vague.

Why not create a drag and drop 'AppleScript' 'applet', which will receive the 'excel' file, detect and ignore the 'special numbers', and pass only the non-'special numbers' to the unspecified 'production system software'?

-----

on open (geschleppte_Einzelteile)
my Prozessdateien(geschleppte_Einzelteile)
end open

on run {}
display dialog "Schleppen Sie die 'Excel' Datei auf applet für die korrekte Verarbeitung." & return & return & "( Drag 'Excel' file(s) onto applet for proper processing. )" buttons {"OK"} default button "OK"
end run

on Prozessdateien(lokale_Einzelteile)
repeat with i in lokale_Einzelteile
--
--
-- Prozessdateien (process data)
--
--
end repeat
end Prozessdateien

-----

Naturally, the above code 'snippet' is but one example of many possible solutions.
 
'Ugh, I guess some people just can't read. This thread belongs in Software Programming & Web Scripting where it will get far more attention.' ... ugh, maybe so; however, those of us who visit 'http://macosx.com' and respond to the most recent entries, see all forum entries - unknowing of which specific forum the entry is actually posted to, until viewing the selected post.

-----

The initial post - seeking specific 'AppleScript' code is too vague.

Why not create a drag and drop 'AppleScript' 'applet', which will receive the 'excel' file, detect and ignore the 'special numbers', and pass only the non-'special numbers' to the unspecified 'production system software'?

-----

on open (geschleppte_Einzelteile)
my Prozessdateien(geschleppte_Einzelteile)
end open

on run {}
display dialog "Schleppen Sie die 'Excel' Datei auf applet für die korrekte Verarbeitung." & return & return & "( Drag 'Excel' file(s) onto applet for proper processing. )" buttons {"OK"} default button "OK"
end run

on Prozessdateien(lokale_Einzelteile)
repeat with i in lokale_Einzelteile
--
--
-- Prozessdateien (process data)
--
--
end repeat
end Prozessdateien

-----

Naturally, the above code 'snippet' is but one example of many possible solutions.

That's what I always used to do also, I know it's the way many people read new messages. :)
The bigger issue is that the description text for this particular forum contains the words "Do not submit new questions here." There is also a sticky thread at the top which says "***This Forum is for Tutorials and Guides only, not questions***"
Oh well, he's new here, not a big issue. But now he's gone and double-posted, though that was probably my fault for suggesting this is the wrong place.

On another note, half of your snippet is in a language I certainly don't speak...what's the deal there? :p
 
It's just his own variable and function names. It's all plain ol' AppleScript, and will work with any language.

It's easy to simulate a command-period in AppleScript. Just do this:

tell application "System Events" to keystroke "." using command down

(You may need to enable GUI Scripting for that to work. You can do this in AppleScript Utility, which is located in /Applications/AppleScript/)

As for how to tell when Excel is taking too long, I'm not sure. As Barhar suggested, it may be easier to have the script identify the troublesome items and simply not attempt to process them.

I can think of no easy way for a script to tell if an action that it did not initiate is taking too long. There might be some way specific to Excel, but since I don't use Excel, I don't know.

If you do initiate the command from within AppleScript, you might find AppleScript's "with timeout" statement useful when used inside a "try" statement. A little example:

Code:
try
	with timeout of 5 seconds
		tell application "Excel"
			--process something
		end tell
	end timeout
on error
	tell application "System Events" to keystroke "." using command down
end try
 
Back
Top