I have a windows desktop application in c# (WPF), which is basically an issue managing application for a call center. It manages (adds, edits, deletes,...) customer issues (records in database), where each issue has numerous fields (textboxes, textareas, checkboxes,...) While the issue is generated, a user often copies/pastes data from other resources to this and other applications (excel, notepad, browser...), and has a windows clipboard full of valuable data.
The problem i don't know how to solve is: A user selects a random text in any textfield (textbox for example) in this program, and copies the data. but this data can't be copied to the clasic windows clipboard
Clipboard.SetText(Textbox1.Text);
because clipboard already has a valuable data, that can't be lost. So i'd like to create a second clipboard which listens to all keyboard input. And whenever a certain combination of keys is pressed it reads the selected text (only text is needed), from any application (notepad, excel, my program,...). Similarly with another combination of keys it pastes that copied text to any application (notepad, excel,..)
Windows already has that functionaliy with the shortcuts CTRL+C and CTRL+V, which work in any application that doesn't override those shortcuts. I'd like to the same for my custom clipboard application/service, with different shortcuts. But i don't know how to get and paste the data to any textfield in any windows application. In a nutshell, i'd need something like:
string clipboardData;
public void OnSpecialCopyShortcutPressed() {
clipboardData = SelectedTextAnywhereInWindowsOrAnyWindowsApp.Text;
}
public void OnSpecialPasteShortcutPressed() {
focusedTextFieldAnywhereInWindowsOrAnyWindowsApp.Text = clipboardData;
}
Basicaly i'd like to have two windows clipboards.
Any pointers would be great. Thank you.
--- edit ---
found the solution for hooking up to the keys pressed here global keyboard hook Still looking for a way to "hook up" to active apps and selected text for copying and focused controls for pasting copied text.