1
0
Fork 0
forked from aly/qstbak
qstbak/Questionable/Questionable.Windows.Utils/ThrottledClipboard.cs
2026-08-17 20:29:32 +10:00

31 lines
595 B
C#

using System;
using Dalamud.Bindings.ImGui;
namespace Questionable.Windows.Utils;
internal static class ThrottledClipboard
{
private const long RefreshIntervalMs = 500L;
private static long _nextReadAtMs;
private static string _cachedText = string.Empty;
public static string GetText()
{
long tickCount = Environment.TickCount64;
if (tickCount >= _nextReadAtMs)
{
_nextReadAtMs = tickCount + 500;
try
{
_cachedText = ImGui.GetClipboardText()?.Trim() ?? string.Empty;
}
catch (Exception)
{
_cachedText = string.Empty;
}
}
return _cachedText;
}
}