Request: Read image from file on disk to Clipboard

Issue #78 closed
Winter Laite created an issue

This can be done in both AHK v1 and v2, but requires external libraries.

Ideally, you would be able to specify a file name, Keysharp would read it, then copy the bitmap to the clipboard.

(Perhaps allow copying the bitmap to a variable also?)

Comments (4)

  1. Winter Laite reporter

    Potentially useful:

    Clipboard.SetImage(Image.FromFile(@"path_to.image"));
    

    Or:

    byte[] bytes = File.ReadAllBytes(@"path_to.jpg");
    Image img;
    using (var ms = new MemoryStream(bytes))
        img = Image.FromStream(ms);
    Clipboard.SetImage(img);
    

    From: SO

  2. Matt Feemster repo owner

    I’ve added a new function named CopyImageToClipboard().

    It takes the same arguments as LoadPicture(). So you can load via filename, or image handle etc...

    In my tests it works.

  3. Log in to comment