I'm trying to write a dictionay application on C#. There is a scenarios that user selects a text and press a hot-key, I want to pop-up a quick windows that display the search result of the selected word (just like Lingoes does)
How would I do it in C#?
Thanks in advance
Start with Google this:
hooks, global hotkeys (for monitoring global keyboard and mouse events)
WinAPI (to do such tricks as grab any selected text)
I've written program you're talking about. You can check the code here - IDictionary.
Regards
Related
We need to implement a universal autocomplete for users at our company. Basically when someone starts with # and then types a name, we want to help them with autocomplete options (some sort of list showing).
This needs to work in any application in windows.
The plan is capture all keypresses, look for the # character, and if they have typed that start helping them with the autocomplete. If they select an option then we SendKeys the rest of the name down to the current cursor location, thereby finishing the name for them.
We have the keypress part working, but we aren't sure how to display the autocomplete feature. How can we implement a UI for this with the Win32 API?
Edit controls have the IAutoComplete and you can also use UWP TextBox and AutoSuggestBox.
In BluePrism it is possible to spy buttons, fields etc. of any windows application and then click those buttons automatically. For example, if you look at the screenshot you can see the attributes of the calculator's button "1" as spied in the Win32-mode (there are also HTML-, Accessibility-, Region- and UI Automation-modes) by which BluePrism will be able to identify and click the according button. Furthermore, BluePrim is compatible with C# and I wonder whether (and how) I could also get those attributes via C# instead or at least use the spied attributes as can be seen on the screenshot to press the same button with C# instead?
EDIT:
It would be highly appreciated if someone could provide the C# code for pressing the calculator's button "1" to get me started (I'm a C# newbie :-) Thanks!
You do not need C# for that, you can just use a Reader stage and action Get AA Attribute or Get Window Attribute.
EDIT:
But if you really want to do it using .NET only, have a look at UI Automation or Active Accessibility Automation (older one)
This seems like a nice example.
You will also find a tool called Inspect.exe very handy to spy elements without using BP. This
You can use the Application Model that you just spied, put it in a navigate stage in your object, then select Click Mouse Centre as the action. This will result in the button you have spied being clicked. Generally, to use Sendkeys is with C# syntax, i.e. use the root element (root element and top of list in Application Modeller tree) and select Global SendKeys as the action inside a navigate stage. In the Text input field you can enter your C# sendkey code, like for example for Ctrl + Alt + Delete use: "^%{DELETE}". I think this is what you may be looking for? Otherwise, if I understand correctly, you might be looking to use a C# code-stage inside BP to pass sendkeys to an application attached to a BP process, which would possibly involve referencing each and every attribute of the host application in C# and then using (for example) the C# Enum properties of each keyboard key, etc... this would be a massively redundant exercise since BP already provides the functionality inside the navigate stage as explained above.
I watnt o create a tutorial/guide inside in my application, creating a "demonstration". For this purpose, I need to capture the mouse of the computer, and to be able to move it and click with it.
I want it to feel like if somebody else were there controling your computer. This will be completed with a video of someone, to make you feel like this someone is doing it live in that moment.
Thank you in advance!!!
There isn't WPF solution. You have to use P/Invoke.
To disable keyboard/mouse use BlockInput API (as far as I understand, you don't want user to break up your "demo").
To simulate user input, use SendInput API.
SendInput at pinvoke.net: http://www.pinvoke.net/default.aspx/user32.sendinput
Another option is to use third-party simulators, like this.
I am trying to create a way or inserting text anywhere on the system in Windows, much like the clipboard works. For example, pressing ctrl+shift+1 would 'paste' text set in my application into where the user is currently pointing the cursor.
For example, if my application sets it to be 'local.network' and the user presses ctrl+shift+1 in their browser address bar, it would paste in 'local.network'. I then want to have different values set, depending on what number the user presses. Is this possible or can I not create a system wide function like this?
What you're looking for is how to register a hotkey.
Register more than one hotkey with RegisterHotKey
Set global hotkeys using C#
in response to your followup comment, sorry, I though the question was more about the capturing the key press event. If you need to paste text to a window that you don't own, then this question would be a near duplicate. That question uses WM_SETTEXT but you can easily use WM_PASTE instead.
What I mean is how can I get text from another running active window. For example I have a program let's say word or msn. I am chatting with someone while my own program is running in the tray. I want to set a key let's say right click and ctrl to open up my program and get the word I clicked on.
I am using C#.
I direct you to my answer to the question Unified way to scrape HTML from any type of browser process
The answer links to an article on Coding the Wheel which details how to access text in other windows via system dll hooks. That should have what you require.
you could copy the word and then get the word out of the clip board in your application... otherwise your talking API's for any application you might was to get a word from.