Skip to content

Commit

Permalink
Follow-Up: Only bring the window to the foreground when starting the …
Browse files Browse the repository at this point in the history
…loop or the window is a different one.
  • Loading branch information
kpreisser committed Aug 11, 2018
1 parent 722f4de commit 05b808e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task InitializeAsync()
{
try
{
var previousWindowToBringToForeground = IntPtr.Zero;
while (true)
{
// First, find the game processes. This will always return at least one process,
Expand All @@ -70,9 +71,13 @@ public async Task InitializeAsync()
if (processes.Count == 1)
{
// When there is only one process, we simply bring the window to the
// foreground.
// foreground (if we didn't do it already).
this.windowHandle = this.environmentInterface.FindMainWindowHandleOfProcess(processes[0]);
this.environmentInterface.BringWindowToForeground(this.windowHandle);
if (this.windowHandle != previousWindowToBringToForeground)
{
previousWindowToBringToForeground = this.windowHandle;
this.environmentInterface.BringWindowToForeground(this.windowHandle);
}

// Wait a bit so that the window can go into foreground.
await WaitSemaphoreInternalAsync(250, false);
Expand Down

0 comments on commit 05b808e

Please sign in to comment.