mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Fix OCR async issue
This commit is contained in:
parent
7baeb193c6
commit
c802383311
5 changed files with 31 additions and 20 deletions
|
@ -358,6 +358,8 @@ public static void InvokeSafe(this Control control, Action action)
|
|||
}
|
||||
|
||||
public static void ForceActivate(this Form form)
|
||||
{
|
||||
if (!form.IsDisposed)
|
||||
{
|
||||
if (!form.Visible)
|
||||
{
|
||||
|
@ -372,6 +374,7 @@ public static void ForceActivate(this Form form)
|
|||
form.BringToFront();
|
||||
form.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
public static int WeekOfYear(this DateTime dateTime)
|
||||
{
|
||||
|
|
|
@ -1470,7 +1470,7 @@ private void tsmiTextCapture_Click(object sender, EventArgs e)
|
|||
|
||||
try
|
||||
{
|
||||
TaskHelpers.OCRImage().RunSynchronously();
|
||||
_ = TaskHelpers.OCRImage();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1842,9 +1842,16 @@ private void tsmiTrayLastRegion_Click(object sender, EventArgs e)
|
|||
new CaptureLastRegion().Capture();
|
||||
}
|
||||
|
||||
private void tsmiTrayTextCapture_Click(object sender, EventArgs e)
|
||||
private async void tsmiTrayTextCapture_Click(object sender, EventArgs e)
|
||||
{
|
||||
TaskHelpers.OCRImage().RunSynchronously();
|
||||
try
|
||||
{
|
||||
await TaskHelpers.OCRImage();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugHelper.WriteException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiTrayToggleHotkeys_Click(object sender, EventArgs e)
|
||||
|
@ -2094,9 +2101,9 @@ private void tsmiShowQRCode_Click(object sender, EventArgs e)
|
|||
uim.ShowQRCode();
|
||||
}
|
||||
|
||||
private void tsmiOCRImage_Click(object sender, EventArgs e)
|
||||
private async void tsmiOCRImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
uim.OCRImage();
|
||||
await uim.OCRImage();
|
||||
}
|
||||
|
||||
private void tsmiCombineImages_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -134,7 +134,7 @@ public static void ExecuteJob(TaskSettings taskSettings, HotkeyType job, CLIComm
|
|||
OpenWebpageCapture(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.TextCapture:
|
||||
OCRImage(safeTaskSettings).RunSynchronously();
|
||||
_ = OCRImage(safeTaskSettings);
|
||||
break;
|
||||
case HotkeyType.AutoCapture:
|
||||
OpenAutoCapture(safeTaskSettings);
|
||||
|
@ -1144,7 +1144,7 @@ public static async Task OCRImage(string filePath, TaskSettings taskSettings = n
|
|||
}
|
||||
}
|
||||
|
||||
public static async Task OCRImage(Stream stream, string fileName, string filePath = null, TaskSettings taskSettings = null)
|
||||
private static async Task OCRImage(Stream stream, string fileName, string filePath = null, TaskSettings taskSettings = null)
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -362,9 +363,9 @@ public void ShowQRCode()
|
|||
if (IsItemSelected && SelectedItem.IsURLExist) new QRCodeForm(SelectedItem.Info.Result.URL).Show();
|
||||
}
|
||||
|
||||
public void OCRImage()
|
||||
public async Task OCRImage()
|
||||
{
|
||||
if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OCRImage(SelectedItem.Info.FilePath).RunSynchronously();
|
||||
if (IsItemSelected && SelectedItem.IsImageFile) await TaskHelpers.OCRImage(SelectedItem.Info.FilePath);
|
||||
}
|
||||
|
||||
public void CombineImages()
|
||||
|
|
|
@ -1007,9 +1007,9 @@ private bool DownloadFromURL(bool upload)
|
|||
|
||||
private void DoOCR()
|
||||
{
|
||||
if (Data != null && Info.DataType == EDataType.Image)
|
||||
if (Image != null && Info.DataType == EDataType.Image)
|
||||
{
|
||||
TaskHelpers.OCRImage(Data, Info.FileName, Info.FilePath, Info.TaskSettings).RunSynchronously();
|
||||
_ = TaskHelpers.OCRImage(Image, Info.TaskSettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue