Monday, October 22, 2018
  • Index
  •  » Automator
  •  » How do I script for quitting application and hitting "quit" button?

#1 2018-02-06 09:29:52 am

muralwork
Member
Registered: 2017-06-13
Posts: 2

How do I script for quitting application and hitting "quit" button?

I'm making an Automator application to quit "Wondershare AllMyMusic" after a 3-hr pause while it records.  I have a 3-hr "pause" action but I can't use the "quit application" action because I get a "Do you want to quit?" pop up window with a "Don't Quit" white button and a "Quit" blue button that can be selected by hitting return.  I know almost nothing about writing script but here is what I've attempted, so far, trying to use the return key to select the "Quit" button:

Applescript:


tell application "Wondershare AllMyMusic"
activate
delay 1
quit
delay 1
tell application "System Events"
tell process "Wondershare AllMyMusic"
keystroke "return"
end tell
end tell
end tell

It seems like this would be a common thing to run across for someone attempting to automate quitting an application but I've been unable to find information on this subject.

Last edited by muralwork (2018-02-06 01:45:43 pm)

Offline

 

#2 2018-02-06 04:58:54 pm

muralwork
Member
Registered: 2017-06-13
Posts: 2

Re: How do I script for quitting application and hitting "quit" button?

I found the answer to my question.  Here is the code that worked (it uses command-Q to quit then keystroke return):

Applescript:


tell application "System Events"
set frontmost of process "Wondershare AllMyMusic" to true
keystroke "q" using command down
keystroke return
end tell

Offline

 
  • Index
  •  » Automator
  •  » How do I script for quitting application and hitting "quit" button?

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)