Also search for Notepad windows with changes.

Fixes #3.
This commit is contained in:
Yaakov 2020-05-21 17:38:01 +10:00
parent 6c43dae404
commit 2d71319974

View file

@ -84,10 +84,29 @@ namespace Microsoft.Extensions.Logging
static void WriteToNotepad(string message)
{
IntPtr hwnd = NativeMethods.FindWindow(null, "Untitled - Notepad");
IntPtr hwnd = FindNotepadWindow();
IntPtr edit = NativeMethods.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null);
NativeMethods.SendMessage(edit, NativeMethods.EM_REPLACESEL, (IntPtr)1, message);
}
static IntPtr FindNotepadWindow()
{
IntPtr hwnd;
hwnd = NativeMethods.FindWindow(null, "Untitled - Notepad");
if (hwnd != IntPtr.Zero)
{
return hwnd;
}
hwnd = NativeMethods.FindWindow(null, "*Untitled - Notepad");
if (hwnd != IntPtr.Zero)
{
return hwnd;
}
return IntPtr.Zero;
}
}
static class NativeMethods