<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[C#] Find Text In File]]></title><description><![CDATA[<p dir="auto">Is there a way to use the find window (Ctrl+F) with a specified string? I know you can use the Find in Files dialog with NPPM_LAUNCHFINDINFILESDLG but can you use the regular find? I tried sending the shortcut but couldn’t get it to work and also tried using InputSimulator but that needs the WindowsInput.dll file to be loaded to notepad++ to work (would appreciate help with that as well, hope this is enough of a notepad++ question for this forum)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22285/c-find-text-in-file</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 01:29:59 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22285.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Dec 2021 12:36:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 18:22:59 GMT]]></title><description><![CDATA[<p dir="auto">@sover-david said in <a href="/post/72196">[C#] Find Text In File</a>:</p>
<blockquote>
<p dir="auto">I know you can use the Find in Files dialog with NPPM_LAUNCHFINDINFILESDLG but can you use the regular find?</p>
</blockquote>
<p dir="auto"><a href="https://npp-user-manual.org/docs/plugin-communication/#nppm-menucommand" rel="nofollow ugc">NPPM_MENUCOMMAND</a> will run any builtin menu with lParam providing the <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/menuCmdID.h#L179" rel="nofollow ugc">command ID</a>: in this case, IDM_SEARCH_FIND to run <strong>Search &gt; Find</strong> to launch the FIND dialog.</p>
<pre><code>// open the FIND dialog
SendMessage( npp_hWnd, NPPM_MENUCOMMAND, 0, IDM_SEARCH_FIND);
</code></pre>
<p dir="auto">Once inside the dialog, you should be able to search controls.  If I understand things correctly, <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h#L22" rel="nofollow ugc">FindReplaceDlg_rc.h</a> defines the control ID’s for each of the entries and buttons: in this case, I think you want IDFINDWHAT for the “Find What” text box.</p>
<p dir="auto">I am starting to get out of my element, because for Win32 stuff, I am usually using a <a href="https://metacpan.org/pod/Win32::GuiTest" rel="nofollow ugc">wrapper libary in Perl</a> rather than truly programming in Win32 API code, so it sometimes provides wrapper functions that don’t map directly to Win32 API calls.  But I <em>think</em> you would want to get the hWnd for the FIND dialog and maybe the edit control, then use WM_SETTEXT to the IDFINDWHAT entry:</p>
<pre><code>find_dlg_hWnd = GetActiveWindow(); // or GetForegroundWindow();     // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getactivewindow
find_box_hWnd = GetDlgItem( find_dlg_hWnd , IDFINDWHAT );   // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdlgitem
SendMessage( find_box_hWnd, WM_SETTEXT, 0, "search text");
</code></pre>
<p dir="auto">or maybe instead of getting the extra hwnd, just</p>
<pre><code>SetDlgItemText( find_dlg_hWnd, IDFINDWHAT, "search text"); // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtexta
</code></pre>
<p dir="auto">Then somehow, you would have to press the “FIND NEXT” button (but I wasn’t able to find the raw API equivalent of Perl’s <a href="https://metacpan.org/pod/Win32::GuiTest#PushChildButton" rel="nofollow ugc">Win32::GuiTest::PushChildButton</a> or <a href="https://metacpan.org/pod/Win32::GuiTest#PushChildById" rel="nofollow ugc">PushChildById</a>, so I cannot link you to the right API command for pusing the button, sorry).</p>
<p dir="auto">But if the SendText/SendWait is working for you, that’s probably sufficient.</p>
<p dir="auto">For other reference, the NPP User Manual’s <a href="https://npp-user-manual.org/docs/searching/#searching-actions-when-recorded-as-macros" rel="nofollow ugc">Searching Actions When Recorded As Macros</a> seem to be using the control IDs as the parameters of the macro commands, so that might give you insight into the control IDs needed for other actions in the FIND family of dialogs … though I’m not sure they always line up with teh <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h" rel="nofollow ugc">FindReplaceDlg_rc.h</a> constants, so I’m not sure.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72204</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72204</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 18 Dec 2021 18:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 16:34:19 GMT]]></title><description><![CDATA[<p dir="auto">@sover-david said in <a href="/post/72202">[C#] Find Text In File</a>:</p>
<blockquote>
<p dir="auto">I managed to get SendKeys.SendWait to work by hiding a dialog that was currently in focus, but that still didn’t work for Ctrl+F so I made it set the text I wanted to find to the clipboard and press Alt+S+Enter Ctrl+V Enter Escape.</p>
</blockquote>
<p dir="auto">Sounds a bit convoluted, but hey, whatever works! :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72203</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72203</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 18 Dec 2021 16:34:19 GMT</pubDate></item><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 16:09:24 GMT]]></title><description><![CDATA[<p dir="auto">Alright, I managed to get SendKeys.SendWait to work by hiding a dialog that was currently in focus, but that still didn’t work for Ctrl+F so I made it set the text I wanted to find to the clipboard and press Alt+S+Enter Ctrl+V Enter Escape.</p>
<p dir="auto">Here’s the code:</p>
<pre><code>Clipboard.SetText("foo");
HideDialog();
SendKeys.SendWait("%(S{ENTER})^(V){ENTER}{ESCAPE}");
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/72202</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72202</guid><dc:creator><![CDATA[Sover the]]></dc:creator><pubDate>Sat, 18 Dec 2021 16:09:24 GMT</pubDate></item><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 13:56:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> said in <a href="/post/72197">[C#] Find Text In File</a>:</p>
<blockquote>
<p dir="auto">It’s all straight windows api code</p>
</blockquote>
<p dir="auto">I did some digging and perhaps <a href="https://community.notepad-plus-plus.org/topic/20312/how-to-start-a-search-automatically">THIS THREAD</a> gives some idea of what’s involved.<br />
For sure read the whole thing, but <a href="https://community.notepad-plus-plus.org/post/59785">THIS POSTING</a> seems to be where the meat of the coding starts.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72201</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72201</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 18 Dec 2021 13:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 13:39:12 GMT]]></title><description><![CDATA[<p dir="auto">@sover-david said in <a href="/post/72196">[C#] Find Text In File</a>:</p>
<blockquote>
<p dir="auto">also tried using InputSimulator but that needs the WindowsInput.dll file to be loaded to notepad++ to work (would appreciate help with that as well, hope this is enough of a notepad++ question for this forum)</p>
</blockquote>
<p dir="auto">Maybe I spoke too soon earlier about it being enough of a N++ question for this forum.  I thought you mainly meant the first part of your question.</p>
<p dir="auto">But if you mean specifically the “InputSimulator” and “WindowsInput.dll” stuff then I’d say no, it isn’t, and there are much better places to ask questions about that stuff.  But of course because I don’t care about that stuff, I can’t point you to better places.</p>
<p dir="auto">Discussing keystroke senders (e.g. AutoHotKey) is fair game here, when illustrating a technique you’ve done, say, but asking for generic help with such a thing is not.  I hope you understand the difference, and know what is appropriate and isn’t.</p>
<p dir="auto">The reason for limiting discussion here is:</p>
<ul>
<li>
<p dir="auto">we’re all here to read about Notepad++ (or we’d be somewhere else); non-N++ discussion wastes participants time</p>
</li>
<li>
<p dir="auto">the people here are N++ “experts” and aren’t experts on other things (well, of course we are, but everyone’s an expert in different areas), and you aren’t likely to get responses on non-N++ generic questions anyway</p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/72200</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72200</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 18 Dec 2021 13:39:12 GMT</pubDate></item><item><title><![CDATA[Reply to [C#] Find Text In File on Sat, 18 Dec 2021 13:12:14 GMT]]></title><description><![CDATA[<p dir="auto">@sover-david said in <a href="/post/72196">[C#] Find Text In File</a>:</p>
<blockquote>
<p dir="auto">hope this is enough of a notepad++ question for this forum</p>
</blockquote>
<p dir="auto">It is. :-)</p>
<blockquote>
<p dir="auto">Is there a way to use the find window (Ctrl+F)</p>
</blockquote>
<p dir="auto">There is not a “built in” (read: easy) way to manipulate the <em>Find</em> window via a plugin.  However, with a bit of work, you could manipulate the windows controls on that window via code.  It’s all straight windows api code, though – gets a bit tedious.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/72197</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/72197</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 18 Dec 2021 13:12:14 GMT</pubDate></item></channel></rss>