Jump to content

Print selected files - file action


Recommended Posts

  • 4 years later...
On 4/3/2019 at 3:26 AM, MrAu said:

Hi,

 

This workflow adds a File Action to allow for sending a document to your default printer.

Eg: send a document to printer, print selected files.sRT352g(1).png.d27726fe0fede376a1d723166a0cab4e.png

 

It takes an Automator workflow OWewDFN(1).png.18c44439667d6c170b7c776368c60565.png

 

and runs it like so DkPQSe7(1).png.e6f7f3fa71e7ae5f9934180ee2994c40.png

 

    /usr/bin/automator ./print-selected.workflow

 

download here https://github.com/fxjkhr/alfred-workflows/blob/master/print-selected.alfredworkflow

@vitor @Vero Is there a universal action that prints selected content in any application to default printer or open in preview?

Link to comment
4 hours ago, TomBenz said:

Is there a universal action that prints selected content in any application to default printer or open in preview?

I'm clearly missing something but, surely, outside Alfred (e.g., in Finder) ⌘P and pressing the spacebar respectively (i.e., no need for Universal Actions)? Inside Alfred (i.e., looking at Alfred's results) see Alfred Preferences → Features → Previews.

 

Stephen

Link to comment
21 minutes ago, Stephen_C said:

I'm clearly missing something but, surely, outside Alfred (e.g., in Finder) ⌘P and pressing the spacebar respectively (i.e., no need for Universal Actions)? Inside Alfred (i.e., looking at Alfred's results) see Alfred Preferences → Features → Previews.

 

Stephen

Thanks for your reply. Print command doesn't give option to print only selected text in outlook / safari etc. Got this code and Alfred workflow with universal action to achieve my desired outcome.

 

tell application "System Events"

keystroke "c" using {command down}

end tell

 

tell application "TextEdit"

activate

set newDoc to make new document

tell application "System Events" to keystroke "v" using command down

delay 0.2

activate

-- Ask the user if they want to print before closing

set printResponse to display dialog "Do you want to print the document before closing?" buttons {"Print", "Don't Print"} default button "Print"

 

-- Check the user's response

if button returned of printResponse is "Print" then

print front document without print dialog

end if

 

set saveResponse to display dialog "Do you want to save the document before closing?" buttons {"Save", "Don't Save"} default button "Don't Save"

 

-- Check the user's response

if button returned of printResponse is "Save" then

set desktopPath to path to desktop folder as text

set rtfFileName to "temp_text.rtf"

set rtfFilePath to desktopPath & rtfFileName

save front document in file rtfFilePath

end if

 

-- Close the document without saving it again

close window 1 with saving

end tell

Link to comment

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...