Code to transform paste buffer strings

Copying text from an IE5 browser window and pasting to Office2K, InterDev or FrontPage or gives:

<TITLE>Join <%=SITENAME%></TITLE>

instead of:

<TITLE>Join <%=SITENAME%></TITLE>

Surely there's a trival solution to over-ride this behavior...is 200 points enough for an executable?

thankx
--steve...

juststeveAsked:
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.

chensuCommented:
What exactly do you want? C++ code?
0
juststeveAuthor Commented:
an executable.

I don't care if it vb-based or what. I just figured the platform best suited for this would be c++

Possible something like this could be accessed via registry keys? But I'll be moving to win2k soon and expect the same issure going on there.
0
chensuCommented:
Do you want the executable to simply convert the string for you? Or do you want the executable to toggle the IE5 behavior?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Jan LouwerensSoftware EngineerCommented:
what happens if you do a View Source on the page, and then copy and paste from there?
0
juststeveAuthor Commented:
Copying from View Source has the same effect my currect solution of pasting to a notepad window and re-copying -unworkable to expect to be able to find the exact source I'm looking to copy.

As to toggle or not... the best solution I can imagine is an application that's associated with the key combination: Ctrl-SpaceBar. When pressed the conversion es effected on whatever's in the paste buffer.

Does this whole issue arise as the result of the clipboard 'enhancements' in Office2K?
0
KangaRooCommented:
It appears that only < and > are replaced by &lt; and &gt; respectively. VBA or macro to replace these tokenstrings might be the simplest solution.

IE5 + Word 97 doesn't behave this way, so I can't reproduce it.
0
KangaRooCommented:
You could try the following code:

Sub Macro1()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "&lt;"
        .Replacement.Text = "<"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "&gt;"
        .Replacement.Text = ">"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
0
juststeveAuthor Commented:
But VBA apps can't execute inside FrontPage or InterDev, can they?
0
KangaRooCommented:
I don't know, I'm using Office 97 and don't have Frontpage or InterDev. If I'd thought it was the solution to your problem I'd have submitted it as answer :) I think it'll work for Word tough (did it?).
0
juststeveAuthor Commented:
My mistake for not making it clear that I need this for developement work (FP and InterDev) so i haven't run it against Word.

thankx anyway.
--steve...
0
KangaRooCommented:
Do you have access to a C++ compiler, or should I mail the executable? Here is the code.
When executed the program reads the clipboard, modifies the text replacing &lt with < and &gt; with >
The modified text is placed back on the clipboard and the program terminates. You can assign it to a hotkey from windows.
//=============================================================
#include <windows.h>

int main()
{
   // Check if text is available
   if(!IsClipboardFormatAvailable(CF_TEXT))
      return 1;
   // if so, Get it
   if(!OpenClipboard(0))
      return 2;
   HANDLE hData = GetClipboardData(CF_TEXT);
   if(!hData)
   {
      CloseClipboard();
      return 2;
   }
   char* buffer = (char*)GlobalLock(hData);

   HGLOBAL hglb = GlobalAlloc(GMEM_SHARE, strlen(buffer) + 1);
   if(!hglb)
   {
      CloseClipboard();
      GlobalUnlock(hData);
      return 2;
   }

   char* outbuffer = (char*)GlobalLock(hglb);
   char* out = outbuffer;

   // parse and modify
   int cursor = 0;
   while(buffer[cursor])
   {
      if(buffer[cursor] == '&' && buffer[cursor + 2] == 't' && buffer[cursor + 3] == ';')
      {
         switch(buffer[cursor+1])
         {
            case 'l' : *out++ = '<'; cursor += 4; break;
            case 'g' : *out++ = '>'; cursor += 4; break;
            default  : *out++ = buffer[cursor++]; break;
         }
      }
      else *out++ = buffer[cursor++];
   }
   *out = '\0';

   // release handles
   GlobalUnlock(hData);
   GlobalUnlock(hglb);

   // put modified data back on the clipboard
   EmptyClipboard();
   SetClipboardData(CF_TEXT, hglb);

   CloseClipboard();
}
0

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
KangaRooCommented:
Can you give me your e-mail so that I can mail you the executable?
0
juststeveAuthor Commented:
steve@juststeve.com

we need to add one more conversion:

find &amp; replace with &

many thankx
--steve...

0
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
C++

From novice to tech pro — start learning today.