working with selected text by hitting a hotkey

MFC app running: text selected in OTHER application (whatever app) & I hit a hotkey.
How should I work on the selected text?

I just want direction, not full code.
Any of the answers will be considered.

1a. Should I save clipboard, add text to clip, then when done restore it?
1b. If so, please supply pointer to restoring clipboard without corrupting it.
2. Any other way to work with selected text in external app, without working with clipboard at all?
3. Maybe there are ways to work with "multiple clipboards?"

ADVAthnaksNCE Moshe
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You probably don't need to use the clipboard.  But where is the text?  Is it in an edit box? an RTF window?  A list box? etc...

If it is in a rich edit control, for example, you can use the EM_GETTEXTRANGE message.  There are other messages for other types of controls/windows.
mflamAuthor Commented:
I see I have not been clear.
Of course if I was in my same app it would be easy...
Please give me a week (this is a very full week for me) and I'll fix the question.
mflamAuthor Commented:
Edited text of question.
There is not guaranteed way to make it work. The app could be anything an hnow knows how it will work....

Your best bet is to use the clipboard because most apps will use it in responce to WM_CUT and WM_PASTE, but some might not and some will might respond in ways you don't want and some might respond but plae data on the clipboard that is not in a text form....

So what you would need to do is enumerate all the formats on the clipboard (EnumClipboardFormats()) and obtain the data for all the formats (GetClipboardData()) and store it all.  Then send the WM_CUT to the other app.  Then try to get text from the clipbpoard, if it is there, modify it and place it back on the clipboard (Clear the other formats from the clipboard, you don't want the app pulling from one of the unaltered formats.)  Then, whethor or not your got text from the other app, send it a WM_PASTE.  Finally place all the original data back on the clipboard.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.