Just upgraded to Mojave.
I need to program screenshots and their co-ordinates via KM.
This used to work consistently in High Sierra.
Now it may work 1 out of 10 times in the app of KM, but have not got it to work at all in Preview or Safari which is where I need it.
I do know of the screen capture action, but need to take screenshots via Shift Command 4.
Basic test Macro is included.
Any help is appreciated
Do you, in fact, mean that you need to take screenshots of a selectable area whose coordinates you wish to be able to specify ?
You can do this with an Execute a Shell Script action, and the following command (which, in this instance, will save the screenshot to your Pictures folder):
screencapture -R0,0,100,100 -t jpg "$HOME/Pictures/Screenshot on $(date +'%Y-%m-%d at %H.%M.%S').jpg"
@CJK thank you.
How would I specify the active application window (and coordinates within it) and not the coordinates as they apply to the full screen?
This shell scripts coordinates are applied to the full screen and not the active window.
Also how would I use pre-set KM variables for the Left Top Width Height and name in that shell script? ie.
VarLeft
VarTop
VarWidth
VarHeight
VarName
Note: I'd like to use more KM type action if possible, no reason why, other than learning. And also that maybe there is a fix for why the Shift Command 4 cannot be programmed.
If I use the screen capture action, the images are always a little blurry, not really sharp.
I use the screen capture action to the system clipboard and then write the clipboard to a file. I've tried all file types and also checked and unchecked 'always nominal resolution' within the screen capture action.
Any help is appreciated.
(the shell script image is very sharp and clear of course, I'll go with that as long as I can get the KM variable 'over there' to be used. )
@ccstone has already provided a good, thorough example of how to use the builtin KM window functions.
Without meaning to step on his toes, we can compact the workflow a bit by retrieving the window coordinates all at once instead of as four separate entities. This can then be fed directly into the shell script action:
By "non-third party", are you also including Keyboard Maestro in this exclusion criterion ?
I assume you are, because you will have already considered getting Keyboard Maestro to issue the click for you. In which case, the other way that springs to mind (having used it recently to help another user on this forum) is using JavaScript for Automation and the Core Graphics API to issue a pair of mouse-down/mouse-up events at appropriate coordinates.
I expect it is the same Mojave issue that prevents simulated keys invoke system hot keys unless they are plain letters. I don't know whether Apple plan to fix this.
I really would like to use the screen capture action, it would make this macro so much easier!
I use these screenshots in an email to send to clients.
When I use a shell script or Shift Command 4 to take the screenshot they are crisp and clear.
But when I use the Screen Capture mode, although the file that is written to disk looks crips and clear, once inserted into an email it looks very fuzzy.
Following is an example of how they look in mail.
First is Screen Capture not nominal resolution
Second is Screen Capture with nominal resolution
Third is Shift Command 4
I would really like to figure this out. I'm sure it's something I have set wrong or am doing incorrectly with the file type or inserting into mail.
I'm working with the shell script to take the screenshot.
When I insert the image into OS X mail from the finder where it was saved, it gets much smaller than the image is when I open it directly in the finder in preview.
I would like it to remain the same size.
What am I missing?
This works fine in Script Editor, but it doesn't fully issue the click if run inside Keyboard Maestro. It may be because KM uses osascript (I wish it didn't), and perhaps the CG events need a GUI context to operate in.
Thankfully, FastScripts uses the native AppleScript engine (whatever the correct terminology for that is), so this script should work via that.
Happy to hear your thoughts. Have you come across any other/better methods ?
The image is 144 dpi - when using the shell script.
But when using the screen capture action it is 72.
And my mail 'image' was set to small, DOH,
you again, have really helped me. Thank you
I'll like to go back and see using the 'actual size' setting, if I can simplify my whole macro and use the screen capture action. !!
Although I'm able to use/modify the shell script if necessary.