Jump to content

Associated keywords in workflows


Recommended Posts

I wanted to make a workflow that would easily allow me to make screen capture videos with QuickTime Player. 

 

I set up a workflow containing two "Keyword to AppleScript to Notification"

 

 

1) has keyword "screencast" that runs the following AppleScript

on alfred_script(q)
    tell application "QuickTime Player"
        activate
        start new screen recording
    end tell
    tell application "Finder" to set visible of process "QuickTime Player" to false
end alfred_script 

then outputs a notification that says "Recording..."

 

 

2) has keyword "stop" that runs the following AppleScript

on alfred_script(q)
    tell application "QuickTime Player" to stop document "screen recording"
end alfred_script

then outputs a notification that says "Finished recording."

 

 

I want to be able to associate those two keywords, where the second keyword "stop" requires the first keyword "screencast" to have been used first.

 

Typing "stop" into the Alfred window would not display a result unless "screencast" had been used first.

Edited by bradengammon
Link to comment
Share on other sites

I wanted to make a workflow that would easily allow me to make screen capture videos with QuickTime Player. 

 

I set up a workflow containing two "Keyword to AppleScript to Notification"

 

 

1) has keyword "screencast" that runs the following AppleScript

on alfred_script(q)
    tell application "QuickTime Player"
        activate
        start new screen recording
    end tell
    tell application "Finder" to set visible of process "QuickTime Player" to false
end alfred_script 

then outputs a notification that says "Recording..."

 

 

2) has keyword "stop" that runs the following AppleScript

on alfred_script(q)
    tell application "QuickTime Player" to stop document "screen recording"
end alfred_script

then outputs a notification that says "Finished recording."

 

 

I want to be able to associate those two keywords, where the second keyword "stop" requires the first keyword "screencast" to have been used first.

 

Typing "stop" into the Alfred window would not display a result unless "screencast" had been used first.

 

Thanks for the suggestions but I'm not sure something like would be in the best interest of the user as it would more than likely have a performance penalty associated with it. Alfred would be required to check an associated state of every workflow whenever input was entered. I know it isn't an ideal situation but this would be better handled inside of the workflow itself.

 

For instance, you could check the current time value of document 1 of Quicktime Player. If document 1 doesn't exist or the return value is NaN then it isn't playing/recording. If it is a number, assume its playing/recording and stop.

Link to comment
Share on other sites

I see what you are saying about slowing Alfred down.

 

Thanks for the idea. I don't know if it would do much to help my situation. If there is no QuickTime document, then the second script won't have any effect anyway. It's relying mostly on the application's default behavior, so I'm not really concerned.

 

I am completely new to AppleScript however, so is there a way that I can prevent the notification output from appearing if the second AppleScript were to return false or something like that?

 

Thanks

Link to comment
Share on other sites

I see what you are saying about slowing Alfred down.

 

Thanks for the idea. I don't know if it would do much to help my situation. If there is no QuickTime document, then the second script won't have any effect anyway. It's relying mostly on the application's default behavior, so I'm not really concerned.

 

I am completely new to AppleScript however, so is there a way that I can prevent the notification output from appearing if the second AppleScript were to return false or something like that?

 

Thanks

 

You could make it check to see if document 1 exists. If not, just exit.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...