Date   

Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

Well, thank you very much for pointing that out. I'll edit the post anyway so that it sticks to the documentation.

Jean-Christophe

On Dec 7, 2017, at 18:43, 2551phil <2551phil@...> wrote:

If it’s correct, it means what you think it means, but I’d still argue that unless that's officially documented, it is better not to rely on it.



Best


Phil
@sqwarq


On 7 Dec 2017, at 16:37, Jean-Christophe Helary <jean.christophe.helary@...> wrote:



On Dec 7, 2017, at 17:34, 2551phil <2551phil@...> wrote:

Good work! I shall retweet that.

BTW, you don’t need to specify both Program and Program Arguments in your plist. If you leave out the Program key (and the osascript string that follows it), launchd will take the first item in the Program Arguments array as the Program (which you correctly have as the path to osascript).

The way you’re doing it, you’re technically passing /usr/bin/osascript as the first argument to /usr/bin/osascript, which you don’t really want to do.

Ok, I found where I got this idea. It's in the http://www.launchd.info link:

When you provide both keys, the value of Program is the executable to be started. The first string in ProgramArguments will show up as argv[0] in the executable. If this makes no sense to you, just think that launchd will ignore it.

And indeed, it did not make sense to me :) But since it works I thought my comments in the code were not entirely wrong.

JC



Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



Re: How to script the launching of a script at a specific time...

Shane Stanley
 

On 7 Dec 2017, at 4:35 pm, Jean-Christophe Helary <jean.christophe.helary@gmail.com> wrote:

I just wrote an article on that issue.
May I ask what version of the OS you are running?

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Re: How to script the launching of a script at a specific time...

2551phil
 

If it’s correct, it means what you think it means, but I’d still argue that unless that's officially documented, it is better not to rely on it.



Best


Phil
@sqwarq


On 7 Dec 2017, at 16:37, Jean-Christophe Helary <jean.christophe.helary@...> wrote:



On Dec 7, 2017, at 17:34, 2551phil <2551phil@...> wrote:

Good work! I shall retweet that.

BTW, you don’t need to specify both Program and Program Arguments in your plist. If you leave out the Program key (and the osascript string that follows it), launchd will take the first item in the Program Arguments array as the Program (which you correctly have as the path to osascript).

The way you’re doing it, you’re technically passing /usr/bin/osascript as the first argument to /usr/bin/osascript, which you don’t really want to do.

Ok, I found where I got this idea. It's in the http://www.launchd.info link:

When you provide both keys, the value of Program is the executable to be started. The first string in ProgramArguments will show up as argv[0] in the executable. If this makes no sense to you, just think that launchd will ignore it.

And indeed, it did not make sense to me :) But since it works I thought my comments in the code were not entirely wrong.

JC



Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

On Dec 7, 2017, at 17:34, 2551phil <2551phil@gmail.com> wrote:

Good work! I shall retweet that.

BTW, you don’t need to specify both Program and Program Arguments in your plist. If you leave out the Program key (and the osascript string that follows it), launchd will take the first item in the Program Arguments array as the Program (which you correctly have as the path to osascript).

The way you’re doing it, you’re technically passing /usr/bin/osascript as the first argument to /usr/bin/osascript, which you don’t really want to do.
Ok, I found where I got this idea. It's in the http://www.launchd.info link:

When you provide both keys, the value of Program is the executable to be started. The first string in ProgramArguments will show up as argv[0] in the executable. If this makes no sense to you, just think that launchd will ignore it.
And indeed, it did not make sense to me :) But since it works I thought my comments in the code were not entirely wrong.

JC


Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

Phil,

You're right. I was confused. I'll correct the post later today.

Jean-Christophe 

On Dec 7, 2017, at 17:50, 2551phil <2551phil@...> wrote:


On 7 Dec 2017, at 15:41, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

My understanding was that if Program Arguments is there, Program is ignored.


