How to start an application when a specific disk is mountedHow to start a service automatically after openning an application?How can messages be scripted whenever I open a specific application?Application to launch specific applications, windows, and tabsRun applescript after specific application launchHow can I start a Hangouts phone call with Applescript/Terminal?How to periodically run a script/command when a specific application is being used?Open application in specific space through AppleScriptHow To Have A Custom Action Located Within An Applescript.app, Execute Only On Every Fifth Launch Of The ApplicationAppleScript: How to close notification alerts from a specific application?Applescript Tell Application of Specific Instance

"I you already know": is this proper English?

What does "see" in "the Holy See" mean?

Why did Saturn V not head straight to the moon?

3D Statue Park: U shapes

Why does RPM for a fixed-pitch propeller change with an aircraft's pitch?

Convert every file from JPEG to GIF in terminal

Writing a clean implementation of Rock, Paper, Scissors game in c++

Why is it considered Acid Rain with pH <5.6

How can I prevent corporations from growing their own workforce?

Why was Sauron preparing for war instead of trying to find the ring?

Is it legal for private citizens to "impound" e-scooters?

Spoken encryption

When going by a train from Paris to Düsseldorf (Thalys), can I hop off in Köln and then hop on again?

How can I stop myself from micromanaging other PCs' actions?

TSA asking to see cell phone

How acidic does a mixture have to be for milk to curdle?

Does the Intel 8086 CPU have user mode and kernel mode?

The Sword in the Stone

How do we explain the E major chord in this progression?

Basic Questions on Wiener Filtering

Anybody know what this small Nintendo stand is for?

Inadvertently nuked my disk permission structure - why?

Is this photo showing a woman posing in the nude before teenagers real?

Is it normal practice to screen share with a client?



How to start an application when a specific disk is mounted


How to start a service automatically after openning an application?How can messages be scripted whenever I open a specific application?Application to launch specific applications, windows, and tabsRun applescript after specific application launchHow can I start a Hangouts phone call with Applescript/Terminal?How to periodically run a script/command when a specific application is being used?Open application in specific space through AppleScriptHow To Have A Custom Action Located Within An Applescript.app, Execute Only On Every Fifth Launch Of The ApplicationAppleScript: How to close notification alerts from a specific application?Applescript Tell Application of Specific Instance






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I store all my music on an external drive. I have iTunes set to start when I login. However, iTunes always starts before my encrypted drive has mounted, and so iTunes complains it can't find its library.



I've tried writing an Applescript which repeatedly checks to see if a drive is mounted, and when it is launches iTunes.



tell application "System Events" to set diskNames to name of every disk
set iTunesDiskName to "Media"
set iTunesDiskIsMounted to false
set iTunesLaunched to false
if iTunesDiskName is in diskNames then set iTunesDiskIsMounted to true


repeat while iTunesLaunched is false
if iTunesDiskIsMounted is true then
tell application "iTunes" to launch
set iTunesLaunched to true
end if
delay 5
end repeat


This does work to launch iTunes if I run it with the drive mounted. However if I run it with the drive unmounted, it keeps running and never detects if the disk is subsequently mounted.



What am I doing wrong?










share|improve this question
























  • Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

    – Solar Mike
    8 hours ago











  • simply, how does iTunesLaunched ever get to be true. Explain.

    – historystamp
    7 hours ago

















2















I store all my music on an external drive. I have iTunes set to start when I login. However, iTunes always starts before my encrypted drive has mounted, and so iTunes complains it can't find its library.



I've tried writing an Applescript which repeatedly checks to see if a drive is mounted, and when it is launches iTunes.



tell application "System Events" to set diskNames to name of every disk
set iTunesDiskName to "Media"
set iTunesDiskIsMounted to false
set iTunesLaunched to false
if iTunesDiskName is in diskNames then set iTunesDiskIsMounted to true


repeat while iTunesLaunched is false
if iTunesDiskIsMounted is true then
tell application "iTunes" to launch
set iTunesLaunched to true
end if
delay 5
end repeat


This does work to launch iTunes if I run it with the drive mounted. However if I run it with the drive unmounted, it keeps running and never detects if the disk is subsequently mounted.



What am I doing wrong?










share|improve this question
























  • Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

    – Solar Mike
    8 hours ago











  • simply, how does iTunesLaunched ever get to be true. Explain.

    – historystamp
    7 hours ago













2












2








2


2






I store all my music on an external drive. I have iTunes set to start when I login. However, iTunes always starts before my encrypted drive has mounted, and so iTunes complains it can't find its library.



I've tried writing an Applescript which repeatedly checks to see if a drive is mounted, and when it is launches iTunes.



tell application "System Events" to set diskNames to name of every disk
set iTunesDiskName to "Media"
set iTunesDiskIsMounted to false
set iTunesLaunched to false
if iTunesDiskName is in diskNames then set iTunesDiskIsMounted to true


repeat while iTunesLaunched is false
if iTunesDiskIsMounted is true then
tell application "iTunes" to launch
set iTunesLaunched to true
end if
delay 5
end repeat


This does work to launch iTunes if I run it with the drive mounted. However if I run it with the drive unmounted, it keeps running and never detects if the disk is subsequently mounted.



