This only sometimes didn't work, and never while debugged

This commit is contained in:
Mike Griese
2025-06-19 08:59:32 -05:00
parent ce150322ed
commit 68461ab553
3 changed files with 7 additions and 13 deletions

View File

@@ -298,18 +298,12 @@ public sealed partial class MainWindow : WindowEx,
private void HideWindow()
{
// now, use EnumWindows to find the first HWND that's not us, and set it as the foreground window
// First, use EnumWindows to find the first HWND that's not us, and set it as the foreground window
PInvoke.EnumWindows(
(hwnd, lParam) =>
{
if (hwnd != _hwnd && PInvoke.IsWindowVisible(hwnd))
{
// // and make sure the HWND's client area is not empty
// if (PInvoke.GetClientRect(hwnd, out var rect) && rect.Width <= 1 && rect.Height <= 1)
// {
// return true; // continue enumerating
// }
// and make sure it's not a tool window
var exStyle = (WINDOW_EX_STYLE)PInvoke.GetWindowLong(hwnd, WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE);
@@ -326,7 +320,7 @@ public sealed partial class MainWindow : WindowEx,
},
IntPtr.Zero);
// Hide our window
// THEN, hide our window
// Instead of hiding the window, cloak it from DWM
// This will make it invisible to the user, such that we can show it again

View File

@@ -7,6 +7,7 @@ using Microsoft.CmdPal.Common.Messages;
using Microsoft.CmdPal.Ext.ClipboardHistory.Helpers;
using Microsoft.CmdPal.Ext.ClipboardHistory.Models;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.ApplicationModel.DataTransfer;
namespace Microsoft.CmdPal.Ext.ClipboardHistory.Commands;
@@ -20,7 +21,7 @@ internal sealed partial class PasteCommand : InvokableCommand
_clipboardItem = clipboardItem;
_clipboardFormat = clipboardFormat;
Name = "Paste";
Icon = new("\xE8C8"); // Copy icon
Icon = new("\uE77F"); // Paste icon
}
private void HideWindow()
@@ -51,7 +52,7 @@ internal sealed partial class PasteCommand : InvokableCommand
ClipboardHelper.SendPasteKeyCombination();
// Clipboard.DeleteItemFromHistory(_clipboardItem.Item);
Clipboard.DeleteItemFromHistory(_clipboardItem.Item);
return CommandResult.ShowToast("Pasting");
}
}

View File

@@ -59,12 +59,11 @@ internal static class ClipboardHelper
output.SetText(text);
try
{
// Clipboard.SetContentWithOptions(output, null);
ClipboardThreadQueue.EnqueueTask(() =>
{
Clipboard.SetContent(output);
// Flush();
Flush();
ExtensionHost.LogMessage(new LogMessage() { Message = "Copied text to clipboard" });
});
}
@@ -88,7 +87,7 @@ internal static class ClipboardHelper
{
try
{
Task.Run(Clipboard.Flush).Wait();
Clipboard.Flush();
return;
}
catch (Exception ex)