Email a screenshot using Function key?

Hi folks!

I’m wondering if one of you knows how to accomplish this…

I help my Dad all the time on his Mac using remote screen sharing. But often, such as when I’m in the office and cannot access screen sharing, I cannot help him with a message that pops up on his screen; and later on, when I’m home, he cannot reproduce it.

Unfortunately it’s too overwhelmingly confusing to him to learn how to take a screen shot, attach it to an email, and send it to me.

After years of facing this issue, it occurred to me recently that there should be a way that he could hit a SINGLE KEY, like a Function key, which would automatically take a screen shot and email it to my (pre-configured) email address. No cut/paste, no opening the mail app and figuring out how to click Send (no, he can’t handle that).

Not long ago I did some googling and found a number of automation tools, but my initial look didn’t find anything that simple. And I don’t know how to write AppleScript and don’t feel like spending a lot of time on this.

So!

I was hoping one of you might know if there’s a simple tool to let me do this? I’d be willing to spend a few bucks on it if needed. In fact, he’s probably be willing to pay for it :slight_smile:

Thanks in advance!

Dave

I can get you most of the way there in Catalina (and maybe earlier system releases): putting the screenshot in a draft email message. He will still need to address it to you and tap Send.

You will need to coach him to go through a setup step once, and from then on, tapping the appropriate key combination will set up the draft email. TO set things up[, tap Shift-command-5 and then the Options pull-down. Set the ‘Save’ option to MAIL, the timer to NONE, and option to REMEMBER LAST SELECTION. Then tap the ‘x’ on the left to exit the image capture.

After doing this once, when you want him to send you a screen capture, have him tap Shift-Command 3. This will attach a capture of the whole screen to a draft email message. He will need to fill out the ‘To’ block, put something on the subject line (to avoid an error) and then tap send.

I realize this is not as simple as you requested, but perhaps you can guide him through the setup step and figure out how to further automate the capture and send.

I’m sure Keyboard Maestro could do it with ease. It’s probably overkill for what you want, though.

Jeremy

1 Like

Shift-command-5

Thanks, that’s interesting! I had read about some of this functionality, but never tried it and certainly didn’t know about all the options. I will add the step of clicking “Capture Entire Screen” to your list of instructions. It is working under Mojave, btw.

Yes, it neither populates the To field nor clicks Send. It also presents the Warning about the blank Subject, which is going to be another obstacle.

Hmmm.

I was right about Keyboard Maestro. I have made a macro which, when a function key is pressed, takes a screenshot of the front window (could just as easily have been the entire screen), saves it to a file on disk and sends an email to a predefined address with that file attached. It was trivially easy.

KM costs about $40. I have no connection to the firm other than as an extremely satisfied user for many years.

Jeremy

Thanks, I’m close!

Can’t figure out how to get the SS to save to a file. It does have a Trigger Clipboard option which seems like it would be more efficient, rather than having to write to a file and then read back. But in the Mail widget, I haven’t yet figured out how to dereference the Trigger Clipboard either in the Body or Attachment sections…

How did you get it to write to a file?

Okay, I got it working with Keyboard Maestro.

Macro screenshot is attached because I don’t seem able to upload arbitrary attachments (ie, the macro itself).

I did have to write to and then read from a file. I also don’t appear to have control over the size of the attachment, but as long as he doesn’t change the “last used” setting of “Actual Size”, I should be fine.

It’s not cheap software and it’s overkill, but it’s probably not worth my time looking any further.

Thanks!!

Dave

1 Like

That’s exactly how I did it, yes.

I didn’t try to see how the “write to file” action would cope if the file already existed, so that might be worth checking.

Once you have KM, I’m sure you’ll find a myriad of uses for it.

Jeremy

Discourse has settings that control what file types can be uploaded for security reasons. I’ve now enabled the .kmmacros extension for uploading if anyone wants to share a Keyboard Maestro macro.

I’ve now enabled the .kmmacros extension for uploading if anyone wants to share a Keyboard Maestro macro.

Thanks, Ace!

I’ve now attached a more generic form of my macro.

Email a Screenshot.kmmacros (2.6 KB)

It would be really cool if you could “compile down” the macro to be a standalone entity that could run without requiring KM to be installed :smile: I’m not sure how plausible that would be, but I think there are some that could be reduced to a combination of AppleScript, cron, and whatever other bundled/free system services exist. Of course, KM wouldn’t be happy about something like that :sweat_smile: :innocent:

I’m sure @peternlewis has thought about what would be involved.

Screen capture can be done with the /usr/sbin/screencapture tool, and the Mail command is done more or less via AppleScript so it should be possible to do the whole lot in AppleScript, and then you just need to trigger it via a hot key, and there are various tools for doing that, or you can probably just get it in the Scripts or Services menu and use the System Preferences, Keyboard shortcuts to set a command key.

Whether the time spent doing that is worth more or less than the share of Keyboard Maestro’s purchase price allocated to this project is a decision each person gets to make.

As far as Keyboard Maestro compiling down to some sort of distributable executable, that would not really be practical except for a limited subset of what Keyboard Maestro does (and even then, shipping running code from an application is not something you can really do any more given Apple’s code signing and notarisation requirements).

So it would have to be more like a run-only version of Keyboard Maestro, which is possible I suppose, but doesn’t make a lot of economic sense, since I’d have to charge for that, and in my experience most macros are specific to each user (it is one of the issues that makes marketing Keyboard Maestro challenging, since I can’t just say “here are a bunch of useful macros”, because the macros that end up being useful to each person tend to be unique to them).

Look at even this macro, it contains a bunch of things unique to how you want it done. While it could all be done in a configurable manner, saving all the different fields in variables in some sort of configuration setup, it would make the whole lot more complicated.

[great insight from Peter Lewis]

Thanks for that thoughtful reply! That all makes sense. At this point in my life it’s just not worth trying to dump time into rolling my own so I’m going to buy it!

I have to say that UI for KM is really quite beautiful. It’s a work of art really. As is the documentation that I’ve seen so far. Making something this powerful and making it this approachable is an accomplishment I rarely see.

1 Like

It seems like others have helped you solve the problem. Many years agp I wrote some Applescript to select a portion of the screen, take a snapshot, open Graphic Converter (app) and create a new image file from the clipboard. I saved this as an app that I keep in the dock so I just need to click on the icon to start the process. I still use it several times a week. The instructions and script are here:
http://users.tpg.com.au/users/aoaug/mac_osx.html#Screen_Snapshots
Although it doesn’t do what you want the method of sending keystrokes to other apps might be useful.
I have had close calls where macOS upgrades have not liked my app controlling other apps but have managed to get it to work again each time. I am holding back on Catalina for this and other reasons.

It seems like others have helped you solve the problem. Many years agp I wrote some Applescript to select a portion of the screen, take a snapshot, open Graphic Converter (app) and create a new image file from the clipboard. I saved this as an app that I keep in the dock so I just need to click on the icon to start the process. I still use it several times a week. The instructions and script are here:

Clever and impressive!

You’re probably pretty close to giving me a simple, free solution to my problem. But I’m happy to have purchased KM which made this a breeze. I’m not sure what else I’ll use it for, but I read through the functionality, and I have a feeling I will find other uses for it :slight_smile:

This seems to work… you should be able to copy and paste it into the Script Editor. Note that you could capture the whole screen using different screencapture parameters. Apologies for the strange formatting of this post…

-- snap2email v1.0 Applescript by Michael Paine  April 2020
-- http://www4.tpgi.com.au/users/aoaug/mac_osx.html
--- This initiates the Unix screencapture function to capture an
--- area of the screen selected with the mouse (-i) and
--- saves it to the clipboard (-c) then
--- starts Mail, fills in the To & Subject fields
-- Paste the snapshot into the Body Section
-- Sends the email
-- **You may need to change the Tabs to suit your Mail layout**
-- For best usage, load into Script Editor and Save As an Application 
-- with the Runtime box checked. Drag the application to the Dock for 
--- ready access. 
--
-- Excute Unix command
do shell script "screencapture -i -c"
-- Ensure GraphicConverter is active (caution: no error trapping here)
tell application "Mail"
	activate
end tell
-- get ready to send keystrokes
tell application "System Events"
	-- make Mail the active application
	tell process "Mail"
		set frontmost to true
	end tell
	-- send the keystrokes
	-- New mail message
	keystroke "N" using {command down}
	-- fill in the To field
	set fieldinput to "yourname@icloud.com"
	keystroke fieldinput
	keystroke return
	-- Jump to the Subject field
	keystroke {tab}
	keystroke {tab}
	keystroke {tab}
	keystroke {tab}
	set fieldinput to "Snapshot taken today"
	keystroke fieldinput
	keystroke return
	-- Jump to the Body section
	keystroke {tab}
	keystroke {tab}
	keystroke {tab}
	-- Paste the screen snapshot
	keystroke "V" using {command down}
	-- Send the email
	keystroke "D" using {command down, shift down}	

end tell

This seems to work… you should be able to copy and paste it into the Script Editor…

Very cool, Michael!

Your hyphens and quotes got messed up in the upload process, but after I fixed those I got it to compile.

It takes a screen shot and brings Mail to the foreground, but then it starts doing weird things in mail, not including creating a new message and filling it out (and definitely not sending anything). It also appears to end with an error tone. Nothing’s jumping out at me about why it doesn’t work for me :slight_smile:

Ah - I am using “classic” Mail layout (Mail Prefs/Viewing) in Mojave that probably has a different sequence of keystrokes to the one you are using. I used the menu bar commands to work out my sequence (eg File/New Message shows Cmd-N and Message/Send shows shift-Cmd-D). And I counted the Tab key presses to jump between fields to come up with that sequence. Try this manually with your Mail layout and edit the script to match your findings.
The other important thing is that you need to give permission for the Script Editor to send keystrokes to other apps via System Preferences/Security & Privacy/Accessibility settings. This also needs to be done when you save the Applescript as an app. I expect you have already done this (since the script is partially working) but I mention it here for others.

Ah - I am using “classic” Mail layout (Mail Prefs/Viewing) in Mojave that probably has a different sequence of keystrokes to the one you are using…

Okay, I figured out the issue. You had:

keystroke "N" using {command down}

to start a new message. But since that’s a capital N, it effectively executes Cmd-Shift-N or “Get All New Mail” and never opens a new message window. Then the subsequent keystrokes all do unexpected things. I changed it to lower case:

keystroke "n" using {command down}

and it works beautifully!

Next I wil try to attach it to a function key…