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

            Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367