I use ShareX and Microsoft Outlook extensively, quite often together so it'd be very useful if ShareX could write to Recent Items so that screen captures are quickly attachable.
Asked
Active
Viewed 194 times
1 Answers
1
ShareX's "Actions" function allows files to be called with arguments and provides two variables:
%input. Described as 'File Path'.%output. Described as 'File Path without extension + "Output File Name Extension"'
I determined that:
- Calling the Command Prompt or Windows PowerShell binaries with the arguments being the commands to create the file would not work because, for some reason, the simple presence of the ShareX variables causes it to fail.
- Calling a PowerShell script file (
.PS1) with the arguments being the ShareX path variables would not work because, by default, they're not executable. - Calling a Batch script file (
.BAT) with the arguments being the ShareX path variables could work because, by default, they are executable.
After a ridiculous amount of trial-and-error (mostly to ensure compatibility with paths that contain single quotes), I created a .BAT file with the following content which works (somehow):
@echo off
PowerShell -Command " $File_Image_Path=""%1""; $File_Shortcut_Path = '%appData%\Microsoft\Windows\Recent\ShareX_' + (Get-Date -Format 'yyyy-MM-dd_HH-mm-ss') + '.lnk'; $File_Shortcut=(New-Object -COM WScript.Shell).CreateShortcut($File_Shortcut_Path); $File_Shortcut.TargetPath=$File_Image_Path; $File_Shortcut.Save(); "
So, the ShareX actions configuration is as follows:
- Name:
Recent Items - File path:
C:\Program Files\ShareX\addToRecentItems.bat - Arguments:
%input - Output file name extension: Blank
- Extension filter: Blank
- Hidden window: Yes
mythofechelon
- 1,191
