Paste Every Screenshot into PowerPoint Automatically (PowerShell Tool)

Advertisement
Paste Every Screenshot into PowerPoint Automatically (PowerShell Tool) Automation
Advertisement

At work I keep screenshots as proof of each step I do. Taking them is easy with Print Screen or the Snipping Tool. Sorting them later is the annoying part: the files are just named by date and time, and once there are dozens, I can’t tell which one belongs to which step.

Pasting them one by one into Excel works, but there are no thumbnails, so finding a screen later is slow, and I still have to type the time and step next to each one.

Short answer: I wrote a PowerShell tool. every time you take a screenshot, it adds a new slide at the end of a PowerPoint file, pastes the image, and puts the capture time in the slide title, plus an optional note like a step number. PowerPoint keeps everything in one file, shows thumbnails, and lets you crop or reuse the images later. The full code is below, feel free to use it.

What the tool does

  • Watches the clipboard. When a new image lands there (any screenshot tool that copies to the clipboard works), it adds a slide at the end and pastes it
  • The slide title is the capture time, like 2026/11/23 09:15:42. The image is shrunk if needed so it fits below the title
  • You pick an existing PowerPoint file to add to, or leave it empty to start a new presentation
  • A Start/Stop button: only screenshots taken while it says Running go into PowerPoint
  • With a check box on, it asks for a short note after each screenshot and adds it to the title, like 2026/11/23 09:15:42_step-3
PowerPoint slide made by the tool: the title shows the capture time with _step-3 added, the pasted image in the middle
A slide the tool made. The title is the capture time plus the note step-3

The code

It’s long because of the three small windows, but what it does is simple. Save it as ScreenshotToPowerPoint.ps1, then right-click it and choose Run with PowerShell.

# Load assemblies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

### Settings ###

# Sleep interval (ms)
[int32]$sleepTime = 100

# Logger
function logger($msg) {
    Write-Host ((Get-Date -Format "yyyy-MM-dd HH:mm:ss") + "  " + $msg)
}

# Array that holds the COM objects
[int32]$arrayUbound = 9
[Object[]]$coms = 0..$arrayUbound
for ([int32]$i=0;$i -le $arrayUbound;$i++){
    $coms[$i] = $null
}

# Index names for the PowerPoint objects
New-Variable -Name ppApp    -Value 0 -Option ReadOnly -Description "PowerPoint.Application"
New-Variable -Name ppPress  -Value 1 -Option ReadOnly -Description "PowerPoint.Presentations"
New-Variable -Name ppPres   -Value 2 -Option ReadOnly -Description "PowerPoint.Presentation"
New-Variable -Name ppSlds   -Value 3 -Option ReadOnly -Description "PowerPoint.Slides"
New-Variable -Name ppSld    -Value 4 -Option ReadOnly -Description "PowerPoint.Slide"
New-Variable -Name ppShps   -Value 5 -Option ReadOnly -Description "PowerPoint.Shpaes"
New-Variable -Name ppPic    -Value 6 -Option ReadOnly -Description "PowerPoint.Shape Pasted Picture"
New-Variable -Name ppTitle  -Value 7 -Option ReadOnly -Description "PowerPoint.Shpae Title PlaceHolder"
New-Variable -Name ppTxtFrm -Value 8 -Option ReadOnly -Description "PowerPoint.TextFrame Title"
New-Variable -Name ppTxtRng -Value 9 -Option ReadOnly -Description "PowerPoint.TextRange Title"

# PowerPoint constant (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.ppslidelayout)
New-Variable -Name ppLayoutTitleOnly -Value 11 -Option ReadOnly -Description "PowerPoint.PpSlideLayout.ppLayoutTitleOnly"

# C# class that raises an event every time the clipboard changes
Add-Type -TypeDefinition @'
    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class ClipboardListeningForm : Form
    {
        [DllImport("user32.dll", SetLastError = true)]
        private extern static void AddClipboardFormatListener(IntPtr hwnd);

        [DllImport("user32.dll", SetLastError = true)]
        private extern static void RemoveClipboardFormatListener(IntPtr hwnd);

        public event EventHandler ClipboardChanged;
        public const int WM_CLIPBOARDUPDATE = 0x031D;

        protected override void OnLoad(EventArgs e)
        {
            AddClipboardFormatListener(Handle);
            base.OnLoad(e);
        }

        protected override void Dispose(bool disposing)
        {
            RemoveClipboardFormatListener(Handle);
            base.Dispose(disposing);
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_CLIPBOARDUPDATE)
            {
                OnClipboardChanged(EventArgs.Empty);
                m.Result = IntPtr.Zero;
            }
            else
                base.WndProc(ref m);
        }

        protected virtual void OnClipboardChanged(EventArgs e)
        {
            EventHandler subscribers = ClipboardChanged;
            if (subscribers != null)
            {
                subscribers(this, e);
            }
        }
    }
