mirror of
https://github.com/yaakov-h/Notepad.Extensions.Logging.git
synced 2024-11-25 20:44:48 +00:00
parent
37d3f8176b
commit
70531ac442
1 changed files with 20 additions and 1 deletions
|
@ -84,10 +84,29 @@ namespace Microsoft.Extensions.Logging
|
||||||
|
|
||||||
static void WriteToNotepad(string message)
|
static void WriteToNotepad(string message)
|
||||||
{
|
{
|
||||||
IntPtr hwnd = NativeMethods.FindWindow(null, "Untitled - Notepad");
|
IntPtr hwnd = FindNotepadWindow();
|
||||||
IntPtr edit = NativeMethods.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null);
|
IntPtr edit = NativeMethods.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null);
|
||||||
NativeMethods.SendMessage(edit, NativeMethods.EM_REPLACESEL, (IntPtr)1, message);
|
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
|
static class NativeMethods
|
||||||
|
|
Loading…
Reference in a new issue