Check is window active

This commit is contained in:
Jaex 2024-01-14 17:40:57 +03:00
parent e0e58b9322
commit 16b12b8d23
2 changed files with 6 additions and 14 deletions

View File

@ -28,7 +28,6 @@ using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace ShareX.HelpersLib
@ -290,16 +289,6 @@ namespace ShareX.HelpersLib
return windowRect;
}
public static void ActivateWindowRepeat(IntPtr handle, int count)
{
for (int i = 0; GetForegroundWindow() != handle && i < count; i++)
{
BringWindowToTop(handle);
Thread.Sleep(1);
Application.DoEvents();
}
}
public static Rectangle GetTaskbarRectangle()
{
APPBARDATA abd = APPBARDATA.NewAPPBARDATA();

View File

@ -51,11 +51,14 @@ namespace ShareX
if (windowInfo.IsMinimized)
{
windowInfo.Restore();
Thread.Sleep(250);
}
windowInfo.Activate();
Thread.Sleep(250);
if (!windowInfo.IsActive)
{
windowInfo.Activate();
Thread.Sleep(100);
}
TaskMetadata metadata = new TaskMetadata();
metadata.UpdateInfo(windowInfo);