Skip to content

Commit

Permalink
Check is window active
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaex committed Jan 14, 2024
1 parent e0e58b9 commit 16b12b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
11 changes: 0 additions & 11 deletions ShareX.HelpersLib/Native/NativeMethods_Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace ShareX.HelpersLib
Expand Down Expand Up @@ -290,16 +289,6 @@ public static Rectangle MaximizedWindowFix(IntPtr handle, Rectangle windowRect)
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();
Expand Down
9 changes: 6 additions & 3 deletions ShareX/CaptureHelpers/CaptureWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ protected override TaskMetadata Execute(TaskSettings taskSettings)
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);
Expand Down

0 comments on commit 16b12b8

Please sign in to comment.