mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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;
|
||||
}
|
||||
|
||||
var flashInfo = new NativeFunctions.FLASHWINFO();
|
||||
flashInfo.cbSize = (uint) Marshal.SizeOf<NativeFunctions.FLASHWINFO>();
|
||||
flashInfo.uCount = uint.MaxValue;
|
||||
flashInfo.dwTimeout = 0;
|
||||
flashInfo.dwFlags = NativeFunctions.FlashWindow.FLASHW_TRAY |
|
||||
NativeFunctions.FlashWindow.FLASHW_TIMERNOFG;
|
||||
flashInfo.hwnd = Process.GetCurrentProcess().MainWindowHandle;
|
||||
NativeFunctions.FlashWindowEx(ref flashInfo);
|
||||
if (!NativeFunctions.ApplicationIsActivated()) {
|
||||
var flashInfo = new NativeFunctions.FLASHWINFO();
|
||||
flashInfo.cbSize = (uint)Marshal.SizeOf<NativeFunctions.FLASHWINFO>();
|
||||
flashInfo.uCount = uint.MaxValue;
|
||||
flashInfo.dwTimeout = 0;
|
||||
flashInfo.dwFlags = NativeFunctions.FlashWindow.FLASHW_ALL |
|
||||
NativeFunctions.FlashWindow.FLASHW_TIMERNOFG;
|
||||
flashInfo.hwnd = Process.GetCurrentProcess().MainWindowHandle;
|
||||
NativeFunctions.FlashWindowEx(ref flashInfo);
|
||||
}
|
||||
|
||||
Task.Run(async () => {
|
||||
this.dalamud.Framework.Gui.Chat.Print("Duty pop: " + contentFinderCondition.Name);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
|
@ -58,6 +59,28 @@ namespace Dalamud
|
|||
|
||||
#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")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue