Taskbar Search Application - c#

I have program that is used by 4000 users to search a large database based on a large number of search scenarios. The current application is a System Tray application and when the user clicks application icon, it opens a winform window and allows the user to enter some text and then returns the search results. I’ve been asked by my CIO if I can just put a textbox and button in the task bars so it always there for the user. I’ve googled everything and can’t find anything on this. I have Window 7 and Vista OS’s some 32 bit and some 64 bit. Does anyone know of an example on how to do this?

Take a look at this CodeProject article that does something similar.
http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx
Also take a look at a similar question asked here on SO.
And also there's an MSDN article posted in the question. See the references section in the article for more information.

You can register your own Protocol Handler. Then you can add the address toolbar to the taskbar. Then a user can just type "search:steak".

Related

c# code to show miniature live view of another window

On Win11, when I use Alt-Tab to cycle through the windows on my machine, I can see live miniature versions of the active windows, including video on YouTube. Does anyone know a way to do this in c#.
Ultimately, I want to have a page that shows a few live miniature windows that the user can click on one to go to that program. It is important to be able to see changes, e.g. flashing alerts, on the miniatures, so ideally the update rate for each should be <200ms
I've tried searching online for solutions, but I've not found a way to phrase the problem such that I get any clues where to even start

How to read and change text in a TextBox control in another process in a .NET application?

I need the following for a specific corporate application that we use in our office. The goal is to create something similar to what password managers do with forms in a web browser -- fill out the login credentials automatically. I need it only for this specific application.
When the application loads, it shows a login window:
My goal is to read Corp Code, Location Code and User Name & fill out the Password accordingly from my application that I'm writing.
I do not have the source code for the corporate application in question. I know that it is a .NET 4.0 process:
From Windows Spy++ I can see what those text boxes are:
So they have this WindowsForms10.EDIT.app.* class name, where * I believe can be changed from build to build:
My first instinct was to use native EnumWindows API with conjunction with GetClassName and GetWindowText to locate those text boxes and get their text, but the issue is telling them apart.
So I was hoping that their Control ID properties could be used for that:
but unfortunately their Control ID value seems to change every time the application runs.
So my only hope in this case is to identify these TextBox controls by their name, natively like .NET does:
Is there a way to do it from another .NET process?
I do not believe it is possible to expose the .NET names of the textboxes that way. You are going down the correct path with p/invoking the EnumWindows, GetClassName, etc.
You might have luck checking the Z-Order of the child windows, which would be the effective tab order, which is probably consistent for each run.

How can I make a menu-like form stay on the screen, on top of all other apps?

I want to make a menubar like window taskbar in C# but I'm wondering how can I make the form stay on the top of the screen and other program will not taped over it just like the window taskbar and when the mouse hover on a icon it will show a form like this:
I have made it like this:
And This is what I want
Windows has a facility for this, allowing you to basically create pseudo-taskbars that dock to the side of the screen and are always visible. It was used by the Office team (possibly publically documented for the Office team?) a long, long time ago to create a desktop toolbar.
Anyway, they are called Application Desktop Toolbars (or "AppBars"), and the documentation is here. To register one, you call the SHAppBarMessage function with the ABM_NEW message. Complete sample code is available in the linked documentation, unfortunately it is in C++.
To use this from a C# application, you will have to P/Invoke. As far as I know, it is not wrapped by the .NET Framework anywhere, probably because it never gets used by anyone anymore. This CodeProject article appears to have the necessary P/Invoke definitions written out. I can't vouch for their correctness, but armed with the documentation and that as an example, you should be able to cook up a working demo.
There is another CodeProject article here, written by Arik Poznanski as part of a series on using shell features from C#. It looks much more thorough, probably more than you need.
Set the property Form.TopMost unless you have other programs creating topmost windows. Doh!

Selecting an item from pop-up menu

I'm trying to make an application that will test some features of an existing app and I wanted it not to be window-size dependent and not to require focusing the window or etc.
I've already figured out how to get window handles for different controls in the tested app so I can click buttons, enter text to textboxes etc. with Send/Post Message but still got a few unsolved problems.
The first is selecting an item from a pop-up menu that can be triggered by button click (TAdvGlowMenuButton class) or right click somewhere- I can't even see any messages related to it in Spy++ so I have no idea how to do it, is it possible to select an item by name? as I don't have it's id
The second thing is clicking next to something, for example 10 pixels to the right of a button.
I have the button handle so I can get it's size and it's parent but I still don't know how to get it's position inside the parent - any ideas?:)
And also a quick one but I don't believe it is possible - can I somehow get position of a label in the tested app? I can't even see it in Spy++ .
I hope you can help me to find it out ;)
Edit: I forgot about the most important thing:P , I'd like to achieve it with Send/Post Message if only it is possible.
My recommendation would be to abandon the message sending/posting model altogether and instead use UI Automation. Automated testing tools is exactly what the UI Automation APIs were designed for, and they are much more capable than SendMessage/PostMessage.
Yes, I realize that this is exactly the opposite of the answer you were looking for. But you will have no end of trouble getting messages to do what you want. A fair number of them rely on the application having the focus, and it is completely reasonable for your code to make this assumption when you receive e.g. a WM_KEYDOWN message. A testing tool should not flag that as a bug.
I notice you've tagged this question with the C# and .NET tags. In that case, you may be interested to learn that the UI Automation APIs have been wrapped in the .NET Framework.

Custom search tab in Windows start menu search with C#

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#)
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#
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.

Categories

Resources