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
Is it legal for private citizens to "impound" e-scooters?
Why are all my history books dividing Chinese history after the Han dynasty?
How could a thief buying plane tickets with stolen credit card details benefit personally?
Why isn't there a ";" after "do" in sh loops?
Unethical behavior : should I report it?
Can two figures have the same area, perimeter, and same number of segments have different shape?
Why does RPM for a fixed-pitch propeller change with an aircraft's pitch?
Print sums of all subsets
What's the difference between 2a and 10a charging options?
Spoken encryption
Decreasing star size
When going by a train from Paris to Düsseldorf (Thalys), can I hop off in Köln and then hop on again?
How do campaign rallies gain candidates votes?
Terence Tao–type books in other fields?
Is my employer paying me fairly? Going from 1099 to W2
High income, sudden windfall
How do I stop my characters falling in love?
Why can't my huge trees be chopped down?
Expansion with *.txt in the shell doesn't work if no .txt file exists
Why do planes need a roll motion?
Why are so many countries still in the Commonwealth?
At what rate does the volume (velocity) of a note decay?
How acidic does a mixture have to be for milk to curdle?
How to handle a player that cannot be convinced his actions are a problem for both GM and party
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
7 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 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 4 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
7 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 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
7 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 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
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
7 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 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 4 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
7 hours ago
simply, how does iTunesLaunched ever get to be true. Explain.
– historystamp
6 hours ago