'@ -ReferencedAssemblies System.Windows.Forms

######


### FilePath form ###

# PowerPoint file to append to (empty = new presentation)
$PastePowerpointFile = $null

# FilePath form
$FilePathForm = New-Object System.Windows.Forms.Form
$FilePathForm.Size = New-Object System.Drawing.Size(500,170)
$FilePathForm.Text = "ScreenshotToPowerPoint"

# FilePath label
$LabelFilePath = New-Object System.Windows.Forms.Label
$LabelFilePath.Location = New-Object System.Drawing.Point(10,10)
$LabelFilePath.AutoSize = $true
$LabelFilePath.Text = "Choose a PowerPoint file to add screenshots to (optional)"
$LabelFilePath.Font = New-Object System.Drawing.Font("Arial", 11)

# FilePath text box
$TextBoxFilePath = New-Object System.Windows.Forms.TextBox
$TextBoxFilePath.Location = New-Object System.Drawing.Point(20,42)
$TextBoxFilePath.Size = New-Object System.Drawing.Size(370,30)
$TextBoxFilePath.Font = New-Object System.Drawing.Font("Arial", 10)

# Browse button
$ButtonFilePath = New-Object System.Windows.Forms.Button
$ButtonFilePath.Location = New-Object System.Drawing.Point(400,40)
$ButtonFilePath.AutoSize = $true
$ButtonFilePath.Text = "Browse"
$ButtonFilePath.Font = New-Object System.Drawing.Font("Arial", 10)

# OK button
$ButtonOKFilePath = New-Object System.Windows.Forms.Button
$ButtonOKFilePath.Location =  New-Object System.Drawing.Point(320,90)
$ButtonOKFilePath.AutoSize = $true
$ButtonOKFilePath.Text = "OK"
$ButtonOKFilePath.Font = New-Object System.Drawing.Font("Arial", 10)
$ButtonOKFilePath.DialogResult = "OK"

# Cancel button
$ButtonCancelFilePath = New-Object System.Windows.Forms.Button
$ButtonCancelFilePath.Location =  New-Object System.Drawing.Point(400,90)
$ButtonCancelFilePath.AutoSize = $true
$ButtonCancelFilePath.Text = "Cancel"
$ButtonCancelFilePath.Font = New-Object System.Drawing.Font("Arial", 10)
$ButtonCancelFilePath.DialogResult = "Cancel"

# Put the controls on the FilePath form
$FilePathForm.Controls.AddRange(@($LabelFilePath,$TextBoxFilePath,$ButtonFilePath,$ButtonOKFilePath,$ButtonCancelFilePath))

# Browse button click
$ButtonFilePath.add_click{

    # Show the file dialog
    $Dialog = New-Object System.Windows.Forms.OpenFileDialog
    $Dialog.Filter = "PowerPoint presentation (*.pptx;*.ppt;*.pptm)|*.pptx;*.ppt;*.pptm"
    if($Dialog.ShowDialog() -eq "OK"){
        $TextBoxFilePath.Text = $Dialog.FileName
    }
}

######


### CustomText form ###

# CustomText form
$CustomTextForm = New-Object System.Windows.Forms.Form
$CustomTextForm.Size = New-Object System.Drawing.Size(500,130)
$CustomTextForm.Text = "CustomText"
$CustomTextForm.Owner = $OnOffForm

# Closing event of the sub form: hide it instead of closing
$Close = {
    $_.Cancel = $True
    $CustomTextForm.Visible = $false
}
$CustomTextForm.Add_Closing($Close)

# CustomText label
$LabelCustomText = New-Object System.Windows.Forms.Label
$LabelCustomText.Location = New-Object System.Drawing.Point(20,10)
#$LabelCustomText.Size = New-Object System.Drawing.Size(450,20)
$LabelCustomText.AutoSize = $true
$LabelCustomText.Text = "Text to add after the capture time (optional)"
$LabelCustomText.Font = New-Object System.Drawing.Font("Arial", 10)

# CustomText text box
$TextBoxCustomText = New-Object System.Windows.Forms.TextBox
$TextBoxCustomText.Location = New-Object System.Drawing.Point(20,30)
$TextBoxCustomText.Size = New-Object System.Drawing.Size(450,30)
$TextBoxCustomText.Font = New-Object System.Drawing.Font("Arial", 10)

