9.8 C
United States of America
Monday, November 25, 2024

functions – AppleScript App to begin a Slideshow in Finder


I don’t have an M1 Mac, nonetheless, the next was examined and works on an Intel based mostly Mac working macOS Huge Sur.

The intent of the instance AppleScript code, proven under, is to imitate the guide occasions vital 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 into consideration the varied views the window might be in, i.e., icon view, record view, or column view.

Be aware 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 completed so manually after the very fact anyway. Moreover, any AppleScript technique employed, if potential, to set off one thing after the slideshow finishes would in all probability be useful resource intensive, having to continuously monitor its state and act accordingly. Due to this fact I don’t take into account it sensible to implement, even when it is potential 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

Be aware: The instance AppleScript code is simply that and doesn’t include any error dealing with as could also be acceptable. The onus is upon the consumer so as to add any error dealing with as could also be acceptable, wanted or wished. 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 vital 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