8

I sometimes get ad-hoc bug reports from customers, which I need to transfer to our online bug tracker. Works fine for text, but pictures are tedious.

I'm looking for a solution to copy-paste images from documents (like excel sheets) in a way that if you paste an image to a file input (or text input) on a html page, the file will automatically be written to disk (tmp dir), and the path written to the file input field.

This question is related to Directly paste clipboard image into gmail message, but I would like to ask if there is a solution using a local program only. I'm interested in solutions for all operating systems.

5 Answers5

3

Okay guys, This is what I did.

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace ClipSave
{
    class Program
    {
        [STAThread] public static void Main()
        {
            if (Clipboard.GetDataObject() != null)
            {
                IDataObject data = Clipboard.GetDataObject();

                if (data.GetDataPresent(DataFormats.Bitmap))
                {
                    Image image = (Image)data.GetData(DataFormats.Bitmap, true);
                    string file = System.Windows.Forms.Application.CommonAppDataPath + "\\ClipSaveImage.png";
                    image.Save(file, System.Drawing.Imaging.ImageFormat.Png);
                    Clipboard.SetText(file);

                }
                else
                    MessageBox.Show("Copy valid image first");
            }
            else
                MessageBox.Show("Copy image first");
        }
    }
}

Compiled it to an EXE, added a start-up menu shortcut to it with a hotkey Ctrl+Shift+C. It then copies the current image in clipboard to a file and puts path to the file into the clipboard.

2

This AutoHotKey thread has an AutoHotKey script for taking a screenshot. It includes the source for a trivial .Net 1.1 program to save the clipboard to a PNG. You would want it to have a few other modifications:

  • Save the image to a different folder, with a name better than image.png
  • Copy the path to the new image to your clipboard

The AutoHotKey Clipboard commands are another way to access that data, though a program to get its image data would be a bit more complicated.

1

Not sure if i answering your question. but you can try out clipman. it helps you to copy everything and keep it aside until you select it back one by one. Clipman,source CNET

Jason
  • 39
  • 1
0
  • Right click the image and save it?
  • Drag the image to a folder?
  • Use the Snipping Tool and save it from there?

These three methods will let you save a file pretty quick. The File Explorer will always go to the same folder so quickly saving or uploading the file won't be a problem either...

The direct clipboard feature has been asked before and failed.

0

I am not familiar with Windows, but since you asked for solutions for all OSes, I have an applescript solution for Mac OS X that I have tested by copying a picture on this website and executing the script.

This applescript assumes the image is on the clipboard in TIFF format (might have to test to see if this is what comes out of Excel.) It creates the file from the clipboard, saves it to a temporary directory, then pastes the path into a specified field on the frontmost page in Safari.

So, you would copy the image, switch to your safari page, and run the script. (From the script menu, make it into a service and assign a shortcut, or use FastScripts to assign a shortcut to the applescript.)

The script will have to be adjusted to find the proper field on your form.

repeat with i in clipboard info

  if TIFF picture is in i then

    -- grab the picture from the clipboard, set up a filename based on date
    set tp to the clipboard as TIFF picture
    set dt to current date
    set dtstr to (time of dt as string) & ".tiff"
    set pt to ((path to temporary items from user domain as string) & dtstr)
    set tf to open for access file pt with write permission

    -- save the file
    try
        write tp to tf
        close access tf
    on error
        close access tf
    end try

    -- put the path into the proper field in the web Browser
    tell application "Safari"
        activate

        -- adjust javascript as necessary
        -- currently inserts into Answer textarea of this superuser.com page for testing
        -- ie. make sure you've clicked "add answer" first
        set myJS to "document.getElementById('wmd-input').value = '" & pt & "'"

        -- document 1 is frontmost
        do JavaScript myJS in document 1
    end tell

    exit repeat
  end if
end repeat

Edit: Things to consider:

  • I do nothing with the path, default delimiter is a colon. You may want the POSIX path.
  • Is it possible to change the javascript to execute a file upload javascript? (I have no experience with this, but I think it could be done.)
  • Excel supports applescript, and has a copy picture command. It may be feasible to do this in one step. Select picture, run script, script copies, saves, opens web page and fills out the form.
ghoppe
  • 6,558
  • 25
  • 21