# OK button
$ButtonOKCustomText = New-Object System.Windows.Forms.Button
$ButtonOKCustomText.Location =  New-Object System.Drawing.Point(230,60)
#$ButtonOKCustomText.Size = New-Object System.Drawing.Size(50,30)
$ButtonOKCustomText.AutoSize = $true
$ButtonOKCustomText.Text = "OK"
$ButtonOKCustomText.Font = New-Object System.Drawing.Font("Arial", 10)

# Cancel button
$ButtonCancelCustomText = New-Object System.Windows.Forms.Button
$ButtonCancelCustomText.Location =  New-Object System.Drawing.Point(320,60)
#$ButtonCancelCustomText.Size = New-Object System.Drawing.Size(160,30)
$ButtonCancelCustomText.AutoSize = $true
$ButtonCancelCustomText.Text = "Cancel (no text)"
$ButtonCancelCustomText.Font = New-Object System.Drawing.Font("Arial", 10)

# Put the controls on the CustomText form
$CustomTextForm.Controls.AddRange(@($LabelCustomText,$TextBoxCustomText,$ButtonOKCustomText,$ButtonCancelCustomText))

# OK button: add the typed text after the time in the newest slide title
# (registered once here, so it does not stack up on every screenshot)
$ButtonOKCustomText.add_Click({
    if ($TextBoxCustomText.Text -ne "") {
        $coms[$ppTxtRng].Text = $coms[$ppTxtRng].Text + "_" + $TextBoxCustomText.Text
        $TextBoxCustomText.Text = $null
    }
    # Hide the CustomText form (see its Closing event)
    $CustomTextForm.Close()
})

# Cancel button: just hide the CustomText form
$ButtonCancelCustomText.add_Click({
    $CustomTextForm.Close()
})

######


### OnOff form ###

# OnOff form (main window)
$OnOffForm = New-Object -TypeName ClipboardListeningForm
$OnOffForm.Size = New-Object System.Drawing.Size(550,250)
$OnOffForm.StartPosition = "CenterScreen"
$OnOffForm.Text = "ScreenshotToPowerpoint"
$OnOffForm.TopLevel = $True
$OnOffForm.MaximizeBox = $False

# OnOff label 1
$label1OnOff = New-Object System.Windows.Forms.Label
$label1OnOff.Location = New-Object System.Drawing.Point(10,10)
$label1OnOff.AutoSize = $true
$label1OnOff.Font = New-Object System.Drawing.Font("Arial", 10)
$label1OnOff.Text = "Start pasting screenshots into PowerPoint?"

# OnOff label 2
$label2OnOff = New-Object System.Windows.Forms.Label
$label2OnOff.Location = New-Object System.Drawing.Point(270,50)
$label2OnOff.AutoSize = $true
$label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12)
$label2OnOff.Text = "Stopped"
$label2OnOff.TextAlign = "BottomCenter"

# Start/Stop toggle button
$StartButtonOnOff = New-Object -TypeName System.Windows.Forms.CheckBox
$StartButtonOnOff.location = New-Object System.Drawing.Point(200,50)
$StartButtonOnOff.Autosize = $true
$StartButtonOnOff.Font = New-Object System.Drawing.Font("Arial", 12)
$StartButtonOnOff.Text = "Start"
$StartButtonOnOff.TextAlign = "MiddleCenter"
$StartButtonOnOff.Appearance = "Button"
$StartButtonOnOff.FlatStyle = "System"

$StartButtonOnOff.add_CheckedChanged({
    if ($StartButtonOnOff.Checked) {
        # Start pressed: show Running on a yellow background
        $StartButtonOnOff.Text = 'Stop'
        $label2OnOff.Text = "Running"
        $label2OnOff.BackColor = "yellow"
        $label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12, [System.Drawing.FontStyle]::Bold)
        $label1OnOff.Text = "Stop pasting screenshots into PowerPoint?"
    } else {
        # Pressed again: back to Stopped
        $StartButtonOnOff.Text = 'Start'
        $label2OnOff.Text = "Stopped"
        $label2OnOff.ResetBackColor()
        $label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12)
        $label1OnOff.Text = "Start pasting screenshots into PowerPoint?"
    }
})

# Close tool button
$CloseButtonOnOff = New-Object System.Windows.Forms.Button
$CloseButtonOnOff.Location = New-Object System.Drawing.Point(215,150)
$CloseButtonOnOff.AutoSize = $true
$CloseButtonOnOff.Font = New-Object System.Drawing.Font("Arial", 10)
$CloseButtonOnOff.Text = "Close tool"
$CloseButtonOnOff.DialogResult = [System.Windows.Forms.DialogResult]::cancel

