Add automatic clipboard copy option to OCR

This commit is contained in:
Luke Anderson 2018-11-29 23:10:42 +10:30
parent 7baeb193c6
commit bb5c5bcb99
5 changed files with 67 additions and 12 deletions

View file

@ -67,6 +67,11 @@ private async void OCRSpaceResultForm_Shown(object sender, EventArgs e)
if (ocrOptions.ProcessOnLoad && string.IsNullOrEmpty(Result))
{
await StartOCR(data, fileName);
if (!string.IsNullOrEmpty(Result) && ocrOptions.AutoCopy)
{
ClipboardHelpers.CopyText(Result);
}
}
}

View file

@ -32,5 +32,6 @@ public class OCROptions
public OCRSpaceLanguages DefaultLanguage { get; set; } = OCRSpaceLanguages.eng;
public bool Silent { get; set; } = false;
public bool ProcessOnLoad { get; set; } = true;
public bool AutoCopy { get; set; } = true;
}
}

View file

@ -176,6 +176,8 @@ private void InitializeComponent()
this.nudGIFFPS = new System.Windows.Forms.NumericUpDown();
this.lblGIFFPS = new System.Windows.Forms.Label();
this.tpOCR = new System.Windows.Forms.TabPage();
this.cbCaptureOCRAutoCopy = new System.Windows.Forms.CheckBox();
this.cbCaptureOCRProcessOnLoad = new System.Windows.Forms.CheckBox();
this.cbCaptureOCRSilent = new System.Windows.Forms.CheckBox();
this.lblOCRDefaultLanguage = new System.Windows.Forms.Label();
this.cbCaptureOCRDefaultLanguage = new System.Windows.Forms.ComboBox();
@ -244,7 +246,6 @@ private void InitializeComponent()
this.pgTaskSettings = new System.Windows.Forms.PropertyGrid();
this.chkOverrideAdvancedSettings = new System.Windows.Forms.CheckBox();
this.tttvMain = new ShareX.HelpersLib.TabToTreeView();
this.cbCaptureOCRProcessOnLoad = new System.Windows.Forms.CheckBox();
this.tcTaskSettings.SuspendLayout();
this.tpTask.SuspendLayout();
this.cmsDestinations.SuspendLayout();
@ -1585,6 +1586,7 @@ private void InitializeComponent()
//
// tpOCR
//
this.tpOCR.Controls.Add(this.cbCaptureOCRAutoCopy);
this.tpOCR.Controls.Add(this.cbCaptureOCRProcessOnLoad);
this.tpOCR.Controls.Add(this.cbCaptureOCRSilent);
this.tpOCR.Controls.Add(this.lblOCRDefaultLanguage);
@ -1593,6 +1595,20 @@ private void InitializeComponent()
this.tpOCR.Name = "tpOCR";
this.tpOCR.UseVisualStyleBackColor = true;
//
// cbCaptureOCRAutoCopy
//
resources.ApplyResources(this.cbCaptureOCRAutoCopy, "cbCaptureOCRAutoCopy");
this.cbCaptureOCRAutoCopy.Name = "cbCaptureOCRAutoCopy";
this.cbCaptureOCRAutoCopy.UseVisualStyleBackColor = true;
this.cbCaptureOCRAutoCopy.CheckedChanged += new System.EventHandler(this.cbCaptureOCRAutoCopy_CheckedChanged);
//
// cbCaptureOCRProcessOnLoad
//
resources.ApplyResources(this.cbCaptureOCRProcessOnLoad, "cbCaptureOCRProcessOnLoad");
this.cbCaptureOCRProcessOnLoad.Name = "cbCaptureOCRProcessOnLoad";
this.cbCaptureOCRProcessOnLoad.UseVisualStyleBackColor = true;
this.cbCaptureOCRProcessOnLoad.CheckedChanged += new System.EventHandler(this.cbCaptureOCRProcessOnLoad_CheckedChanged);
//
// cbCaptureOCRSilent
//
resources.ApplyResources(this.cbCaptureOCRSilent, "cbCaptureOCRSilent");
@ -2092,13 +2108,6 @@ private void InitializeComponent()
this.tttvMain.TreeViewSize = 190;
this.tttvMain.TabChanged += new ShareX.HelpersLib.TabToTreeView.TabChangedEventHandler(this.tttvMain_TabChanged);
//
// cbCaptureOCRProcessOnLoad
//
resources.ApplyResources(this.cbCaptureOCRProcessOnLoad, "cbCaptureOCRProcessOnLoad");
this.cbCaptureOCRProcessOnLoad.Name = "cbCaptureOCRProcessOnLoad";
this.cbCaptureOCRProcessOnLoad.UseVisualStyleBackColor = true;
this.cbCaptureOCRProcessOnLoad.CheckedChanged += new System.EventHandler(this.cbCaptureOCRProcessOnLoad_CheckedChanged);
//
// TaskSettingsForm
//
resources.ApplyResources(this, "$this");
@ -2405,5 +2414,6 @@ private void InitializeComponent()
private System.Windows.Forms.ComboBox cbCaptureOCRDefaultLanguage;
private System.Windows.Forms.CheckBox cbCaptureOCRSilent;
private System.Windows.Forms.CheckBox cbCaptureOCRProcessOnLoad;
private System.Windows.Forms.CheckBox cbCaptureOCRAutoCopy;
}
}

