Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom search tab in Windows start menu search with C#

Tags:

I am interested to know how can I do the same thing that the apllication listed below does: Start Menu Calculator

I want to know how can I create an custom tab in Start Menu Search and then handle it with my WPF application. It should only be enabled until my application is running.( Just like what The calculator does )

I read something about windows API Code Pack and I downloaded it but I don't know how can I use it. I searched through it but I didn't find anything.( If you know how I could do this using with Windows API Code Pack, please write an example that explains how to do it in C#)

like image 854
mahdavipanah Avatar asked Jun 14 '12 14:06

mahdavipanah


People also ask

How do I add a search box to Windows 10 Start menu?

Press and hold (or right-click) the taskbar and select Taskbar settings. Select Taskbar items to expand the section, then toggle the Search switch to On.

How do I search for something in the Start menu?

Instead, as Into Windows points out, just hit the Windows key and start typing. That will open up the Start menu and also search whatever you type in--no need to take your hands off your keyboard and you can remove the search box from the taskbar.

How do I add programs to the Windows search bar?

Navigate to C:\ProgramData\Microsoft\Windows\Start Menu. Once you get there,you'll be able to view your program list on your start menu. To add a program shortcut to the start menu,Navigate to your program files folder. Right click on a program icon that ends with .exe, copy and paste it to the "StartMenu" folder.

What does the search bar on the Start menu allow you to search for?

The Start menu Search is located on the left panel of the Start menu in the bottom. Typing into this search box will yield results each key stroke to launch applications or files quicker. The search not only returns and launches applications but also searches for documents, pictures, videos, and other file types.


2 Answers

  • The main exe "Start Menu Calculator.exe" installs a windows hook (using SetWindowsHookEx) into explorer.exe. The hook is implemented as usual in SBLib.dll which is then injected into Windows Explorer's memory space.

  • This hook searches for window handles belonging to the search box. See a discussion around this here: How do I get a "handle" on the Windows Search textbox? and probably sub classes the search box windows (if you kill the "Start Menu Calculator.exe" process abruptly, it crashes Windows Explorer too... which kinda confirms this)

  • It then reacts to key presses, and I suppose it butchers up the result window. In the hierarchies of Windows, I think it's a Window named "Desktop Search Open View", you can get to it with SPY++ under "Start Menu", aside the windows mentioned in the msdn forum above.

So, no nice API behind this nice application. Massive hacks instead :-)

I think however, some level of integration is possible, using documented behavior, with the search box. I have not dug further, but there is the notion of federated search in Windows (Windows 7 Federated Search). I don't see if this would be capable of reacting instantaneously to what the user types in though...

As a side note, if you're also looking for a way to run javascript code from C#, there is a question here on SO that says it all: parse and execute JS by C#

like image 185
Simon Mourier Avatar answered Oct 20 '22 13:10

Simon Mourier


When making Start Menu Calculator I initially tried to use federated search and Managed (.NET) code however you can't integrate into the start menu, only the shell search (for web service based search which lets you return custom results based on a search string). The problem is that the federated search is structured such that all the search data is pre-indexed so for the calculator to work I would have had to pre index every possible calculation! The reason it all works this way is to make sure that clicking the start menu is always fast and responsive (you don't want a web service call everytime you press start in the shell).

I ended up hiring someone to write a native windows app that places a IE control into the Start menu search area and passes the searched text in with the source. All the visual stuff is just css made to look like the start menu rendering and the calculations handled in javascript.

So yes, a bit of a hack but it seems to work and I havent had/heard of any crashing issues so far.

like image 33
David Avatar answered Oct 20 '22 12:10

David