Well, the docs say this:

  Program <string>
     This key maps to the first argument of execv(3) and indicates the abso-
     lute path to the executable for the job. If this key is missing, then the
     first element of the array of strings provided to the ProgramArguments
     will be used instead. This key is required in the absence of the
     ProgramArguments key.

     ProgramArguments <array of strings>
     This key maps to the second argument of execvp(3) and specifies the argu-
     ment vector to be passed to the job when a process is spawned. This key
     is required in the absence of the Program key.  IMPORTANT: Many people
     are confused by this key. Please read execvp(3) very carefully!


You may be right (I’d assume so, if your test scripts work), but I don’t see a statement that quite supports what you said. But at best it’s redundant to use Program when you’ve specified Program Args and correctly specified the path to the executable in the first item of the array. At worst, I dunno…


Best


Phil
@sqwarq

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



Re: How to script the launching of a script at a specific time...

2551phil
 


On 7 Dec 2017, at 15:41, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

My understanding was that if Program Arguments is there, Program is ignored.


Well, the docs say this:

  Program <string>
     This key maps to the first argument of execv(3) and indicates the abso-
     lute path to the executable for the job. If this key is missing, then the
     first element of the array of strings provided to the ProgramArguments
     will be used instead. This key is required in the absence of the
     ProgramArguments key.

     ProgramArguments <array of strings>
     This key maps to the second argument of execvp(3) and specifies the argu-
     ment vector to be passed to the job when a process is spawned. This key
     is required in the absence of the Program key.  IMPORTANT: Many people
     are confused by this key. Please read execvp(3) very carefully!


You may be right (I’d assume so, if your test scripts work), but I don’t see a statement that quite supports what you said. But at best it’s redundant to use Program when you’ve specified Program Args and correctly specified the path to the executable in the first item of the array. At worst, I dunno…


Best


Phil
@sqwarq


Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 



On Dec 7, 2017, at 17:34, 2551phil <2551phil@...> wrote:

Good work! I shall retweet that.

Wow, thank you Phil :-)

BTW, you don’t need to specify both Program and Program Arguments in your plist.

I know. I wrote about that in the comments. It is just that the sample files I got all had both, so I though it was better to keep the data just to be on the safe side.

If you leave out the Program key (and the osascript string that follows it), launchd will take the first item in the Program Arguments array as the Program (which you correctly have as the path to osascript).

The way you’re doing it, you’re technically passing /usr/bin/osascript as the first argument to /usr/bin/osascript, which you don’t really want to do.

Are you sure? That's not what I understood from the docs. My understanding was that if Program Arguments is there, Program is ignored. And the first element of Program Arguments is the argument to exec.


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



Re: How to script the launching of a script at a specific time...

2551phil
 

Good work! I shall retweet that.

BTW, you don’t need to specify both Program and Program Arguments in your plist. If you leave out the Program key (and the osascript string that follows it), launchd will take the first item in the Program Arguments array as the Program (which you correctly have as the path to osascript).

The way you’re doing it, you’re technically passing /usr/bin/osascript as the first argument to /usr/bin/osascript, which you don’t really want to do.


Best


Phil
@sqwarq


On 7 Dec 2017, at 12:35, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

I just wrote an article on that issue. Thank you all for your help.
(any comments are welcome)

https://mac4translators.blogspot.jp/2017/12/automation-scheduling-file-and.html

On Dec 2, 2017, at 12:19, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Ok, so the only way to actually launch a script at a given date/time is to use launchd I guess ?

On Dec 2, 2017, at 12:13, Shane Stanley <sstanley@...> wrote:

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work.

As noted elsewhere, you can't do that since macOS 10.9. The filepath property is a vestige of bygone carefree days.

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com




Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

I just wrote an article on that issue. Thank you all for your help.
(any comments are welcome)

https://mac4translators.blogspot.jp/2017/12/automation-scheduling-file-and.html

On Dec 2, 2017, at 12:19, Jean-Christophe Helary <jean.christophe.helary@...> wrote:

Ok, so the only way to actually launch a script at a given date/time is to use launchd I guess ?

