forked from aly/qstbak
31 lines
595 B
C#
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;
|
|
}
|
|
}
|