View file

@ -306,6 +306,10 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
cbCaptureOCRSilent.Checked = ocrOptions.Silent;
cbCaptureOCRProcessOnLoad.Checked = ocrOptions.ProcessOnLoad;
cbCaptureOCRAutoCopy.Checked = ocrOptions.AutoCopy;
cbCaptureOCRAutoCopy.Enabled = !cbCaptureOCRSilent.Checked;
cbCaptureOCRProcessOnLoad.Enabled = !cbCaptureOCRSilent.Checked;
#endregion
@ -1120,6 +1124,9 @@ private void cbCaptureOCRDefaultLanguage_SelectedIndexChanged(object sender, Eve
private void cbCaptureOCRSilent_CheckedChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.OCROptions.Silent = cbCaptureOCRSilent.Checked;
cbCaptureOCRAutoCopy.Enabled = !cbCaptureOCRSilent.Checked;
cbCaptureOCRProcessOnLoad.Enabled = !cbCaptureOCRSilent.Checked;
}
private void cbCaptureOCRProcessOnLoad_CheckedChanged(object sender, EventArgs e)
@ -1127,6 +1134,11 @@ private void cbCaptureOCRProcessOnLoad_CheckedChanged(object sender, EventArgs e
TaskSettings.CaptureSettings.OCROptions.ProcessOnLoad = cbCaptureOCRProcessOnLoad.Checked;
}
private void cbCaptureOCRAutoCopy_CheckedChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.OCROptions.AutoCopy = cbCaptureOCRAutoCopy.Checked;
}
#endregion
#endregion Capture

View file

@ -3780,6 +3780,33 @@
<data name="&gt;&gt;tpScreenRecorder.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="cbCaptureOCRAutoCopy.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="cbCaptureOCRAutoCopy.Location" type="System.Drawing.Point, System.Drawing">
<value>11, 106</value>
</data>
<data name="cbCaptureOCRAutoCopy.Size" type="System.Drawing.Size, System.Drawing">
<value>205, 17</value>
</data>
<data name="cbCaptureOCRAutoCopy.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="cbCaptureOCRAutoCopy.Text" xml:space="preserve">
<value>Automatically copy results to clipboard</value>
</data>
<data name="&gt;&gt;cbCaptureOCRAutoCopy.Name" xml:space="preserve">
<value>cbCaptureOCRAutoCopy</value>
</data>
<data name="&gt;&gt;cbCaptureOCRAutoCopy.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbCaptureOCRAutoCopy.Parent" xml:space="preserve">
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRAutoCopy.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="cbCaptureOCRProcessOnLoad.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -3808,7 +3835,7 @@
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRProcessOnLoad.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="cbCaptureOCRSilent.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -3838,7 +3865,7 @@
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRSilent.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<data name="lblOCRDefaultLanguage.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -3868,7 +3895,7 @@
<value>tpOCR</value>
</data>
<data name="&gt;&gt;lblOCRDefaultLanguage.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="cbCaptureOCRDefaultLanguage.Location" type="System.Drawing.Point, System.Drawing">
<value>11, 24</value>
@ -3889,7 +3916,7 @@
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRDefaultLanguage.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="tpOCR.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 22</value>