Skip to content

Commit e1ee510

Browse files
kjkclaude
andcommitted
add CmdSetScreenshotHotkey to set/remove global screenshot hotkey (fixes #5518)
Dialog captures key combinations including PrtSc (via low-level keyboard hook), shows current hotkey, and allows setting or removing it. Updates the Shortcuts section in advanced settings with Cmd = CmdScreenshot. Unregisters hotkey before dialog opens so keys can be captured, restores on cancel. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 381fc41 commit e1ee510

9 files changed

Lines changed: 342 additions & 2 deletions

File tree

cmd/gen-commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export const commands = [
224224
"CmdPdShowInfo", "Show PDF Info",
225225
"CmdDocumentExtractText", "Extract Text From Document",
226226
"CmdDocumentShowOutline", "Show Document Bookmarks",
227+
"CmdSetScreenshotHotkey", "Set Screenshot Hotkey",
227228
"CmdNone", "Do nothing",
228229
];
229230

docs/md/Commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ CmdPdfDeletePages,,Delete Pages From PDF,"Delete pages from a PDF file using pag
296296
CmdPdfExtractPages,,Extract Pages From PDF,"Extract pages from a PDF file using page ranges like 1,3-8,13-N where N is the last page, ver 3.7+"
297297
CmdPdfEncrypt,,Encrypt PDF,"Encrypt a PDF file with a password using AES-256 encryption, ver 3.7+"
298298
CmdPdfDecrypt,,Decrypt PDF,"Decrypt an encrypted PDF file, removing password protection, ver 3.7+"
299+
CmdSetScreenshotHotkey,,Set Screenshot Hotkey,"Open dialog to set or remove a global hotkey for taking screenshots, ver 3.7+"
299300
```
300301

301302
## Debug

docs/md/Version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Available in [pre-release](https://www.sumatrapdfreader.org/prerelease) builds.
4242
- Can save images in different formats: PNG, JPEG, BMP, GIF, TIFF.
4343
- add `CmdPdfBake` (`Bake PDF File` in `Ctrl + k` [command palette](Command-Palette.md)) to bake interactive form and annotation content into static graphics in a new PDF file
4444
- add `Fullscreen` advanced setting with `ShowToolbar` and `ShowMenubar` options to show toolbar and menu bar in fullscreen mode. Use `F9` / `F8` to toggle them while in fullscreen
45+
- add `CmdSetScreenshotHotkey` (`Set Screenshot Hotkey` in `Ctrl + k` [command palette](Command-Palette.md)) to set or remove a global hotkey for taking screenshots
4546
- add `Show Errors` in right-click context menu for PDF documents that have mupdf warnings/errors
4647
- add `CmdToggleSmoothScroll` (`Toggle Smooth Scroll`) command to toggle `SmoothScroll` advanced setting
4748
- replace `HideScrollbars` and `UseOverlayScrollbar` settings with `Scrollbars` setting (values: `windows`, `smart`, `overlay`, `hidden`)

src/CommandPalette.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ static i32 gDocumentNotOpenWhitelist[] = {
119119
CmdDebugCorruptMemory,
120120
CmdScreenshot,
121121
CmdTabGroupRestore,
122+
CmdSetScreenshotHotkey,
122123
0,
123124
};
124125

src/Commands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ static SeqStrings gCommandNames =
234234
"CmdPdShowInfo\0"
235235
"CmdDocumentExtractText\0"
236236
"CmdDocumentShowOutline\0"
237+
"CmdSetScreenshotHotkey\0"
237238
"CmdNone\0"
238239
"\0";
239240

@@ -458,6 +459,7 @@ static i32 gCommandIds[] = {
458459
CmdPdShowInfo,
459460
CmdDocumentExtractText,
460461
CmdDocumentShowOutline,
462+
CmdSetScreenshotHotkey,
461463
CmdNone,
462464
};
463465

@@ -682,6 +684,7 @@ SeqStrings gCommandDescriptions =
682684
"Show PDF Info\0"
683685
"Extract Text From Document\0"
684686
"Show Document Bookmarks\0"
687+
"Set Screenshot Hotkey\0"
685688
"Do nothing\0"
686689
"\0";
687690
// clang-format on

src/Commands.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ enum {
229229
CmdPdShowInfo = 418,
230230
CmdDocumentExtractText = 419,
231231
CmdDocumentShowOutline = 420,
232-
CmdNone = 421,
232+
CmdSetScreenshotHotkey = 421,
233+
CmdNone = 422,
233234

234235
/* range for file history */
235236
CmdFileHistoryFirst,

0 commit comments

Comments
 (0)