I am trying to build a C# background app that would hook keyboard keystrokes (e.g. CAPS + (A/B/C/....)) to act as a Copy to many different clipboard.
First of all, I looked for a Windows Method that would act like a CTRL+V does : Directly paste a full string. I Also tried the SendInputs to "paste", wrong idea it took too long to execute. As I did not find any goods, I decided to use the Windows Clipboard.
Scenario is (when I do CAPS+A)
- Cache the content of Clipboard to retrieve it later
- Simulate a CTRL+C
- Get content of Clipboard and set it for a variable corresponding to 'A' key
- Set the Clipboard to the default cached value.
This works well when I am on Notepad. But I get the exception CLIPBRD_E_CANT_OPEN at step 3 when the CTRL+C is executed on another application (for exactly 5 seconds, the Clipboard is not accessible by my application)
My questions: - Is there a way to send Windows a signal for it to "Paste" some given text, acting like a CTRL+V without using the Windows Clipboard ? - Is there a way to force the Clipboard to get back to my application within 5 seconds ? - Am i missing a smarter scenario ?
Thanks!