What am I doing wrong?










share|improve this question
















I store all my music on an external drive. I have iTunes set to start when I login. However, iTunes always starts before my encrypted drive has mounted, and so iTunes complains it can't find its library.



I've tried writing an Applescript which repeatedly checks to see if a drive is mounted, and when it is launches iTunes.



tell application "System Events" to set diskNames to name of every disk
set iTunesDiskName to "Media"
set iTunesDiskIsMounted to false
set iTunesLaunched to false
if iTunesDiskName is in diskNames then set iTunesDiskIsMounted to true


repeat while iTunesLaunched is false
if iTunesDiskIsMounted is true then
tell application "iTunes" to launch
set iTunesLaunched to true
end if
delay 5
end repeat


This does work to launch iTunes if I run it with the drive mounted. However if I run it with the drive unmounted, it keeps running and never detects if the disk is subsequently mounted.



What am I doing wrong?







applescript automation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago









historystamp

1,1666 silver badges11 bronze badges




1,1666 silver badges11 bronze badges










asked 8 hours ago









dunxddunxd

3153 silver badges20 bronze badges




3153 silver badges20 bronze badges












  • Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

    – Solar Mike
    8 hours ago











  • simply, how does iTunesLaunched ever get to be true. Explain.

    – historystamp
    7 hours ago

















  • Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

    – Solar Mike
    8 hours ago











  • simply, how does iTunesLaunched ever get to be true. Explain.

    – historystamp
    7 hours ago
















Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

– Solar Mike
8 hours ago





Should you re-evaluate the check for the disk names after the delay and before the end repeat? Otherwise it keeps rechecking a value already set to false...

– Solar Mike
8 hours ago













simply, how does iTunesLaunched ever get to be true. Explain.

– historystamp
7 hours ago





simply, how does iTunesLaunched ever get to be true. Explain.

– historystamp
7 hours ago










1 Answer
1






active

oldest

votes


















2














Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login.



Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer.



on run
-- Executed when the script is launched
checkForMedia()
end run

on idle
-- checks every five seconds if diskNames contains "Media"
checkForMedia()
return 5 -- in seconds
end idle

on checkForMedia()
tell application "System Events" to set diskNames to name of every disk
if diskNames contains "Media" then
tell application "iTunes" to launch
quit me -- Quits this applet after diskNames contains "Media" and launches itunes
end if
end checkForMedia

on quit
continue quit -- allows the script to quit
end quit





share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login.



    Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer.



    on run
    -- Executed when the script is launched
    checkForMedia()
    end run

    on idle
    -- checks every five seconds if diskNames contains "Media"
    checkForMedia()
    return 5 -- in seconds
    end idle

    on checkForMedia()
    tell application "System Events" to set diskNames to name of every disk
    if diskNames contains "Media" then
    tell application "iTunes" to launch
    quit me -- Quits this applet after diskNames contains "Media" and launches itunes
    end if
    end checkForMedia

    on quit
    continue quit -- allows the script to quit
    end quit





    share|improve this answer



























      2














      Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login.



      Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer.



      on run
      -- Executed when the script is launched
      checkForMedia()
      end run

      on idle
      -- checks every five seconds if diskNames contains "Media"
      checkForMedia()
      return 5 -- in seconds
      end idle

      on checkForMedia()
      tell application "System Events" to set diskNames to name of every disk
      if diskNames contains "Media" then
      tell application "iTunes" to launch
      quit me -- Quits this applet after diskNames contains "Media" and launches itunes
      end if
      end checkForMedia

      on quit
      continue quit -- allows the script to quit
      end quit





      share|improve this answer

























        2












        2








        2







        Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login.



        Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer.



        on run
        -- Executed when the script is launched
        checkForMedia()
        end run

        on idle
        -- checks every five seconds if diskNames contains "Media"
        checkForMedia()
        return 5 -- in seconds
        end idle

        on checkForMedia()
        tell application "System Events" to set diskNames to name of every disk
        if diskNames contains "Media" then
        tell application "iTunes" to launch
        quit me -- Quits this applet after diskNames contains "Media" and launches itunes
        end if
        end checkForMedia

        on quit
        continue quit -- allows the script to quit
        end quit





        share|improve this answer













        Save this following AppleScript code as a "stay open" application in Script Editor.app. Disable iTunes starting up at login but enable your new "stay open" application to start at login.



        Be sure to grant appropriate permissions in System Preferences for your new applet to control your computer.



        on run
        -- Executed when the script is launched
        checkForMedia()
        end run

        on idle
        -- checks every five seconds if diskNames contains "Media"
        checkForMedia()
        return 5 -- in seconds
        end idle

        on checkForMedia()
        tell application "System Events" to set diskNames to name of every disk
        if diskNames contains "Media" then
        tell application "iTunes" to launch
        quit me -- Quits this applet after diskNames contains "Media" and launches itunes
        end if
        end checkForMedia

        on quit
        continue quit -- allows the script to quit
        end quit






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 5 hours ago









        wch1zpinkwch1zpink

        3,8065 silver badges21 bronze badges




        3,8065 silver badges21 bronze badges













            Popular posts from this blog

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її