On Dec 2, 2017, at 12:13, Shane Stanley <sstanley@...> wrote:

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work.

As noted elsewhere, you can't do that since macOS 10.9. The filepath property is a vestige of bygone carefree days.

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



How To Get List of Valid Time Zone IDs

 

Thanks for this handy script, Shane.
I started a new topic to help others find it.

Best Regards,

Jim Underwood
aka JMichaelTX


From: Shane Stanley <sstanley@...>
Date: Tuesday, December 5, 2017 at 12:32 AM
To: "ASUL (AppleScript)" <applescript-users@...>
Subject: Re: CalendarLib EC

"Japanese Standard Time" is not a valid time zone name in this context -- it really requires a zone ID. Try "Asia/Tokyo".

You can find out the valid entries like this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

current application's NSTimeZone's knownTimeZoneNames() as list


Re: How to script the launching of a script at a specific time...

Shane Stanley
 

On 2 Dec 2017, at 2:19 pm, Jean-Christophe Helary <jean.christophe.helary@gmail.com> wrote:

Ok, so the only way to actually launch a script at a given date/time is to use launchd I guess ?
You can still do it via Calendar.app -- you just have to set the file manually. Otherwise it's probably a matter of launchd or a third-party utility.

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Re: How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

Ok, so the only way to actually launch a script at a given date/time is to use launchd I guess ?

On Dec 2, 2017, at 12:13, Shane Stanley <sstanley@...> wrote:

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work.

As noted elsewhere, you can't do that since macOS 10.9. The filepath property is a vestige of bygone carefree days.


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



Re: How to script the launching of a script at a specific time...

Shane Stanley
 

On 2 Dec 2017, at 1:09 pm, Jean-Christophe Helary <jean.christophe.helary@gmail.com> wrote:

I know I can use Calendar's "open file alert" to open a file at a specific time. It works fine when I manually create an event.

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work.
As noted elsewhere, you can't do that since macOS 10.9. The filepath property is a vestige of bygone carefree days.

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


How to script the launching of a script at a specific time...

Jean-Christophe Helary <jean.christophe.helary@...>
 

If there is an Applescript way to open a specific file at a given time that does not involve Calendar, I'm all for it, but right now I'm trying to focus on Calendar because that's where I manage all my jobs. So...

I know I can use Calendar's "open file alert" to open a file at a specific time. It works fine when I manually create an event.

What I want to do is to script the creation of that event, and for that I need to specify the filepath property of the "open file alert" but *that* doesn't work. I end up with an event that does *not* have a filepath and that won't open the file.

Conversely, when I manually create the alert, it does work *but* the event as explored in SD does not provide any value for the filepath property, so I have no way to see what I'm doing wrong.

Specifically:

tell application "Calendar"
activate
set job to make new event in calendar "test" with properties {allday event:true, status:confirmed, start date:(date "Saturday, December 2, 2017 0:00:00"), end date:(date "Sunday, December 3, 2017 0:00:00"), description:"Test", summary:"launch file", location:"Jean-Christophe", url:""}
set filealert to make new open file alarm of job with properties {filepath:"/path/to/file", trigger date:(date "Friday, December 1, 2017 16:26:00")}
switch view to week view
show job
end tell

Plus, that code *sometimes* triggers a Calendar error that goes like this:


I take any suggestions that solves that Calendar issue (most probably caused to my poor coding skills), or any solution that bypasses Calendar but stays reasonably within what Applescript allows :-)


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



Re: Is it me or is Finder scripting broken?

John Stewart
 

Thanks Chris, that’s mostly a winner, at least I can now get and set the property. Hopefully I can eventually get the Finder to respond to the changes. For now I’ll just abort the script and set the preference manually.

JBS


On November 26, 2017 at 8:46:19 PM, Christopher Stone (listmeister@...) wrote:

On 11/26/2017, at 17:09, John Stewart <psamech@...> wrote:
I’m looking at the desktop not just any random Finder window.  I have a script that cleans my desktop by moving file/icons around, it won’t work if the Desktop isn’t set to snap top grid.