# Check box: add custom text to each slide title
$CheckBoxOnOff = New-Object System.Windows.Forms.CheckBox
$CheckBoxOnOff.Location = New-Object System.Drawing.Point(20, 100)

$CheckBoxOnOff.AutoSize = $true
$CheckBoxOnOff.Font = New-Object System.Drawing.Font("Arial", 10)
$CheckBoxOnOff.Text = "Ask for extra text (like a step number) after each screenshot"
$CheckBoxOnOff.Checked = $false

# Put the controls on the OnOff form
$OnOffForm.Controls.AddRange(@($label1OnOff,$label2OnOff,$StartButtonOnOff,$CloseButtonOnOff,$CheckBoxOnOff))



### Main ###

# Step 1: log the start
logger "Process starting"


# Step 2: show the FilePath form, get the file path
if($FilePathForm.ShowDialog() -eq "OK"){
    if($TextBoxFilePath.text -ne ""){
        $PastePowerpointFile = $TextBoxFilePath.text
    }else{
        $PastePowerpointFile = $null
    }
}else{
    # Cancel pressed: stop here
    break
}


# Step 3: start PowerPoint. Open the chosen file (empty = new presentation)
logger "Connected to PowerPoint."

$coms[$ppApp] = New-Object -ComObject PowerPoint.Application
$coms[$ppPress] = $coms[$ppApp].Presentations

 if ($PastePowerpointFile -ne $null) {
        try {
            $coms[$ppPres] = $coms[$ppPress].Open($PastePowerpointFile)
            logger "Open $PastePowerpointFile"
        } catch {
            logger "File Open Failed. => $PastePowerpointFile"
            return;
        }
    } else {
        $coms[$ppPres] = $coms[$ppPress].Add($true)
    }

    $coms[$ppSlds] = $coms[$ppPres].Slides

logger "Clear Clipboard."


# Step 4: runs every time the clipboard changes
$OnOffForm.add_ClipboardChanged({

    # PowerPoint window hidden? Quit PowerPoint, then stop here
    if ($coms[$ppApp].Visible -eq $False) {
            logger "PowerPoint Closed."
            $coms[$ppApp].Quit()
            break
        }

    # Step 5: Start is on, with an image on the clipboard
    if ($StartButtonOnOff.Checked -and [System.Windows.Forms.Clipboard]::ContainsImage()) {
            Measure-Command {

                # Add a slide after the last one
                $coms[$ppSld]  = $coms[$ppSlds].Add($coms[$ppSlds].Count + 1, $ppLayoutTitleOnly)
                $coms[$ppShps] = $coms[$ppSld].Shapes
                $coms[$ppPic]  = $coms[$ppShps].Paste()
                $coms[$ppTitle]  = $coms[$ppShps].Title
                $coms[$ppTxtFrm] = $coms[$ppTitle].TextFrame
                $coms[$ppTxtRng] = $coms[$ppTxtFrm].TextRange
                $coms[$ppTxtRng].Text = Get-Date -Format "yyyy/MM/dd HH:mm:ss"

                # Shrink the image (if needed) to fit below the title, centered
                $slideW = $coms[$ppPres].PageSetup.SlideWidth
                $slideH = $coms[$ppPres].PageSetup.SlideHeight
                $areaTop = $coms[$ppTitle].Top + $coms[$ppTitle].Height
                $scale = [Math]::Min(($slideW - 20) / $coms[$ppPic].Width, ($slideH - $areaTop - 10) / $coms[$ppPic].Height)
                $coms[$ppPic].LockAspectRatio = -1
                if ($scale -lt 1) {
                    $coms[$ppPic].Width = $coms[$ppPic].Width * $scale
                }
                $coms[$ppPic].Left = ($slideW - $coms[$ppPic].Width) / 2
                $coms[$ppPic].Top = $areaTop + ($slideH - $areaTop - $coms[$ppPic].Height) / 2

                # Step 6: if the check box is on, ask for text to add after the time
                if ($CheckBoxOnOff.Checked) {
                        $TextBoxCustomText.text = $null

                        # Show the CustomText form. The OnOff form uses ShowDialog, so use Show() here
                        $CustomTextForm.Show()
                }

                # Step 7: always show the newest (last) slide
                $coms[$ppSlds].Item($coms[$ppSlds].Count).Select()

                [System.Windows.Forms.Clipboard]::Clear()

            } | ForEach-Object { logger ("{0:N3} ms" -f $_.TotalMilliseconds) }
        } else {
            Start-Sleep -Milliseconds $sleepTime
        }

})

