ScreenSnip Enhanced

Discussion in 'Scripting' started by Thomas Dubreuil, Apr 14, 2019 at 21:05.

  1. Thomas Dubreuil

    Thomas Dubreuil MDL Member

    Aug 29, 2017
    199
    302
    10
    I recently explored NirCmd options and it gave me some ideas...

    I like to use "native tools" as much as I can, but always found taking screenshots with windows "counter productive", because most of the time I'll upload it, and I always have to save it to a file.

    That's over now with this simple script: it will save your screenshot with date and time directly on your desktop.

    Disclaimer:
    Needs NirCmd
    Replace NIRCMDPATH value with your own nircmd path.

    Code:
    @echo off
    
    "C:\Program Files\System Tools\System Utilities\NirCmd\nircmdc.exe" clipboard clear
    start /wait explorer.exe ms-screenclip:
    :SaveImage_loop
    for /f "tokens=1, 2, 3, 4 delims=-/. " %%a in ("%DATE%") do set "ClipName=%%a-%%b-%%c"
    for /f "tokens=1-3 delims=:," %%a in ("%TIME%") do set "ClipName=%ClipName%_%%ah%%bm%%cs"
    "NIRCMDPATH\nircmdc.exe" clipboard saveimage "%USERPROFILE%\Desktop\%ClipName%.png"
    if exist "%USERPROFILE%\Desktop\%ClipName%.png" exit /b
    goto :SaveImage_loop
    Bonus: ScreenSnip - Active window (2s delay)
    It will take a screenshot of your active/selected window only, like explorer, notepad, or firefox etc. after 2 seconds delay (which gives you time to open a .txt even), and save it on your desktop with date and time.
    Disclaimer: Needs NirCmd
    Replace NIRCMDPATH value with your own nircmd path.

    Code:
    @echo off
    
    "C:\Program Files\System Tools\System Utilities\NirCmd\nircmdc.exe" clipboard clear
    timeout /t 2 /nobreak >NUL 2>&1
    "C:\Program Files\System Tools\System Utilities\NirCmd\nircmdc.exe" sendkeypress alt+printscreen
    :SaveImage_loop
    for /f "tokens=1, 2, 3, 4 delims=-/. " %%a in ("%DATE%") do set "ClipName=%%a-%%b-%%c"
    for /f "tokens=1-3 delims=:," %%a in ("%TIME%") do set "ClipName=%ClipName%_%%ah%%bm%%cs"
    "NIRCMDPATH\nircmdc.exe" clipboard saveimage "%USERPROFILE%\Desktop\%ClipName%.png"
    if exist "%USERPROFILE%\Desktop\%ClipName%.png" exit /b
    goto :SaveImage_loop
    Bonus2: ScreenSnip - Fullscreen
    It will take a full screen screenshot and save it on your desktop with date and time.
    Disclaimer: Needs NirCmd
    Replace NIRCMDPATH value with your own nircmd path.

    Code:
    @echo off
    
    for /f "tokens=1, 2, 3, 4 delims=-/. " %%a in ("%DATE%") do set "ClipName=%%a-%%b-%%c"
    for /f "tokens=1-3 delims=:," %%a in ("%TIME%") do set "ClipName=%ClipName%_%%ah%%bm%%cs"
    "NIRCMDPATH\nircmdc.exe" savescreenshot "%USERPROFILE%\Desktop\%ClipName%.png"
    exit /b
    Bonus3: Add all this to your context menu.
    Save the scripts as ScreenSnipEnhanced.bat, ScreenSnipActiveWindow.bat, ScreenSnipFullScreen.bat

    Code:
    @echo off
    
        echo Enter NirCmd path here:
            set /p "NirCmdFolder="
        echo Enter scripts path here:
            set /p "ScriptPath="
    echo SnippingTool and ScreenSnipContext Menu
            reg add "HKCR\Directory\background\shell\03_ScreenSnip_Enhanced" /v "Icon" /t REG_SZ /d "%%SystemRoot%%\System32\shell32.dll,259" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\03_ScreenSnip_Enhanced" /v "MUIVerb" /t REG_SZ /d "ScreenSnip - Enhanced" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\03_ScreenSnip_Enhanced" /v "Position" /t REG_SZ /d "Bottom" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\03_ScreenSnip_Enhanced\command" /ve /t REG_SZ /d "\"%NirCmdFolder%\nircmd.exe\" exec hide \"%ScriptPath%\ScreenSnipEnhanced.bat\"" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools" /v "Icon" /t REG_SZ /d "SnippingTool.exe" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools" /v "MUIVerb" /t REG_SZ /d "Snipping Tools" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools" /v "Position" /t REG_SZ /d "Bottom" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools" /v "SeparatorAfter" /t REG_DWORD /d "1" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools" /v "SubCommands" /t REG_SZ /d "" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\01_ScreenSnip_ActiveWindow" /v "Icon" /t REG_SZ /d "%%SystemRoot%%\System32\shell32.dll,259" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\01_ScreenSnip_ActiveWindow" /ve /t REG_SZ /d "ScreenSnip - Active Window (2 s delay)" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\01_ScreenSnip_ActiveWindow\command" /ve /t REG_SZ /d "\"%NirCmdFolder%\nircmd.exe\" exec hide \"%ScriptPath%\ScreenSnipActiveWindow.bat\"" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\02_ScreenSnip_Fullscreen" /v "Icon" /t REG_SZ /d "%%SystemRoot%%\System32\shell32.dll,259" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\02_ScreenSnip_Fullscreen" /ve /t REG_SZ /d "ScreenSnip - Full Screen" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\02_ScreenSnip_Fullscreen\command" /ve /t REG_SZ /d "\"%NirCmdFolder%\nircmd.exe\" exec hide \"%ScriptPath%\ScreenSnipFullScreen.bat\"" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\03_SnippingTool" /v "MUIVerb" /t REG_SZ /d "@SnippingTool.exe,-101" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\03_SnippingTool" /v "Icon" /t REG_SZ /d "SnippingTool.exe" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\03_SnippingTool" /v "CommandFlags" /t REG_DWORD /d "32" /f >NUL 2>&1
            reg add "HKCR\Directory\background\shell\04_SnippingTools\shell\03_SnippingTool\Command" /ve /t REG_SZ /d "SnippingTool.exe" /f >NUL 2>&1
    goto :eof
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...