Search code examples
javascriptpowershellcommand-line-interfacebatch-processingpaint

close and 'save as' for 100 of MS Paint files at once?


I take everyday 100 print screen images and paste them on another 100 MS paint files. I need to automate the process of saving all 100 opened files at once. I know that using 'tasklist | find "mspaint"' will bring all tasks with process IDs but how can I add more steps to make it all saved at once? e.g. 1.png, 2.png...100.png.


Solution

  • thanks to this post https://www.timsblog.nl/2016/01/13/asynchronously-save-images-in-the-clipboard-to-file/, I finally find a perfect answer to my question. the whole process can be fully automated using powershell_ise.

    Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -Action {
        $content = Get-Clipboard -Format Image
        If ($content) 
        {
            $path = $psISE.CurrentFile.FullPath | Split-Path
            $filename = "$path\ImageCap - " + (Get-date -Format 'hh-mm-ss') + '.png'
            $content.Save($filename,'png')
            Set-Clipboard -Value $Null
        }
    }