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 