--I still use a capture tool called GrabBox on my Mac (http://d.hatena.ne.jp/tell-k/20110523/1306166332) --When I Sierra the OS, it stopped working. (It's a mystery whether it's really Sierra's fault) Sad ――For the time being, I made a note because I made a quick response.
--GrabBox is successfully inscored, but the image file is not saved in Dropbox even if I take a capture with ** Shift + Cmd + 4 ** --I was able to confirm that if you put the image file directly in the directory of the GrabBox app in Drobpox, it will be published.
――If you can move the image to the specified directory of Dropbox after taking the capture, it is good because it is the same as before. --Since you can change the save destination of screenshots on Mac, I prepared a script that does the following in Python.
The content of the script looks like this
move2dropbox.py
# -*- coding: utf-8 -*-
import time
import os
import uuid
import shutil
import subprocess
from PIL import Image
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
here = os.path.abspath(os.path.dirname(__file__))
HOME_DIR = os.path.expanduser('~')
SCREENSHOT_DIR = os.path.join(here, 'screenshot')
DROPBOX_DIR = os.path.join(HOME_DIR, 'Dropbox', 'App', 'GrabBox')
DROPBOX_URL = 'https://dl.dropboxusercontent.com/spa/xxxxxxxxx/'
CMD_LOCATION = 'defaults write com.apple.screencapture location {}'.format(SCREENSHOT_DIR) # NOQA
CMD_NAME = 'defaults write com.apple.screencapture name "grabox"'
CMD_KILLALL = 'killall SystemUIServer'
def resize_for_retina(imgfile):
img = Image.open(imgfile)
resized = img.resize([int(0.5 * s) for s in img.size])
resized.save(imgfile)
class MyHandler(FileSystemEventHandler):
def on_created(self, event):
for img in os.listdir(SCREENSHOT_DIR):
if not img.endswith('.png'):
continue
new_img = '{}.png'.format(uuid.uuid4().hex)
resize_for_retina(os.path.join(SCREENSHOT_DIR, img))
shutil.move(
os.path.join(SCREENSHOT_DIR, img),
os.path.join(DROPBOX_DIR, new_img)
)
subprocess.call(
'echo "{}" | pbcopy'.format(DROPBOX_URL + new_img),
shell=True
)
if __name__ == "__main__":
if not os.path.exists(SCREENSHOT_DIR):
os.makedirs(SCREENSHOT_DIR)
subprocess.call(CMD_LOCATION, shell=True)
subprocess.call(CMD_NAME, shell=True)
subprocess.call(CMD_KILLALL, shell=True)
observer = Observer()
observer.schedule(MyHandler(), path=SCREENSHOT_DIR, recursive=False)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
Finally, create a shell script that hits this script in the background
move2dropbox.command
nohup python /path/to/move2dropbox.py > /dev/null 2>&1 &
** Add the extension ".command" ** and register it in ** "System environment> Users and groups> Login items" **
Now, when you log in, the above monitoring script will be executed without permission.
――Please tell us your recommended capture tool right now (urgent)
List recommended ones
end
Recommended Posts