My earbuds are acting up and they keep on playing music when every they want to. I have used applescript before but is only to open apps not close them.
My earbuds are acting up and they keep on playing music when every they want to. I have used applescript before but is only to open apps not close them.
I'm not sure if you want some sort of background process (agent) that is always running, keeping an eye out to see if iTunes is running. And, whenever it opens, to close it, to prevent if from ever running If so, then, you need to run your AppleScript in some sort of loop. Here is some pseudocode to do so:
Code:
while (true) { // always run
tell application "iTunes"
quit
end tell
sleep 10 seconds // sleep so that you don't hog the CPU for no reason
}
Oh, I'm sorry, the second block of code was written in pseudocode (i.e. it shows you what you want to do logically, but it may not be syntactically correct). Sorry for confusing you.
Here's syntactically correct Applescript for the second block of code. This should work as is:
Code:
repeat
tell application "iTunes"
quit
end tell
// Sleeps (waits) 10 seconds. Adjust this time interval (in seconds) to what works for you.
// This is how often you want your script to "wake up" and check for iTunes running
delay 10
end repeat