diff --git a/ShareX.HelpersLib/ExternalProgram.cs b/ShareX.HelpersLib/ExternalProgram.cs
index 97e25bd90..8552da3b9 100644
--- a/ShareX.HelpersLib/ExternalProgram.cs
+++ b/ShareX.HelpersLib/ExternalProgram.cs
@@ -32,16 +32,16 @@ namespace ShareX.HelpersLib
public class ExternalProgram
{
public bool IsActive { get; set; }
- public bool HiddenWindow { get; set; }
public string Name { get; set; }
public string Path { get; set; }
public string Args { get; set; }
- public string Extensions { get; set; }
public string OutputExtension { get; set; }
+ public string Extensions { get; set; }
+ public bool HiddenWindow { get; set; }
+ public bool DeleteInputFile { get; set; }
public ExternalProgram()
{
- IsActive = false;
Args = "%input";
}
@@ -59,87 +59,111 @@ public ExternalProgram(string name, string path, string args) : this(name, path)
}
}
- public string Run(string filePath)
+ public string Run(string inputPath)
{
- if (!string.IsNullOrEmpty(filePath) && CheckExtensions(filePath) && !string.IsNullOrEmpty(Path) && File.Exists(Path))
+ if (!string.IsNullOrEmpty(Path) && File.Exists(Path) && !string.IsNullOrWhiteSpace(inputPath))
{
- filePath = filePath.Trim('"');
+ inputPath = inputPath.Trim('"');
- try
+ if (CheckExtension(inputPath, Extensions))
{
- string outputPath = "";
-
- using (Process process = new Process())
+ try
{
- ProcessStartInfo psi = new ProcessStartInfo(Path);
+ string outputPath = inputPath;
- if (string.IsNullOrEmpty(Args))
+ using (Process process = new Process())
{
- psi.Arguments = '"' + filePath + '"';
- }
- else
- {
- if (!string.IsNullOrEmpty(OutputExtension))
+ ProcessStartInfo psi = new ProcessStartInfo(Path);
+ psi.UseShellExecute = false;
+
+ if (string.IsNullOrEmpty(Args))
{
- outputPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath));
-
- if (!OutputExtension.Contains("."))
- {
- OutputExtension = "." + OutputExtension;
- }
-
- outputPath += OutputExtension;
+ psi.Arguments = '"' + inputPath + '"';
}
else
{
- outputPath = filePath;
+ if (!string.IsNullOrWhiteSpace(OutputExtension))
+ {
+ outputPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputPath), System.IO.Path.GetFileNameWithoutExtension(inputPath));
+
+ if (!OutputExtension.StartsWith("."))
+ {
+ outputPath += ".";
+ }
+
+ outputPath += OutputExtension;
+ }
+
+ psi.Arguments = CodeMenuEntryActions.Parse(Args, inputPath, outputPath);
}
- psi.Arguments = CodeMenuEntryActions.Parse(Args, filePath, outputPath);
+ if (HiddenWindow)
+ {
+ psi.CreateNoWindow = true;
+ }
+
+ process.StartInfo = psi;
+
+ DebugHelper.WriteLine($"Running \"{psi.FileName}\" with arguments: {psi.Arguments}");
+
+ process.Start();
+ process.WaitForExit();
}
- if (HiddenWindow)
+ if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
{
- psi.WindowStyle = ProcessWindowStyle.Hidden;
- psi.CreateNoWindow = true;
+ if (DeleteInputFile && !inputPath.Equals(outputPath, StringComparison.OrdinalIgnoreCase) && File.Exists(inputPath))
+ {
+ DebugHelper.WriteLine("Deleting input file: " + inputPath);
+
+ File.Delete(inputPath);
+ }
+
+ return outputPath;
}
- process.StartInfo = psi;
-
- DebugHelper.WriteLine(string.Format("Running {0} with arguments: {1}", Path, psi.Arguments));
-
- process.Start();
- process.WaitForExit();
+ return inputPath;
}
-
- if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
+ catch (Exception e)
{
- return outputPath;
+ DebugHelper.WriteException(e);
}
-
- return filePath;
- }
- catch (Exception e)
- {
- DebugHelper.WriteException(e);
}
}
- return filePath;
+ return inputPath;
}
- private bool CheckExtensions(string path)
+ private bool CheckExtension(string path, string extensions)
{
- if (string.IsNullOrEmpty(Extensions) || string.IsNullOrEmpty(path)) return true;
- int idx = 0;
- for (int i = 0; i <= Extensions.Length; ++i)
+ if (!string.IsNullOrWhiteSpace(path))
{
- if (i == Extensions.Length || !char.IsLetterOrDigit(Extensions[i]))
+ if (string.IsNullOrWhiteSpace(extensions))
{
- if (idx < i && path.EndsWith(Extensions.Substring(idx, i - idx))) return true;
- idx = i + 1;
+ return true;
+ }
+
+ int index = 0;
+
+ for (int i = 0; i <= extensions.Length; ++i)
+ {
+ if (i == extensions.Length || !char.IsLetterOrDigit(extensions[i]))
+ {
+ if (i > index)
+ {
+ string extension = "." + extensions.Substring(index, i - index);
+
+ if (path.EndsWith(extension, StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+
+ index = i + 1;
+ }
}
}
+
return false;
}
}
diff --git a/ShareX/Forms/ActionsForm.Designer.cs b/ShareX/Forms/ActionsForm.Designer.cs
index 32c585f8a..25f0012c7 100644
--- a/ShareX/Forms/ActionsForm.Designer.cs
+++ b/ShareX/Forms/ActionsForm.Designer.cs
@@ -43,6 +43,7 @@ private void InitializeComponent()
this.txtOutputExtension = new System.Windows.Forms.TextBox();
this.lblOutputExtension = new System.Windows.Forms.Label();
this.cbHiddenWindow = new System.Windows.Forms.CheckBox();
+ this.cbDeleteInputFile = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// lblName
@@ -92,6 +93,7 @@ private void InitializeComponent()
// btnCancel
//
resources.ApplyResources(this.btnCancel, "btnCancel");
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Name = "btnCancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
@@ -110,6 +112,7 @@ private void InitializeComponent()
//
resources.ApplyResources(this.txtOutputExtension, "txtOutputExtension");
this.txtOutputExtension.Name = "txtOutputExtension";
+ this.txtOutputExtension.TextChanged += new System.EventHandler(this.txtOutputExtension_TextChanged);
//
// lblOutputExtension
//
@@ -122,6 +125,12 @@ private void InitializeComponent()
this.cbHiddenWindow.Name = "cbHiddenWindow";
this.cbHiddenWindow.UseVisualStyleBackColor = true;
//
+ // cbDeleteInputFile
+ //
+ resources.ApplyResources(this.cbDeleteInputFile, "cbDeleteInputFile");
+ this.cbDeleteInputFile.Name = "cbDeleteInputFile";
+ this.cbDeleteInputFile.UseVisualStyleBackColor = true;
+ //
// ActionsForm
//
this.AcceptButton = this.btnOK;
@@ -129,6 +138,7 @@ private void InitializeComponent()
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.CancelButton = this.btnCancel;
+ this.Controls.Add(this.cbDeleteInputFile);
this.Controls.Add(this.cbHiddenWindow);
this.Controls.Add(this.lblOutputExtension);
this.Controls.Add(this.txtOutputExtension);
@@ -166,5 +176,6 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtOutputExtension;
private System.Windows.Forms.Label lblOutputExtension;
private System.Windows.Forms.CheckBox cbHiddenWindow;
+ private System.Windows.Forms.CheckBox cbDeleteInputFile;
}
}
\ No newline at end of file
diff --git a/ShareX/Forms/ActionsForm.cs b/ShareX/Forms/ActionsForm.cs
index 744108c88..a769f073c 100644
--- a/ShareX/Forms/ActionsForm.cs
+++ b/ShareX/Forms/ActionsForm.cs
@@ -51,6 +51,7 @@ public ActionsForm(ExternalProgram fileAction)
txtOutputExtension.Text = fileAction.OutputExtension ?? "";
txtExtensions.Text = fileAction.Extensions ?? "";
cbHiddenWindow.Checked = fileAction.HiddenWindow;
+ cbDeleteInputFile.Checked = fileAction.DeleteInputFile;
}
private void btnPathBrowse_Click(object sender, EventArgs e)
@@ -58,6 +59,11 @@ private void btnPathBrowse_Click(object sender, EventArgs e)
Helpers.BrowseFile(txtPath);
}
+ private void txtOutputExtension_TextChanged(object sender, EventArgs e)
+ {
+ cbDeleteInputFile.Enabled = txtOutputExtension.TextLength > 0;
+ }
+
private void btnOK_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtName.Text))
@@ -78,6 +84,7 @@ private void btnOK_Click(object sender, EventArgs e)
FileAction.Extensions = txtExtensions.Text;
FileAction.OutputExtension = txtOutputExtension.Text;
FileAction.HiddenWindow = cbHiddenWindow.Checked;
+ FileAction.DeleteInputFile = cbDeleteInputFile.Checked;
DialogResult = DialogResult.OK;
Close();
diff --git a/ShareX/Forms/ActionsForm.resx b/ShareX/Forms/ActionsForm.resx
index 02874f675..851d4a716 100644
--- a/ShareX/Forms/ActionsForm.resx
+++ b/ShareX/Forms/ActionsForm.resx
@@ -144,7 +144,7 @@
$this
- 13
+ 14
True
@@ -171,7 +171,7 @@
$this
- 12
+ 13
True
@@ -198,7 +198,7 @@
$this
- 11
+ 12
@@ -223,7 +223,7 @@
$this
- 10
+ 11
Top, Left, Right
@@ -247,7 +247,7 @@
$this
- 9
+ 10
Top, Left, Right
@@ -271,7 +271,7 @@
$this
- 8
+ 9
Top, Right
@@ -287,7 +287,7 @@
...
- @Invariant
+
btnPathBrowse
@@ -298,16 +298,16 @@
$this
- 7
+ 8
- Top, Right
+ Bottom, Right
- 155, 285
+ 136, 304
- 72, 24
+ 80, 24
11
@@ -325,16 +325,16 @@
$this
- 6
+ 7
- Top, Right
+ Bottom, Right
- 233, 285
+ 224, 304
- 72, 24
+ 80, 24
12
@@ -352,7 +352,7 @@
$this
- 5
+ 6
True
@@ -379,7 +379,7 @@
$this
- 4
+ 5
Top, Left, Right
@@ -403,7 +403,7 @@
$this
- 3
+ 4
Top, Left, Right
@@ -427,7 +427,7 @@
$this
- 2
+ 3
True
@@ -454,7 +454,7 @@
$this
- 1
+ 2
True
@@ -484,6 +484,36 @@
$this
+ 1
+
+
+ True
+
+
+ False
+
+
+ 8, 272
+
+
+ 99, 17
+
+
+ 14
+
+
+ Delete input file
+
+
+ cbDeleteInputFile
+
+
+ System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
0
@@ -493,7 +523,7 @@
6, 13
- 313, 317
+ 313, 337
CenterScreen
diff --git a/ShareX/Forms/TaskSettingsForm.Designer.cs b/ShareX/Forms/TaskSettingsForm.Designer.cs
index e5083331d..f275271eb 100644
--- a/ShareX/Forms/TaskSettingsForm.Designer.cs
+++ b/ShareX/Forms/TaskSettingsForm.Designer.cs
@@ -1935,6 +1935,7 @@ private void InitializeComponent()
this.lvActions.View = System.Windows.Forms.View.Details;
this.lvActions.ItemMoved += new ShareX.HelpersLib.MyListView.ListViewItemMovedEventHandler(this.lvActions_ItemMoved);
this.lvActions.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.lvActions_ItemChecked);
+ this.lvActions.SelectedIndexChanged += new System.EventHandler(this.lvActions_SelectedIndexChanged);
//
// chActionsName
//
diff --git a/ShareX/Forms/TaskSettingsForm.cs b/ShareX/Forms/TaskSettingsForm.cs
index 77ff6d5bf..845e29c83 100644
--- a/ShareX/Forms/TaskSettingsForm.cs
+++ b/ShareX/Forms/TaskSettingsForm.cs
@@ -311,7 +311,7 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
cbCaptureOCRAutoCopy.Enabled = !cbCaptureOCRSilent.Checked;
cbCaptureOCRProcessOnLoad.Enabled = !cbCaptureOCRSilent.Checked;
- #endregion
+ #endregion OCR
#endregion Capture
@@ -1139,7 +1139,7 @@ private void cbCaptureOCRAutoCopy_CheckedChanged(object sender, EventArgs e)
TaskSettings.CaptureSettings.OCROptions.AutoCopy = cbCaptureOCRAutoCopy.Checked;
}
- #endregion
+ #endregion OCR
#endregion Capture
@@ -1206,6 +1206,11 @@ private void txtNameFormatPatternActiveWindow_TextChanged(object sender, EventAr
UpdateNameFormatPreviews();
}
+ private void cbFileUploadReplaceProblematicCharacters_CheckedChanged(object sender, EventArgs e)
+ {
+ TaskSettings.UploadSettings.FileUploadReplaceProblematicCharacters = cbFileUploadReplaceProblematicCharacters.Checked;
+ }
+
private void btnResetAutoIncrementNumber_Click(object sender, EventArgs e)
{
Program.Settings.NameParserAutoIncrementNumber = 0;
@@ -1424,6 +1429,11 @@ private void btnActionsRemove_Click(object sender, EventArgs e)
}
}
+ private void lvActions_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ btnActionsEdit.Enabled = btnActionsDuplicate.Enabled = btnActionsRemove.Enabled = lvActions.SelectedItems.Count > 0;
+ }
+
private void lvActions_ItemChecked(object sender, ItemCheckedEventArgs e)
{
ExternalProgram fileAction = e.Item.Tag as ExternalProgram;
@@ -1534,11 +1544,6 @@ private void txtToolsScreenColorPickerFormat_TextChanged(object sender, EventArg
TaskSettings.ToolsSettings.ScreenColorPickerFormat = txtToolsScreenColorPickerFormat.Text;
}
- private void cbFileUploadReplaceProblematicCharacters_CheckedChanged(object sender, EventArgs e)
- {
- TaskSettings.UploadSettings.FileUploadReplaceProblematicCharacters = cbFileUploadReplaceProblematicCharacters.Checked;
- }
-
#endregion Tools
#region Advanced
diff --git a/ShareX/Forms/TaskSettingsForm.resx b/ShareX/Forms/TaskSettingsForm.resx
index 5f8a54e9b..780908f56 100644
--- a/ShareX/Forms/TaskSettingsForm.resx
+++ b/ShareX/Forms/TaskSettingsForm.resx
@@ -421,7 +421,7 @@
btnAfterCapture
- ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
tpTask
@@ -451,7 +451,7 @@
btnAfterUpload
- ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
tpTask
@@ -523,7 +523,7 @@
btnDestinations
- ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
tpTask
@@ -553,7 +553,7 @@
btnTask
- ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
tpTask
@@ -4606,7 +4606,7 @@
lvUploaderFiltersList
- ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
tpUploaderFilters
@@ -4887,6 +4887,9 @@
4
+
+ False
+
NoControl
@@ -4981,7 +4984,7 @@
lvActions
- ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
pActions
@@ -4989,6 +4992,9 @@
2
+
+ False
+
NoControl
@@ -5016,6 +5022,9 @@
3
+
+ False
+
NoControl
@@ -5572,7 +5581,7 @@
tttvMain
- ShareX.HelpersLib.TabToTreeView, ShareX.HelpersLib, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null
+ ShareX.HelpersLib.TabToTreeView, ShareX.HelpersLib, Version=12.4.0.0, Culture=neutral, PublicKeyToken=null
$this