Hello list

I have made a plugin for Internet Explorer who responds to clicks on an URL 
in any application and then redirects the URL to IE if it is an internal
link (intranet)
or opens a terminalserver session to a server with internet connection (IE
starts automatically when login in
to the server). The plugin works pretty welle except for one thing.
I have to send the URL as keystrokes (key by key) because copy and paste is
disabled
on the terminal server for security reasons.
I have used the "SendKeys32.pas" file for sending the keystrokes.
The problem is that if a URL contains a tilde (~), then the functions in
then
SendKeys32.pas replaces tilde with the "ENTER" key and then screws up the
whole URL.
Sometimes it also "forget" to press SHIFT when sending ex. http://www.vg.no/
it turns up as 
http.77www.vg.no7. 
Does anyone know of a better way to send keystrokes to a window 
and also sends tilde as the correct character ?
Here is an example of my code:

const
  Class_IEBrowserHelper: TGUID = '{FCADDC14-BD46-408A-9842-CDBE1C6D37EB}';
// Unik GUID
  CI_ISEXTERNAL   = 0;
  CS_ISINTERNAL   = 1;
  CS_NOTCONNECTED = 2;
  CS_INETCLASS    = 'TSSHELLWND';
  CS_INETRDP      = 'C:\Temp\inet.rdp';  // RDP fil for tilkobling til
internet

  CL_DESKTOPBLUE  = $00A56D39; // Bakgrunnsfarge for desktop vindu (m�rk
bl�). RGB kode=R(57) G(109) B(165)
  CL_INTERNETBLUE = $009C4D00; //
  CL_EXPLORERGRAY = $00CED3D6; // $00D6D3CEGr�fargen til Internet Explorer
toolbar. RGB kode= R(214) G(211) B(206)
  CL_EXPLORERGRAY2= $00C7C7C7; // Explorerfargen kan variere...Denne er for
XP maskiner...
  CL_INACTIVEIE   = $00848284; // Caption bar farge for Internet Explorer
n�r IE er inaktiv (mangler fokus)...
  CS_KEYCOMMAND   = '{F6}';

procedure DoConnectProcessing;
var
iTime       : integer;
clColor1,
clColor2,
clColor3    : TColor; // Farge variabler for detektering av bakgrunnsfarge
cCanvas     : TCanvas;
bMatch      : boolean;
s           : string;
begin
      FindTerminalWindow;
      if hInetWin > 0 then
      begin
        cCanvas          := TCanvas.Create;
        s                := CS_KEYCOMMAND + sGurl+ '{ENTER}';
        //ProcessSpecialChars(s);
       AppActivate(hInetWin,PAnsichar(sPwd + '{ENTER}'),true,false);
        bMatch := false;
        for iTime := 0 to GetSendURLTimeout do // Loop X antall ganger ut i
fra "Timeout" verdi i registry...
        begin                  // Det testes for verdien CL_EXPLORERGRAY som
er bakgrunnsfargen for Internet Explorer Toolbar
          cCanvas.Handle    := GetWindowDC(0); // Hent Device Context handle
          sleep(1000);     // 1 sekunds pause (1000 millisekunder)
          clColor1          := ColorToRGB(GetPixel(cCanvas.Handle,40,25));
// 40 X, 60 Y
          clColor2          := ColorToRGB(GetPixel(cCanvas.Handle,45,25));
// 45 X, 60 Y
          clColor3          := ColorToRGB(GetPixel(cCanvas.Handle,300,25));
// 300 X, 60 Y

          bMatch := (clColor1=CL_EXPLORERGRAY) and
(clColor2=CL_EXPLORERGRAY) and (clColor3=CL_EXPLORERGRAY);
          if bMatch then
          begin
             sleep(1000); // For sikkerhets skyld...
             SetCursorPos(30,10); // Flytt musepeker til caption bar. Dette
er sannsynligvis un�dvendig,
             sleep(1000);         // men m�tte gj�re det p� utviklings pc'en
pga. Norton Antivirus tok fokus fra IE
             SendMessage(hInetWin,WM_NCHITTEST,0,MAKELONG(40,10));
              AppActivate(hInetWin,PAnsichar(s),true,false);
            break;
          end;
        end;
        if not bMatch then MessageBox(hInetWin,PAnsiChar('Kan ikke �pne URL
pga. p�logging tok for lang tid eller IE ikke funnet'),PAnsiChar('Thales URL
Redirector'), MB_ICONERROR or MB_OK);
         cCanvas.Free;
      end;
end;

function AppActivate(WindowHandle : HWND;pKey : PAnsiChar;bWait :
boolean;bHotkey : boolean) : boolean; overload;
begin
  try
   if bHotkey then
   begin
     SendMessage(WindowHandle, WM_SYSCOMMAND, SC_HOTKEY, WindowHandle);
     SendMessage(WindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, WindowHandle);
   end;
    result := SetForegroundWindow(WindowHandle);
    SendKeys(pKey,bWait);
  except
    on Exception do Result:=false;
  end;
end;

Roger Boyesen
Norway
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to