diff --git a/ShareX/OCR/OCRForm.Designer.cs b/ShareX/OCR/OCRForm.Designer.cs
index 70ae102a83e..1f9bde5ab18 100644
--- a/ShareX/OCR/OCRForm.Designer.cs
+++ b/ShareX/OCR/OCRForm.Designer.cs
@@ -35,6 +35,8 @@ private void InitializeComponent()
this.txtResult = new System.Windows.Forms.TextBox();
this.lblScaleFactor = new System.Windows.Forms.Label();
this.nudScaleFactor = new System.Windows.Forms.NumericUpDown();
+ this.cbServices = new System.Windows.Forms.ComboBox();
+ this.btnOpen = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nudScaleFactor)).BeginInit();
this.SuspendLayout();
//
@@ -93,10 +95,26 @@ private void InitializeComponent()
0});
this.nudScaleFactor.ValueChanged += new System.EventHandler(this.nudScaleFactor_ValueChanged);
//
+ // cbServices
+ //
+ this.cbServices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ resources.ApplyResources(this.cbServices, "cbServices");
+ this.cbServices.FormattingEnabled = true;
+ this.cbServices.Name = "cbServices";
+ //
+ // btnOpen
+ //
+ resources.ApplyResources(this.btnOpen, "btnOpen");
+ this.btnOpen.Name = "btnOpen";
+ this.btnOpen.UseVisualStyleBackColor = true;
+ this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
+ //
// OCRForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.btnOpen);
+ this.Controls.Add(this.cbServices);
this.Controls.Add(this.nudScaleFactor);
this.Controls.Add(this.lblScaleFactor);
this.Controls.Add(this.txtResult);
@@ -120,5 +138,7 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.Label lblScaleFactor;
private System.Windows.Forms.NumericUpDown nudScaleFactor;
+ private System.Windows.Forms.ComboBox cbServices;
+ private System.Windows.Forms.Button btnOpen;
}
}
\ No newline at end of file
diff --git a/ShareX/OCR/OCRForm.cs b/ShareX/OCR/OCRForm.cs
index c79693c6137..247c0cac906 100644
--- a/ShareX/OCR/OCRForm.cs
+++ b/ShareX/OCR/OCRForm.cs
@@ -80,6 +80,16 @@ public OCRForm(Bitmap bmp, OCROptions options)
nudScaleFactor.SetValue((decimal)Options.ScaleFactor);
+ if (Options.ServiceLinks != null && Options.ServiceLinks.Count > 0)
+ {
+ cbServices.Items.AddRange(Options.ServiceLinks.ToArray());
+ cbServices.SelectedIndex = 0;
+ }
+ else
+ {
+ cbServices.Enabled = false;
+ }
+
txtResult.SupportSelectAll();
loaded = true;
@@ -127,5 +137,14 @@ private async void nudScaleFactor_ValueChanged(object sender, EventArgs e)
await OCR();
}
}
+
+ private void btnOpen_Click(object sender, EventArgs e)
+ {
+ if (cbServices.SelectedItem is ServiceLink serviceLink)
+ {
+ string input = txtResult.Text.Trim();
+ serviceLink.OpenLink(input);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/ShareX/OCR/OCRForm.resx b/ShareX/OCR/OCRForm.resx
index f46b9ad9df5..092b39faf89 100644
--- a/ShareX/OCR/OCRForm.resx
+++ b/ShareX/OCR/OCRForm.resx
@@ -147,7 +147,7 @@
$this
- 5
+ 7
Microsoft Sans Serif, 9.75pt
@@ -171,7 +171,7 @@
$this
- 4
+ 6
True
@@ -201,7 +201,7 @@
$this
- 3
+ 5
@@ -235,7 +235,7 @@
$this
- 2
+ 4
True
@@ -265,7 +265,7 @@
$this
- 1
+ 3
Microsoft Sans Serif, 9.75pt
@@ -292,6 +292,57 @@
$this
+ 2
+
+
+ Microsoft Sans Serif, 9.75pt
+
+
+ 440, 20
+
+
+ 168, 24
+
+
+ 7
+
+
+ cbServices
+
+
+ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 1
+
+
+ Microsoft Sans Serif, 9.75pt
+
+
+ 440, 48
+
+
+ 168, 32
+
+
+ 8
+
+
+ Open...
+
+
+ btnOpen
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
0
diff --git a/ShareX/OCR/OCROptions.cs b/ShareX/OCR/OCROptions.cs
index 254b2661ddc..554a2e510f8 100644
--- a/ShareX/OCR/OCROptions.cs
+++ b/ShareX/OCR/OCROptions.cs
@@ -23,6 +23,8 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3)
+using System.Collections.Generic;
+
namespace ShareX
{
public class OCROptions
@@ -31,5 +33,11 @@ public class OCROptions
public float ScaleFactor { get; set; } = 2f;
public bool Silent { get; set; } = false;
public bool AutoCopy { get; set; } = false;
+ public List ServiceLinks { get; set; } = new List()
+ {
+ new ServiceLink("Google Translate", "https://translate.google.com/?sl=auto&tl=en&text={0}&op=translate"),
+ new ServiceLink("Google Search", "https://www.google.com/search?q={0}"),
+ new ServiceLink("Bing", "https://www.bing.com/search?q={0}")
+ };
}
}
\ No newline at end of file
diff --git a/ShareX/OCR/ServiceLink.cs b/ShareX/OCR/ServiceLink.cs
new file mode 100644
index 00000000000..985df15351a
--- /dev/null
+++ b/ShareX/OCR/ServiceLink.cs
@@ -0,0 +1,67 @@
+#region License Information (GPL v3)
+
+/*
+ ShareX - A program that allows you to take screenshots and share any file type
+ Copyright (c) 2007-2022 ShareX Team
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Optionally you can also view the license at .
+*/
+
+#endregion License Information (GPL v3)
+
+using ShareX.HelpersLib;
+
+namespace ShareX
+{
+ public class ServiceLink
+ {
+ public string Name { get; set; }
+ public string URL { get; set; }
+
+ public ServiceLink(string name, string url)
+ {
+ Name = name;
+ URL = url;
+ }
+
+ public string GenerateLink(string input)
+ {
+ if (!string.IsNullOrEmpty(input))
+ {
+ string encodedInput = URLHelpers.URLEncode(input);
+ return string.Format(URL, encodedInput);
+ }
+
+ return null;
+ }
+
+ public void OpenLink(string input)
+ {
+ string link = GenerateLink(input);
+
+ if (!string.IsNullOrEmpty(link))
+ {
+ URLHelpers.OpenURL(link);
+ }
+ }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ShareX/ShareX.csproj b/ShareX/ShareX.csproj
index 077e6734b2e..166cdcad0da 100644
--- a/ShareX/ShareX.csproj
+++ b/ShareX/ShareX.csproj
@@ -207,6 +207,7 @@
+
Form