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;
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
add a comment |
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
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
add a comment |
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
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
applescript automation
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered 5 hours ago
wch1zpinkwch1zpink
3,8065 silver badges21 bronze badges
3,8065 silver badges21 bronze badges
add a comment |
add a comment |
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