Re: AppleScript-Users Digest, Vol 4, Issue 526
Re: AppleScript-Users Digest, Vol 4, Issue 526
- Subject: Re: AppleScript-Users Digest, Vol 4, Issue 526
- From: "John Dulion" <email@hidden>
- Date: Sat, 3 Nov 2007 16:05:09 +0000
- Importance: Normal
- Sensitivity: Normal
John Dulion
Creps United Publications
800-752-0555
724-840-5079
-----Original Message-----
From: email@hidden
Date: Fri, 2 Nov 2007 21:28:57
To:email@hidden
Subject: AppleScript-Users Digest, Vol 4, Issue 526
Send AppleScript-Users mailing list submissions to
email@hidden
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.apple.com/mailman/listinfo/applescript-users
or, via email, send a message with subject or body 'help' to
email@hidden
You can reach the person managing the list at
email@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of AppleScript-Users digest..."
Today's Topics:
1. Re: prevent user input question (Philip Aker)
2. Re: [Slightly OT] Scripting Bridge in Leopard (has)
3. Re: prevent user input question (Shane Stanley)
4. Re: Why doesn't this script work? (Christopher Nebel)
5. Re: [Slightly OT] Scripting Bridge in Leopard (Mark J. Reed)
6. Re: Running Scripts (Mark J. Reed)
7. Re: Why doesn't this script work? (Michelle Steiner)
8. AppleScript URL Protocol (Rick Gordon)
9. Re: Why doesn't this script work? (Christopher Nebel)
10. Re: Why doesn't this script work? (Michelle Steiner)
11. Re: prevent user input question (Paul Berkowitz)
12. Re: Why doesn't this script work? (Laine Lee)
13. Re: Why doesn't this script work? (Michelle Steiner)
----------------------------------------------------------------------
Message: 1
Date: Fri, 02 Nov 2007 12:33:43 -0700
From: Philip Aker <email@hidden>
Subject: Re: prevent user input question
To: Oakley Masten <email@hidden>
Cc: Users Group AppleScript <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes;
format=flowed
On 2007-02-11, at 09:51, Oakley Masten wrote:
>> Under what circumstances are you running the script?
> The process in question opens, modifies, prints and then saves a
> folder of Excel files. It uses GUI scripting and therefor is
> susceptible to errors if a user inputs anything by keyboard or
> mouse. So can I suspend input until the script finishes? If so how?
> Also, how do I post a dialog that tells the user that they must
> wait until the process is finished. And what do I do if the process
> hangs up and never finishes? Is there a "time limit" parameter for
> my lock out?
> So many questions !!!!
IMO, Luther's described a viable method. You can probably block input
by using a 'do shell script' which calls osascript to run your script
(run it via System Events). But I think that neither of these will
account for your user switching to Excel and typing like a mad fool
while the script is runningā¦
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
------------------------------
Message: 2
Date: Fri, 2 Nov 2007 19:48:21 +0000
From: has <email@hidden>
Subject: Re: [Slightly OT] Scripting Bridge in Leopard
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On 1 Nov 2007, at 13:21, Rob Stott wrote:
> I was kind of wondering whether anyone had a working example so I
> could compare theirs to my ham-fisted effort!
Still working on fully grokking SB myself, but if you're curious,
here's a really basic comparison I just whipped up between
AppleScript, SB, appscript and Mac::Glue:
------- AppleScript -------
#!/usr/bin/osascript
tell application id "com.apple.textedit"
get paragraph 1 of document "Read Me.txt"
end tell
------- Scripting Bridge (via PyObjC) -------
#!/usr/bin/python
from ScriptingBridge import *
textedit =
SBApplication.alloc().initWithBundleIdentifier_('com.apple.textedit')
print `textedit.documents().objectWithName_('Read
Me.txt').text().paragraphs()[0].get()`
------- py-appscript [1] -------
#!/usr/bin/python
from appscript import *
textedit = app(id='com.apple.textedit')
print `textedit.documents['Read Me.txt'].paragraphs[1].get()`
------- Mac::Glue [2] -------
#!/usr/bin/perl
use Mac::Glue;
my $te = new Mac::Glue('TextEdit');
print $te->obj('document' => 'Read Me.txt')->obj('paragraph' => 1)->get;
I'll try to post some less trivial examples as and when time allows.
has
[1] Folks wanting to use appscript on Leopard's stock Python install
should download and unpack 'appscript-0.17.2.tar.gz' from <http://appscript.sourceforge.net
>, cd to the appscript-0.17.2 folder and run 'python setup.py
install'. (Note that you'll need to have gcc - included in Apple's Dev
Tools - installed.) New binary installers, eggs, etc. are on my TODO
list for later this month.
[2] To make a TextEdit glue, run: sudo gluemac /Applications/
TextEdit.app
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
------------------------------
Message: 3
Date: Sat, 03 Nov 2007 09:24:55 +1100
From: Shane Stanley <email@hidden>
Subject: Re: prevent user input question
To: AS users <email@hidden>
Message-ID: <C351EEE7.3E889%email@hidden>
Content-Type: text/plain; charset="US-ASCII"
On 3/11/07 3:51 AM, "Oakley Masten" <email@hidden> wrote:
> The process in question opens, modifies, prints and
> then saves a folder of Excel files. It uses GUI
> scripting and therefor is susceptible to errors if a
> user inputs anything by keyboard or mouse.
Why is it using GUI scripting?
--
Shane Stanley <email@hidden>
AppleScript Pro Florida, Feb 2008 <http://scriptingmatters.com/aspro>
------------------------------
Message: 4
Date: Fri, 2 Nov 2007 16:24:55 -0700
From: Christopher Nebel <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Nov 1, 2007, at 11:08 PM, Michelle Steiner wrote:
> It doesn't return any errors, but it doesn't do anything either. I
> suspect that it is a permissions issue, but I have no idea of how to
> address it.
>
> tell application "System Events"
> tell property list file
> "Dora:System:Library:LaunchDaemons:com.apple.backupd-auto.plist"
> set value of property list item 4 of it to 7200
> end tell
> end tell
Permissions is a good guess, since at least on my system, that file is
only writable by root. Since System Events doesn't have a way to
authenticate file operations, the best I can suggest is to change the
permissions on the file -- 'do shell script "chmod a+w /System/Library/
LaunchDaemons/com.apple.backupd-auto.plist" with administrator
privileges' should do the trick.
Beware that "property list item 4" is not reliable. Property list
items in a dictionary (such as this one is) are not in any
deterministic order, and may move if the file is changed. Referring
to them by name (e.g., 'property list item "StartInterval"') is a much
better way to go.
--Chris Nebel
AppleScript Engineering
------------------------------
Message: 5
Date: Fri, 2 Nov 2007 19:35:00 -0400
From: "Mark J. Reed" <email@hidden>
Subject: Re: [Slightly OT] Scripting Bridge in Leopard
To: has <email@hidden>, email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=UTF-8
What, no ruby appscript version? Tsk.
:)
On 11/2/07, has <email@hidden> wrote:
> On 1 Nov 2007, at 13:21, Rob Stott wrote:
>
> > I was kind of wondering whether anyone had a working example so I
> > could compare theirs to my ham-fisted effort!
>
> Still working on fully grokking SB myself, but if you're curious,
> here's a really basic comparison I just whipped up between
> AppleScript, SB, appscript and Mac::Glue:
>
>
> ------- AppleScript -------
>
> #!/usr/bin/osascript
>
> tell application id "com.apple.textedit"
> get paragraph 1 of document "Read Me.txt"
> end tell
>
>
> ------- Scripting Bridge (via PyObjC) -------
>
> #!/usr/bin/python
>
> from ScriptingBridge import *
>
> textedit =
> SBApplication.alloc().initWithBundleIdentifier_('com.apple.textedit')
> print `textedit.documents().objectWithName_('Read
> Me.txt').text().paragraphs()[0].get()`
>
>
> ------- py-appscript [1] -------
>
> #!/usr/bin/python
>
> from appscript import *
>
> textedit = app(id='com.apple.textedit')
> print `textedit.documents['Read Me.txt'].paragraphs[1].get()`
>
>
> ------- Mac::Glue [2] -------
>
> #!/usr/bin/perl
>
> use Mac::Glue;
>
> my $te = new Mac::Glue('TextEdit');
> print $te->obj('document' => 'Read Me.txt')->obj('paragraph' => 1)->get;
>
>
>
> I'll try to post some less trivial examples as and when time allows.
>
> has
>
> [1] Folks wanting to use appscript on Leopard's stock Python install
> should download and unpack 'appscript-0.17.2.tar.gz' from
> <http://appscript.sourceforge.net
> >, cd to the appscript-0.17.2 folder and run 'python setup.py
> install'. (Note that you'll need to have gcc - included in Apple's Dev
> Tools - installed.) New binary installers, eggs, etc. are on my TODO
> list for later this month.
>
> [2] To make a TextEdit glue, run: sudo gluemac /Applications/
> TextEdit.app
>
> --
> http://appscript.sourceforge.net
> http://rb-appscript.rubyforge.org
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
--
Mark J. Reed <email@hidden>
------------------------------
Message: 6
Date: Fri, 2 Nov 2007 19:37:46 -0400
From: "Mark J. Reed" <email@hidden>
Subject: Re: Running Scripts
To: "Ruby Madraswala" <email@hidden>, "AppleScript-Users
Mail" <email@hidden>
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=UTF-8
Why not use Folder Actions to trigger the scripts only when a file is
added to the folder, rather than having them check over and over?
On 11/2/07, Ruby Madraswala <email@hidden> wrote:
> I have about 15 scripts running; all the scripts check their respective
> hotfolder and if it finds a file it processes the file. Files are
> dropped in hotfolder about 2 -10 times a day. The scripts check the
> hotfolders every 2-5 minutes. Running all script at same time slows the
> computer
>
> I know how to check for files in a folder, but how I do call a script to
> run from a folder on the desktop.
>
>
> If file in hotfolder1
> Run script1
> End if
>
> If file in hotfolder2
> Run script2
> End if
>
> And so on. This way the scripts run only when there is a file in any of
> the hotfolders. This hopefully will avoid 15 scripts to run
> simultaneously OR any other suggestions.
>
>
> Thanks
>
> Ruby
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
--
Mark J. Reed <email@hidden>
------------------------------
Message: 7
Date: Fri, 2 Nov 2007 17:13:19 -0700
From: Michelle Steiner <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Nov 2, 2007, at 4:24 PM, Christopher Nebel wrote:
> Permissions is a good guess, since at least on my system, that file
> is only writable by root. Since System Events doesn't have a way to
> authenticate file operations, the best I can suggest is to change
> the permissions on the file -- 'do shell script "chmod a+w /System/
> Library/LaunchDaemons/com.apple.backupd-auto.plist" with
> administrator privileges' should do the trick.
That worked. How do I change it back, programatically, after writing
to it?
> Beware that "property list item 4" is not reliable. Property list
> items in a dictionary (such as this one is) are not in any
> deterministic order, and may move if the file is changed. Referring
> to them by name (e.g., 'property list item "StartInterval"') is a
> much better way to go.
Understood, but that generated an error when I tried it. Curiously,
it doesn't generate one now (before changing permissions, that is).
After changing permissions, it works just fine.
-- Michelle
--
if u cn rd ths u cn gt a gd jb, bt if u rt lk ths u r a mrn.
------------------------------
Message: 8
Date: Fri, 2 Nov 2007 17:33:37 -0700
From: Rick Gordon <email@hidden>
Subject: AppleScript URL Protocol
To: email@hidden
Message-ID: <p06230922c35171e151c7@[192.168.1.69]>
Content-Type: text/plain; charset="us-ascii"
I'm seeking documentation on the AppleScript URL Protocol, but all links that I find in Google searches have been removed.
Can anyone point me to documentation on it?
Thanks.
--
___________________________________________________
RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________
WWW: http://www.shelterpub.com
------------------------------
Message: 9
Date: Fri, 2 Nov 2007 17:55:52 -0700
From: Christopher Nebel <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Nov 2, 2007, at 5:13 PM, Michelle Steiner wrote:
> On Nov 2, 2007, at 4:24 PM, Christopher Nebel wrote:
>
>> Permissions is a good guess, since at least on my system, that file
>> is only writable by root. Since System Events doesn't have a way
>> to authenticate file operations, the best I can suggest is to
>> change the permissions on the file -- 'do shell script "chmod a+w /
>> System/Library/LaunchDaemons/com.apple.backupd-auto.plist" with
>> administrator privileges' should do the trick.
>
> That worked. How do I change it back, programatically, after
> writing to it?
If you're willing to assume that it's supposed to be root-writable
only, then use the same chmod(1) command, but change "a+w" to "go-w".
If you want to get the old permissions and then set them back (in
other words, make it general purpose for any file), then it's harder.
I'd suggest using Finder to do it, seeing as how it reads a lot
better, but unfortunately it doesn't work -- Finder just doesn't try
to authenticate the "set" operation and simply ignores it.
--Chris Nebel
AppleScript Engineering
------------------------------
Message: 10
Date: Fri, 2 Nov 2007 18:24:02 -0700
From: Michelle Steiner <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Nov 2, 2007, at 5:55 PM, Christopher Nebel wrote:
>> That worked. How do I change it back, programatically, after
>> writing to it?
>
> If you're willing to assume that it's supposed to be root-writable
> only, then use the same chmod(1) command, but change "a+w" to "go-w".
Thanks. Muchl appreciated.
-- Michelle
--
"As a matter of general principle, I believe there can be no doubt
that criticism in time of war is essential to the maintenance of any
kind of democratic government ... too many people desire to suppress
criticism simply because they think that it will give some comfort to
the enemy to know that there is such criticism." -- Robert A. Taft,
December 19, 1941
------------------------------
Message: 11
Date: Fri, 02 Nov 2007 18:59:16 -0700
From: Paul Berkowitz <email@hidden>
Subject: Re: prevent user input question
To: AppleScript-Users <email@hidden>
Message-ID: <C3512404.3EE7D¾email@hidden>
Content-Type: text/plain; charset="US-ASCII"
On 11/2/07 9:51 AM, "Oakley Masten" <email@hidden> wrote:
>
> The process in question opens, modifies, prints and
> then saves a folder of Excel files. It uses GUI
> scripting and therefor is susceptible to errors if a
> user inputs anything by keyboard or mouse. So can I
> suspend input until the script finishes? If so how?
Don't use GUI scripting then. Use Excel AppleScripting.
GUI scripting is a poor relation to be used for unscriptable apps when
there's no alternative.
--
Paul Berkowitz
------------------------------
Message: 12
Date: Fri, 02 Nov 2007 22:42:07 -0500
From: Laine Lee <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <C351583F.89CFE%email@hidden>
Content-Type: text/plain; charset="US-ASCII"
On 11/2/07 6:24 PM, "Christopher Nebel" <email@hidden> wrote:
> Permissions is a good guess, since at least on my system, that file is
> only writable by root.
OK, and why doesn't this script work?
property newline : ASCII character 10
property tmpfile : "/tmp/execme"
set theshellscript to "#!/bin/sh " & newline & "osascript -e \"tell
application \\\"System Events\\\"
tell property list file
\\\"dora:System:Library:LaunchDaemons:com.apple.backupd-auto.plist\\\"
set value of property list item 4 of it to 7200
end tell
end tell\""
do shell script "echo
" & quoted form of theshellscript & " > " & tmpfile
do shell script "chmod +x" & space & tmpfile
do shell script tmpfile & space & "> /dev/null 2>&1 &" with administrator
privileges
--
Laine Lee
------------------------------
Message: 13
Date: Fri, 2 Nov 2007 21:27:24 -0700
From: Michelle Steiner <email@hidden>
Subject: Re: Why doesn't this script work?
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
Here is the penultimate version of the script; I need to put in some
error checking to ensure that only a number is entered into the dialog.
-- Michelle
set the DialogReturn to (display dialog "Enter the backup interval you
wish." default answer "1" buttons {"Hours", "Minutes", "Cancel"}
default button "Hours" with title "Set Time Machine Backup Interval")
set the RawNumber to the text returned of the DialogReturn as number
set the TimeUnit to the button returned of the DialogReturn
if the TimeUnit is "Minutes" then
set the BackupInterval to the RawNumber * minutes
else if the TimeUnit is "Hours" then
set the BackupInterval to the RawNumber * hours
end if
set the BackupInterval to the BackupInterval as integer
set thePath to ((path to library folder from system domain) as text) &
"LaunchDaemons:com.apple.backupd-auto.plist"
do shell script Ā¬ "chmod a+w /System/Library/LaunchDaemons/
com.apple.backupd-auto.plist" with administrator privileges
tell application "System Events"
tell property list file thePath
set value of property list item "StartInterval" of it to the
BackupInterval
end tell
end tell
do shell script "chmod go-w /System/Library/LaunchDaemons/
com.apple.backupd-auto.plist" with administrator privileges
--
"We have succeeded for 205 years in keeping the affairs of state
separate from the uncompromising idealism of religious groups and we
mustn't stop now. To retreat from that separation would violate the
principles of conservatism and the values upon which the framers built
this democratic republic." --Barry Goldwater,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/applescript-users/attachments/20071102/62f09c5d/attachment.html
------------------------------
_______________________________________________
AppleScript-Users mailing list
email@hidden
http://lists.apple.com/mailman/listinfo/applescript-users
End of AppleScript-Users Digest, Vol 4, Issue 526
*************************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden