Basically, if I'd like to be able to handle a print job initialization command. Like hitting Cmd+P on a document or something. I'd like to be able to access the data being printed and programmatically handle it rather than through a GUI.
Thanks!
You can possibly use the OSX automator to do what you need here. It depends on what you want to get out of the printed document. Automator allows you to create print plugins, which you can select from the system print dialog. I see you mentioned already that you don't want to use the "PDF" print menu as is, but perhaps some value can be added with extra automation in a print plugin. The plugin will create a .pdf of the printed documents, to which you can apply an automated sequence of actions.
Start /Applications/Automator
Under "Choose a type for your document:", choose "Print Plugin"
Then set up a sequence of actions you need to process your printed document. For example, you might want to do "Extract PDF Text" or "PDF to Images". Type "pdf" in the search field to see all the pdf-related actions available.
Save the automator workflow. You will only be able to give it a name, but not save it as a file in an arbitrary path.
You can use the plugin by opening the system print dialog in any given application, then dropping down the "PDF" menu in the bottom left-hand corner. You should see your plugin appear there.
Related
I'm looking for a solution to be able to select a text on an app(Figma) and then reverse it then store reverse version to the clipboard.
I used BetterTouchBar app for saving selected text but I can't do anything with it.
How can I do that with or without BetterTouchbar App.
Thanks a lot.
Create an Automator Quick Action1, setting Workflow receives current text in any application and add a Run AppleScript action, adding the following line of example AppleScript code where is says: (* Your script goes here *)
set the clipboard to the (reverse of characters of item 1 of input) as text
Save the Quick Action as e.g.: Reverse Selected Text To Clipboard
It's now available from the Services menu in any application, e.g. TextEdit > Services, or the Services menu on the Context menu (right-click menu).
You can also assign a keyboard shortcut in: System Preferences > Keyboard > Shortcuts > Services
1 In versions of macOS prior to Mojave a Quick Action is called a Service.
Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the used to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.
I wrote a simple jsx script, which displays a dialog box containing a list of checkboxes and 'Continue' button, which on click executes various commands depending on which items from the list were ticked.
As this script is supposed to be part of an Action Set, I created an action which just executes this script.
When I run the command File > Automate > Batch > The above action on a Folder or opened files, the dialog box shows for every image from the batch.
Is there any way to show this dialog box only once and apply all its settings to the whole batch?
The better way to accomplish this is to add a folder picker to your dialog and modify the script to loop through all images in the folder (or open files, whatever your needs are) rather than attempt to run the script via an action. If you really must have it in an action, the way I have done this before is to write a xml config file that the script will look for and apply the settings from there - skipping the dialog altogether.
I am building a Delphi application which opens an image and its metadata and prints it. For the Windows version I build a form to generate the PrintPreview, but in Mac I can use the Print Dialog's 'Open PDF in Preview' instead. When I click on it, a PDF file is generated and I can see it, its OK. The problem is I want to access this option directly from a button, so when the button is clicked, the PDF in Preview is opened and the user does not have to open the Print Dialog, then click the 'PDF' and then select 'Open PDF in Preview'. How can I do this?
I read about using Automator, apple scripts etc, but I still can't find it.
Is there any path this generated PDF Preview is stored, so maybe I can open it from there?...
TIA
Possible duplicate of Using Automator or Applescript or both to recursively print documents to PDF but I'll answer anyways.
To answer your question directly see the question I linked to. Basically you need to use System Events from applescript to accomplish that exactly
However, there's a quicker solution using /usr/sbin/cupsfilter. Check the man page for more.
You can call cupsfilter <an-image-file> and you'll get a PDF on stdout, courtesy of OSX's printing daemon. It looks quite configurable but I just learned about it a while ago.
If you want this to open for the user you can save it in a nice place or you can do it the one-shot way and do cupsfilter <your-image> | open -f -a "Preview" to open the PDF right up.
I have custom Alfred workflow to File Filter some folders of my choice. I have two actions - to browse with Alfred, and, with CMD modifier, to open in Sublime.
I want to have an action where I may choose which program I want to open it in. I use 2-3 programs for basic editing, so I want to be able to select one of these.
Workflow would be:
start my workflow
enter few chars to find file
select a file with CMD
choose editor of choice from the list
How to implement the last thing? In other words, how to implement incremental actions e.g. "do this with this and then this".
There're two ways to do it.
Because you can choose which application will be used to open the file instead of the default one. A simple idea is using different keyword for each application. e.g. vim [file-name] for vim while sublime [file-name] for sublime.
Another way is using Run Script instead of Open File. An Apple script or Bash script can get the result in File Filter and open different application as you wish.
I want to replace the standard system open file dialog with the one I wrote, that means no matter within which programs you are opening a file, my dialog will be shown instead of the standard one, is this possible?
It seems that that there is no such API provided to accomplish this, is it possible to use some hooking technique, but this has to be reliable and not to be treated as spyware by anti-virus tools?
any other options?
If this is not possible, is it possible to add to the spacebar or toolbar in the standard open file dialog a button which invokes my dialog, which allow users select a file and in turn returns the path of the selected file to the "File name" input box of the standard dialog?
Any hits, links and code examples will be appreciated.
Starting in Vista, the FileOpen/FileSave dialogs are now "Common Item Dialogs" of which IFileOpenDialog & IFileSaveDialog are the two published implementations.
Since they're just COM objects with known CLSIDs you might get away with just replacing them by re-registering using their CLSIDs. Never tried something like that, might trip all sorts of alarm bells.
Pre-Vista file dialogs can be hooked in process, but I've never come across anything about global hooks or equivalent.
If you copy a file/folder to a dialog's filename field it usually pastes the full path anyway.
For example, if you have open both a program calling the standard open/save dialog box and also have a window open at the file or path that you want to work with (open from/save to), you can simply copy the file/folder from the explorer window, and then paste into the filename field of the dialog box, and it will insert the full path of the file/folder. No custom script is required!
Alternatively, for those programs that use custom dialog boxes where this step fails, copy the same file/folder in the window into the address bar of the same window (assuming it is visible). This will paste the full path, which you can copy again, and then paste this full path into the custom dialog box. I often use this when creating Office hyperlinks (Ctrl+K), because the Insert Hyperlink dialog does not work for the first method.
You can also use similar methods but paste into address bar fields and it works.