image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old December 26th, 2006, 04:36 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
viewsonic is on a distinguished road
AppleScript Question

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+".""
Reply With Quote
  #2  
Old December 26th, 2006, 05:33 PM
dlloyd's Avatar
Official Pianist
 
Join Date: Dec 2002
Location: At a keyboard. One or the other.
Posts: 2,978
Thanks: 0
Thanked 0 Times in 0 Posts
dlloyd is on a distinguished road
Ugh, I guess some people just can't read. This thread belongs in Software Programming & Web Scripting where it will get far more attention.
__________________
< Also Known As aeromusek in places >

< PowerBook | 1.67GHz | 1024MB RAM | 120GB | 17" High Res >
< iPod | 20GB | 3rd gen >


"the show must go on" - the artists of the world
Reply With Quote
  #3  
Old December 26th, 2006, 06:12 PM
Registered User
 
Join Date: May 2005
Posts: 1,339
Thanks: 0
Thanked 1 Time in 1 Post
barhar is on a distinguished road
'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.
Reply With Quote
  #4  
Old December 26th, 2006, 06:26 PM
dlloyd's Avatar
Official Pianist
 
Join Date: Dec 2002
Location: At a keyboard. One or the other.
Posts: 2,978
Thanks: 0
Thanked 0 Times in 0 Posts
dlloyd is on a distinguished road
Quote:
Originally Posted by barhar View Post
'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?
__________________
< Also Known As aeromusek in places >

< PowerBook | 1.67GHz | 1024MB RAM | 120GB | 17" High Res >
< iPod | 20GB | 3rd gen >


"the show must go on" - the artists of the world
Reply With Quote
  #5  
Old December 26th, 2006, 06:37 PM
Registered User
 
Join Date: May 2005
Posts: 1,339
Thanks: 0
Thanked 1 Time in 1 Post
barhar is on a distinguished road
View '[How To] AppleScript Question'
Reply With Quote
  #6  
Old December 26th, 2006, 07:26 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,498
Thanks: 4
Thanked 15 Times in 14 Posts
Mikuro is on a distinguished road
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
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.5

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 11:16 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.