# Show the OnOff form (the tool starts here)
[void]$OnOffForm.ShowDialog()

# Step 8: release the COM objects
for ([int32]$i=$arrayUbound;$i -ge 0;$i--){
        if ($null -ne $coms[$i]) {
            [System.Runtime.InteropServices.Marshal]::FinalReleaseComObject($coms[$i]) >$null
            $coms[$i] = $null
        }
    }

# Step 9: log the end
logger "Terminating"

What to change for your setup:

What Where Default
Slide title format Get-Date -Format "yyyy/MM/dd HH:mm:ss" 2026/11/23 09:15:42
Text between the time and your note + "_" + in the OK button action _
Image size and position The block under # Shrink the image Fit below the title, centered
Slide layout ppLayoutTitleOnly -Value 11 Title Only

I ran this English version on Windows 11 with Windows PowerShell 5.1 and Microsoft PowerPoint: three test images went onto three slides, and the notes went into the right titles.

How to use it

1. Pick the PowerPoint file (optional)

The first window asks for a PowerPoint file to add screenshots to. Type the full path, use Browse, or leave it empty and press OK to start a new presentation. Cancel ends the tool.

First window of the tool: a text box for the PowerPoint file path with Browse, OK & Cancel buttons
Leave it empty for a new presentation

2. Press Start

Next, PowerPoint opens along with the main window. Screenshots don’t go into PowerPoint yet. Press Start, and while the label says Running, every new screenshot becomes a slide.

Main window while running: Stop button, Running label on yellow, the note check box & Close tool
While it says Running, each screenshot becomes a slide

3. Add a note (optional)

Turn on the check box to get a small window after each screenshot. Type a note and press OK, and it’s added after the time in the title. Cancel leaves the title as the time only.

Small note window with a text box containing step-2 & OK & Cancel buttons
The note window that appears after each screenshot

How it works

Watching the clipboard

The C# class ClipboardListeningForm in the middle of the script is a window that Windows tells about every clipboard change (AddClipboardFormatListener and the WM_CLIPBOARDUPDATE message). The script uses it as the main window, so a screenshot triggers the ClipboardChanged event right away, with no polling.

Adding the slide

PowerPoint is driven through COM. The COM objects (application, presentations, slides, the new slide, its shapes and so on) go into one array, $coms, so they can all be released at the end. The new slide uses the Title Only layout (ppLayoutTitleOnly, value 11, see PpSlideLayout enumeration on Microsoft Learn). The script adds it after the last slide, pastes the clipboard, writes the time into the title, then clears the clipboard.

Why the note window only hides

The main window runs with ShowDialog(), so the note window has to use Show() instead. A window opened with Show() is gone for good once it closes, so it couldn’t come back for the next screenshot. That’s why its Closing event cancels the close and just hides the window. $CustomTextForm.Owner ties it to the main window so it doesn’t keep the script running after you close the tool.

What changed from my first version

Testing this English version showed a few rough spots in my original script, so I fixed them here:

  • The OK and Cancel actions of the note window were added inside the clipboard event, so a new copy piled up with every screenshot. Now they’re set up once, before the tool starts
  • A full-size screenshot covered the slide title. Now the image is shrunk to fit below the title and centered
  • The cleanup at the end printed errors when the presentation was already closed. It now uses $null -ne $coms[$i], which doesn’t make PowerShell walk through COM collections

Notes

  • You need PowerShell scripts allowed to run, and Microsoft PowerPoint installed
  • You need a screenshot tool that copies to the clipboard: Print Screen, Windows key + Shift + S, the Snipping Tool, and so on
  • Copying any image (not just a screenshot) while it says Running also adds a slide
  • If you close PowerPoint while it says Running, the next screenshot gives an error. Close the tool first
  • The tool doesn’t save the presentation. Save it in PowerPoint when you’re done

Ideas to make it your own

  • To keep images at full size, remove the block under # Shrink the image
  • Change the date format in Get-Date -Format "yyyy/MM/dd HH:mm:ss" to whatever you like

Summary

This PowerShell tool turns each screenshot into a PowerPoint slide titled with the capture time, plus an optional note. Your evidence ends up in one file with thumbnails, in order, and easy to search by time or step.

References

Revision history

2024/02/11 First version
2026/11/23 English version. Note window fix, images fit below the title, cleaner cleanup

Comments

Copied title and URL