functions – AppleScript App to begin a Slideshow in Finder


I do not need an M1 Mac, nevertheless, the next was examined and works on an Intel based mostly Mac operating macOS Massive Sur.

The intent of the instance AppleScript code, proven under, is to imitate the handbook occasions crucial to begin a slideshow of the chosen objects in Finder, or the contents of the window itself with nothing chosen, by doing it with an AppleScript software positioned in its Toolbar.

  • If nothing is chosen within the entrance window when the app icon is clicked within the Toolbar, then all objects are chosen and the slideshow begins.

  • If particular person information are chosen within the entrance window when the app icon is clicked within the Toolbar, the slideshow begins with the chosen particular person information.

  • If a folder is chosen within the entrance window when the app icon is clicked within the Toolbar, then if the folder shouldn’t be already opened, its opened, the objects are chosen and the slideshow begins. If the folder is already opened, the objects are chosen and the slideshow begins. This takes under consideration the assorted views the window might be in, i.e., icon view, checklist view, or column view.

Word that no different manipulation of the state of the entrance window is tried after the slideshow finishes as a result of, if it was began manually, every other actions must be carried out so manually after the very fact anyway. Moreover, any AppleScript technique employed, if attainable, to set off one thing after the slideshow finishes would most likely be useful resource intensive, having to consistently monitor its state and act accordingly. Due to this fact I don’t think about it sensible to implement, even when it is attainable to do.

The instance AppleScript code was saved as an AppleScript software named Begin Slideshow in Script Editor, given a customized icon in Finder and added to its Toolbar, as proven within the picture under.

enter image description here


Instance AppleScript code:

inform software "Finder"
    activate
    set mySelection to choice
    if mySelection is {} then
        set choice to each merchandise of entrance window
        my startSlideshow()
    else
        set mySelectionAlias to first merchandise of mySelection as alias
        set mySelectionAliasProperties to properties of mySelectionAlias
        if the category of mySelectionAliasProperties is folder then
            if identify of entrance window is the same as identify of mySelectionAliasProperties then
                set choice to each merchandise of entrance window
                my startSlideshow()
            else
                my openFolder()
                set choice to each merchandise of entrance window
                my startSlideshow()
            finish if
        else
            my startSlideshow()
        finish if
    finish if
finish inform

on openFolder()
    inform software "System Occasions" to ¬
        key code 31 utilizing command down
    delay 0.2
finish openFolder

on startSlideshow()
    inform software "System Occasions" to ¬
        key code 49 utilizing possibility down
finish startSlideshow

Word: The instance AppleScript code is simply that and doesn’t comprise any error dealing with as could also be acceptable. The onus is upon the person so as to add any error dealing with as could also be acceptable, wanted or needed. Take a look on the strive assertion and error assertion within the AppleScript Language Information. See additionally, Working with Errors. Moreover, the usage of the delay command could also be crucial between occasions the place acceptable, e.g. delay 0.5, with the worth of the delay set appropriately.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles