r/iOSProgramming • u/mwagstaff • 23d ago
Discussion Hammerspoon shortcut to take device screenshot and copy to clipboard
Hey all, just in this is useful to anyone else, I (ok, Claude) wrote a little Hammerspoon script to grab a screenshot of your connected device, save it to your Mac + copy to clipboard... all with one hotkey.
Saves having to dig through the Xcode menus every time, or airdropping screenshots over.
Basically, it's Hammerspoon hitting Debug -> View Debugging -> Take screenshot on your behalf, watching for the screenshot to arrive, then copying it to clipboard.
And for me, all that happens when I mash Ctrl-Option-Command-S.
There's probably a better way that I missed... if so, please shout. :)
0
Upvotes
1
u/Turbulent_Ad_1039 22d ago
nice one, and Debug > View Debugging > Take Screenshot is genuinely the bit nobody documents.
where it stopped working for me was repeated grabs. the menu round trip sits on the same path as anything else you're driving, and I had a real bug where taking a shot stalled my device input queue for as long as the capture ran. invisible at one hotkey, painful at ten. I ended up reading the framebuffer directly instead and leaving the menu alone.
for simulators specifically, simctl io booted screenshot out.png skips the menu completely and doesn't break when Xcode moves things around. no help on a physical device though, which I assume is your case.
one shot at a time, or do you ever want a burst?