Search in DOpus Config with Notepad++ Button

I often use notepad++ to search for eg script fragments in the dopus config (actually just text files). To automate I made this button to enter the query, starting notepad++, open the "search in files", entering the search term, filter, and dopus config directory and then hitting the search button (using wsh SendKeys()). You might need to adjust the waiting times (especially when waiting for notepad++ to start) to your system. Easiest would be using a multiplyer.

function OnClick(clickData)
{
	var dialog = clickData.func.Dlg;
	var query = dialog.GetString("Search query: ", "", 256, "OK|Cancel", "Search in DOpus config", DOpus.Listers(0));
	if(dialog.result == 1)
	{
		var wsh = new ActiveXObject("WScript.Shell");
		var notepadExe = DOpus.vars("programpath-notepadpp"); //or enter a hardcoded path to exe here
		var dopusData = DOpus.aliases("dopusdata").path;
		var waitTime = 50;
		DOpus.Create.Command.RunCommand(notepadExe);
		
		DOpus.Delay(waitTime * 20);
		wsh.SendKeys("^+F"); 		//Ctrl + Shift + F (Find in files)
		DOpus.Delay(waitTime * 5);
		wsh.SendKeys("^A");			//Ctrl + A (Select all)
		wsh.SendKeys(query);		//Type in query
		DOpus.Delay(waitTime);
		wsh.SendKeys("{TAB}");		//Tab to "replace with"
		wsh.SendKeys("^A");			//Ctrl + A (Select all)
		wsh.SendKeys("{BACKSPACE}");//Delete "replace with"
		DOpus.Delay(waitTime);
		wsh.SendKeys("{TAB}");
		wsh.SendKeys("*.*");		//Filter
		DOpus.Delay(waitTime);
		wsh.SendKeys("{TAB}");
		wsh.SendKeys(dopusData); 	//Enter dopus dir
		DOpus.Delay(waitTime * 5);
		wsh.SendKeys("{ENTER}");	//Search
	}
}

And directly the button code

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Search in DOpus config</label>
	<icon1>#searchfield</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData)</instruction>
		<instruction>{</instruction>
		<instruction>	var dialog = clickData.func.Dlg;</instruction>
		<instruction>	var query = dialog.GetString(&quot;Search query: &quot;, &quot;&quot;, 256, &quot;OK|Cancel&quot;, &quot;Search in DOpus config&quot;, DOpus.Listers(0));</instruction>
		<instruction>	if(dialog.result == 1)</instruction>
		<instruction>	{</instruction>
		<instruction>		var wsh = new ActiveXObject(&quot;WScript.Shell&quot;);</instruction>
		<instruction>		var notepadExe = DOpus.vars(&quot;programpath-notepadpp&quot;); //or enter a hardcoded path to exe here</instruction>
		<instruction>		var dopusData = DOpus.aliases(&quot;dopusdata&quot;).path;</instruction>
		<instruction>		var waitTime = 50;</instruction>
		<instruction>		DOpus.Create.Command.RunCommand(notepadExe);</instruction>
		<instruction>		</instruction>
		<instruction>		DOpus.Delay(waitTime * 20);</instruction>
		<instruction>		wsh.SendKeys(&quot;^+F&quot;); 		//Ctrl + Shift + F (Find in files)</instruction>
		<instruction>		DOpus.Delay(waitTime * 5);</instruction>
		<instruction>		wsh.SendKeys(&quot;^A&quot;);			//Ctrl + A (Select all)</instruction>
		<instruction>		wsh.SendKeys(query);		//Type in query</instruction>
		<instruction>		DOpus.Delay(waitTime);</instruction>
		<instruction>		wsh.SendKeys(&quot;{TAB}&quot;);		//Tab to &quot;replace with&quot;</instruction>
		<instruction>		wsh.SendKeys(&quot;^A&quot;);			//Ctrl + A (Select all)</instruction>
		<instruction>		wsh.SendKeys(&quot;{BACKSPACE}&quot;);//Delete &quot;replace with&quot;</instruction>
		<instruction>		DOpus.Delay(waitTime);</instruction>
		<instruction>		wsh.SendKeys(&quot;{TAB}&quot;);</instruction>
		<instruction>		wsh.SendKeys(&quot;*.*&quot;);		//Filter</instruction>
		<instruction>		DOpus.Delay(waitTime);</instruction>
		<instruction>		wsh.SendKeys(&quot;{TAB}&quot;);</instruction>
		<instruction>		wsh.SendKeys(dopusData); 	//Enter dopus dir</instruction>
		<instruction>		DOpus.Delay(waitTime * 5);</instruction>
		<instruction>		wsh.SendKeys(&quot;{ENTER}&quot;);	//Search</instruction>
		<instruction>	}</instruction>
		<instruction>}</instruction>
	</function>
</button>

Detailed Installation Instructions
Or Copy button code, customize menu bar, context menu => paste and youve got the button there.