mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 20:24:16 +01:00
fix: only flash window if NOT in foreground
This commit is contained in:
parent
fd18ba6e8e
commit
832c5f758f
2 changed files with 33 additions and 8 deletions
|
|
@ -69,14 +69,16 @@ namespace Dalamud.Game.Network {
|
||||||
contentFinderCondition.Image = 112324;
|
contentFinderCondition.Image = 112324;
|
||||||
}
|
}
|
||||||
|
|
||||||
var flashInfo = new NativeFunctions.FLASHWINFO();
|
if (!NativeFunctions.ApplicationIsActivated()) {
|
||||||
flashInfo.cbSize = (uint) Marshal.SizeOf<NativeFunctions.FLASHWINFO>();
|
var flashInfo = new NativeFunctions.FLASHWINFO();
|
||||||
flashInfo.uCount = uint.MaxValue;
|
flashInfo.cbSize = (uint)Marshal.SizeOf<NativeFunctions.FLASHWINFO>();
|
||||||
flashInfo.dwTimeout = 0;
|
flashInfo.uCount = uint.MaxValue;
|
||||||
flashInfo.dwFlags = NativeFunctions.FlashWindow.FLASHW_TRAY |
|
flashInfo.dwTimeout = 0;
|
||||||
NativeFunctions.FlashWindow.FLASHW_TIMERNOFG;
|
flashInfo.dwFlags = NativeFunctions.FlashWindow.FLASHW_ALL |
|
||||||
flashInfo.hwnd = Process.GetCurrentProcess().MainWindowHandle;
|
NativeFunctions.FlashWindow.FLASHW_TIMERNOFG;
|
||||||
NativeFunctions.FlashWindowEx(ref flashInfo);
|
flashInfo.hwnd = Process.GetCurrentProcess().MainWindowHandle;
|
||||||
|
NativeFunctions.FlashWindowEx(ref flashInfo);
|
||||||
|
}
|
||||||
|
|
||||||
Task.Run(async () => {
|
Task.Run(async () => {
|
||||||
this.dalamud.Framework.Gui.Chat.Print("Duty pop: " + contentFinderCondition.Name);
|
this.dalamud.Framework.Gui.Chat.Print("Duty pop: " + contentFinderCondition.Name);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -58,6 +59,28 @@ namespace Dalamud
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>Returns true if the current application has focus, false otherwise</summary>
|
||||||
|
public static bool ApplicationIsActivated()
|
||||||
|
{
|
||||||
|
var activatedHandle = GetForegroundWindow();
|
||||||
|
if (activatedHandle == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return false; // No window is currently activated
|
||||||
|
}
|
||||||
|
|
||||||
|
var procId = Process.GetCurrentProcess().Id;
|
||||||
|
int activeProcId;
|
||||||
|
GetWindowThreadProcessId(activatedHandle, out activeProcId);
|
||||||
|
|
||||||
|
return activeProcId == procId;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||||
|
private static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
private static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
|
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue