Topic: Screenshot tool

Hello,

I've managed to create a simple screenshot plugin using the 'screencapture' command in OS X,

It's early days, but thought I'd share what's going on so far:

# Dropzone Action Info
# Name: Screenshots
# Description: Take a screenshot, add it to ~/Screenshots and add to Drop Bar
# Creator: Gareth Evans
# URL: http://yoursite.com
# Events: Clicked
# KeyModifiers: Command, Option, Control, Shift
# SkipConfig: No
# RunsSandboxed: No
# Version: 1.0
# MinDropzoneVersion: 3.0

def clicked
# Create the Screenshots directory if not already present
  system("mkdir ~/Screenshots")
# Capture screenshot.png to the directory
  system("screencapture -i ~/Screenshots/screenshot.png")
  file_paths = [File.expand_path('~') + "/Screenshots/screenshot.png"] 
  $dz.add_dropbar(file_paths)
# Notification
  $dz.finish("Screenshot successful")
  $dz.url(false)
end

My biggest hurdle is when you take a second screenshot, it looks like there are two files in the drop bar, but both icons point to the same screenshot.png,

Does anybody know if there is a dz.remove command in the API so I can put it above the dz.add command, ensuring there is only ever one icon in the Drop Bar.

Also, if there's an easier way to approach this I'm all ears smile

Re: Screenshot tool

This is really cool. There isn't an API to remove items from Drop Bar, but what about just giving each subsequent screenshot a different filename? Then you'd avoid overwriting the last one each time. And the idea is you'd probably drag it out of Drop Bar before capturing the next one so having multiple ones added to Drop Bar isn't really a problem.

Try the below:

# Dropzone Action Info
# Name: Screenshots
# Description: Take a screenshot, add it to ~/Screenshots and add to Drop Bar
# Creator: Gareth Evans
# URL: http://yoursite.com
# Events: Clicked
# KeyModifiers: Command, Option, Control, Shift
# SkipConfig: No
# RunsSandboxed: No
# Version: 1.0
# MinDropzoneVersion: 3.0

def clicked
  # Create the Screenshots directory if not already present
  system("mkdir ~/Screenshots")
  
  # Make a filename with the current time
  formatted_time = Time.now.strftime("%F at %I.%M.%S %p")
  filename = "Screen Shot " + formatted_time + ".png"
  file_path = File.expand_path('~') + "/Screenshots/" + filename
  
  # Capture screenshot
  system("screencapture -i \"" + file_path + "\"")
  
  # Add to Drop Bar
  $dz.add_dropbar([file_path])
  
  # Notification
  $dz.finish("Screenshot successful")
  $dz.url(false)
end

Also, could I recommend you fork the https://github.com/aptonic/dropzone3-actions repository, add your action and send me a pull request? That will make your action show up at https://aptonic.com/actions/untested automatically which will allow others to install it.

This will also allow us to collaborate on improvements more easily smile