Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Open Image

Description
This macro will copy the currently selected item. If it's an image, it will save it to the user's temp folder and then open it in the user's default image viewer.
Language
C#.net
Minimum Version
Created By
AR22586
Contributors
-
Date Created
2h ago
Date Last Modified
2h ago

Macro Code

using System;
using System.IO;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Diagnostics;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // Copy the currently selected item, like pressing Ctrl+C
        BFS.Clipboard.Copy();

        // Give Windows a moment to update the clipboard
        BFS.General.ThreadWait(200);

        // Check for an image
        if (!Clipboard.ContainsImage())
        {
            MessageBox.Show(
                "The clipboard does not contain an image.",
                "ClipboardFusion",
                MessageBoxButtons.OK,
                MessageBoxIcon.Exclamation);

            return null;
        }

        // Create a temporary PNG file
        string filename = Path.Combine(
            Path.GetTempPath(),
            "ClipboardImage_" +
            DateTime.Now.ToString("yyyyMMdd_HHmmss") +
            ".png"
        );

        // Save clipboard image
        Clipboard.GetImage().Save(filename, ImageFormat.Png);

        // Open using Windows' default application for PNG files
        Process.Start(new ProcessStartInfo(filename)
        {
            UseShellExecute = true
        });

        return null;
    }
}