Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm must solve one problem here in my work, they need a several of hotkeys and each hotkey must do one specific task. This hotkeys must be active even when the application was without focus.
I was able to register a hotkey, this is working, even without the focus on the application.
But now my problem is, one of the hotkeys must process some things on the database, make some math and than paste the result wherever the focus is, like forcing a ctrl+c and ctrl+v.
It's easy the database and math part, but how do I put something in memory and force a past wherever the is focus ?
Any ideas?

Tks a lot
Ray

What I have tried:

I don't try anything eat, I have no idea how to start this part of the problem.
Posted
Updated 23-Jul-18 4:46am

Hi,
I solve the problem using this:

using System.Windows.Forms;
// Clear the Windows ClipBoard
Clipboard.Clear();
// Input text on the Windows ClipBoard
Clipboard.SetText(text);
// Paste text wherever the focus were
SendKeys.Send("^v");


Tks
 
Share this answer
 
 
Share this answer
 
Comments
Raimundo B. C. Neto 17-Jul-18 11:29am    
Hi, thanks for the answer. This post has a way to register a global hotkey, this I have already done. My problem now is this:
The user is in another application, anyone, and press like ctrl+shift+1, I make some processing and put a result let say in a string, and here come the question, how do I force a paste in this other application, that it's where the focus is?
tks
Ziee-M 18-Jul-18 3:17am    
If i did understand, you have either to make your diffrent apps communicate based on hotkeys events, or implement Hotkeys in your target App. the later is certainly the easiest.
What are the technologies you use (Winforms, WPF or other)?
Raimundo B. C. Neto 18-Jul-18 9:25am    
I'll try to explain better.
I must make two apps communicate, but one is a third part app and I can't modify it or access direct the database and there isn't any webservice or nothing like it to communicate direct.
So when the users must input some information they do ctrl+c and ctrl+v from one app to the other. But this involves change windows, select the information in the right fild, ctrl+c, change windows again, put the focus in the right field and than do the ctrl+v. Too many steps.
My idea was if I could put several global hotkeys on my app, one to each field, and when the users need they could put the focus on the destination field and press the hotkey, the hotkey would copy the information from the right field and past wherever the focus were.
The global hotkeys I was able to do it, now I must do the copy/paste part.
Do you go it?
Ziee-M 18-Jul-18 9:44am    
Yes, i think i got the idea.
Here is an idea how to achive this, in your producer app, you fill a file when hotkey entered.
In the consumer app, using a stopwatch, you can check if that file have been updated and show the data you need in it.
You can also use a thread in your consumer app, but it will conume much more ressources.
Raimundo B. C. Neto 18-Jul-18 10:23am    
Ok, I'll study this option, tks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900