I am trying to port my all in one clipboard solution from C# to Phrase Express which allows one keyboard key to act as a copy, and paste tool; Copy if text is highlighted, and paste if text is not highlighted.
Concept
The concept is generally easy, and allows you to scale to multiple keys to make auto populating forms, data, or even variable phrases a breeze.
- Backup the clipboard.
- Clear the clipboard.
- Send Ctrl C
- If the clipboard returns with nothing: (That would indicate no text was selected) - Paste previously assigned variable, else store the captured text to an assigned variable.
- Restore clipboard from backup.
Issue
However, I've been caught on a snag. Clearing the clipboard clears all variables attached to it. The Clipboard Backup is always deleted if it is AFTER {#setclipboard}.
I have tried waits and nested statements with no luck. Hope one of you experts might have the answer.
Code
Any help is deeply appreciated!
Hotkey: Num1
Use: Highlight some text in a notepad, Press the hotkey, It will process the sample code below. Then remove "{#setclipboard}"
Code: Select all
{#clipboard -copy}{#set -name clipbkup -content {#clipboard -paste}}{#setclipboard}
Bkup: {#gettemp clipbkup} <--- The Value to restore to the clipboard after execution
Clip: {#clipboard -paste} <--- The clipboard after the completion
(Rest of code to execute with those variables here)