Skip to content

Conversation

@daverayment
Copy link
Collaborator

@daverayment daverayment commented Nov 1, 2025

Summary of the Pull Request

This PR:

  1. Fixes a flaw with ZoomIt's screenshot save feature where the .png file extension would not be included when a period was present anywhere in the path.

  2. Includes an update to create unique screenshot filenames, saving the user from having to manually type a new filename each time they save a new screenshot in the same location.

PR Checklist

  • Closes: ZoomIt capture saving #43158
  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Extension addition error

This code in Zoomit.cpp contains the error:

            openFileName.lpstrFile			= filePath;
            if( GetSaveFileName( &openFileName ) )
            {
                TCHAR targetFilePath[MAX_PATH];
                _tcscpy( targetFilePath, filePath );
                if( !_tcsrchr( targetFilePath, '.' ) )
                {
                    _tcscat( targetFilePath, L".png" );
                }

(https://github.com/microsoft/PowerToys/blob/main/src/modules/ZoomIt/ZoomIt/Zoomit.cpp#L6253-L6261)

The intention appears to be to append the extension when it doesn't already exist, but the check is flawed. Instead of checking for the extension explicitly, it is assumed to exist if a period exists anywhere in the entire path. If the path is something like:

C:\Users\John.Smith\Pictures\zoomit

then it will fail to add the required extension.

There is actually no need for this manual check, as the appending of the extension will be done automatically when the file is saved if the lpstrDefExt property is set on the OPENFILENAME structure. Oddly, the intention to do this is hinted at in the existing code, but the implementation is commented out:

openFileName.lpstrDefExt = NULL; // "*.png";

This may have been done when the transition was being made from BMP screenshots to PNGs, or the issue may have been attempting to use "*.png" when only "png" is required.

This PR fixes the issue by:

  1. Restoring the assignment of png as the default filename extension - lpstrDefExt.
  2. Removing the check and manual addition of the extension.

Unique filename issue

The PR also fixes the user's other complaint about the screenshots always being called "zoomit" by adding a GetUniqueScreenshotFilename() method which creates a unique filename based on the current date and time, e.g. ZoomIt 2025-11-01 004723.png. This is consistent with other tools like the Windows Snipping Tool and provides files which sort correctly when ordered by name, which is not the case for files with simple numeric suffixes.

Validation Steps Performed

Tested on a local build.

  • Made repeated screenshots.
  • Tested that the overwrite protection still worked by manually editing the filename to coincide with a prior file.
  • Tested different folders than the default.

…mes when the path included a period. Add datetime suffix to screenshot filenames.
@daverayment daverayment added the Product-ZoomIt Refers to the ZoomIt tool label Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-ZoomIt Refers to the ZoomIt tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZoomIt capture saving

1 participant