Hey John,

Try this:

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/11/26 19:40
# dMod: 2017/11/26 19:44
# Appl: Finder
# Task: Get Arrangement of Window of Desktop
# Libs: None
# Osax: None
# Tags: @ccstone, @Applescript, @Script, @Finder, @Arrangement, @Window, @Desktop
----------------------------------------------------------------

tell application "Finder"
    tell desktop
        tell its window
            if its current view = icon view then
                tell its icon view options
                    its arrangement
                end tell
            end if
        end tell
    end tell
end tell

----------------------------------------------------------------

--
Best Regards,
Chris


Re: Is it me or is Finder scripting broken?

Christopher Stone
 

On 11/26/2017, at 17:09, John Stewart <psamech@...> wrote:
I’m looking at the desktop not just any random Finder window.  I have a script that cleans my desktop by moving file/icons around, it won’t work if the Desktop isn’t set to snap top grid.


Hey John,

Try this:

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/11/26 19:40
# dMod: 2017/11/26 19:44
# Appl: Finder
# Task: Get Arrangement of Window of Desktop
# Libs: None
# Osax: None
# Tags: @ccstone, @Applescript, @Script, @Finder, @Arrangement, @Window, @Desktop
----------------------------------------------------------------

tell application "Finder"
    tell desktop
        tell its window
            if its current view = icon view then
                tell its icon view options
                    its arrangement
                end tell
            end if
        end tell
    end tell
end tell

----------------------------------------------------------------

--
Best Regards,
Chris


Re: Is it me or is Finder scripting broken?

John Stewart
 

Thanks Bob,

That works but doesn’t solve my problems. I’m looking at the desktop not just any random Finder window.  I have a script that cleans my desktop by moving file/icons around, it won’t work if the Desktop isn’t set to snap top grid.

JBS


On November 26, 2017 at 4:01:16 PM, Robert Poland (rpoland@...) wrote:

tell application "Finder"
activate
if ((current view of window index 1) = list view) then
set wdw to window 1
select wdw -- in case the window was not selected
tell wdw to tell its list view options
set m to width of column id modification date column
set width of column id modification date column to m + 1
set m to width of column id modification date column
set s to width of column id size column
set width of column id size column to s + 1
set s to width of column id size column
end tell
end if
end tell


Re: Is it me or is Finder scripting broken?

Robert Poland
 



On Nov 26, 2017, at 8:42 AM, John Stewart <psamech@...> wrote:

Can't get or set list, column or icon view properties:

tell
application id "com.apple.finder" -- Finder

get properties of Finder preferences

(* comment out next line to see all properties *)

get icon view options of result (* it's currently set to "snap to grid" but returns missing value *)

--get folders spring open of result (* this works, it's currently set to true *)

end tell


Maybe the following will be of some help;

tell application "Finder"
activate
if ((current view of window index 1) = list view) then
set wdw to window 1
select wdw -- in case the window was not selected
tell wdw to tell its list view options
set m to width of column id modification date column
set width of column id modification date column to m + 1
set m to width of column id modification date column
set s to width of column id size column
set width of column id size column to s + 1
set s to width of column id size column
end tell
end if
end tell

Robert Poland
Fort Collins, CO


Is it me or is Finder scripting broken?

John Stewart
 

Can't get or set list, column or icon view properties:

tell
application id "com.apple.finder" -- Finder

get properties of Finder preferences

(* comment out next line to see all properties *)

get icon view options of result (* it's currently set to "snap to grid" but returns missing value *)

--get folders spring open of result (* this works, it's currently set to true *)

end tell


Re: Trying to move away from Finder...

Christopher Stone
 

On 11/23/2017, at 09:33, 2551phil <2551phil@...> wrote:
I find this way slightly easier to remember (and type):


Hey Phil,

Remember?

Type?

I keep stuff like that in my snippets library, so they're a couple of keystrokes away.  :)

Still...  Good to know.

--
Take Care,
Chris

121 - 140 of 275