Ver Mensaje Individual
  #4  
Antiguo 30-01-2012
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Reputación: 18
cesarsoftware Va por buen camino
Hola satael.

Te lo pongo mas facil, esta son las funciones que uso yo habitualmente.

Código Delphi [-]
function SacaTeclado(): HWND;
var
  TecladoPgm: string;
  TecladoWND: HWND;
  Resultado: integer;
  msg: string;
begin
  TecladoPGm := 'c:\windows\osk.exe' // se puede usar otro.
  TecladoWND := FindWindow(nil, 'Teclado en pantalla'); // comprueba si esta en ram
  if TecladoWND = 0 then
  begin
    Resultado := ShellExecute(Application.Handle, 'open', PChar(TecladoPgm), Pchar(''), PChar(ExtractFilePath(TecladoPgm)), SW_SHOW);
    case Resultado of
      0: msg := 'The operating system is out of memory or resources.';
      ERROR_FILE_NOT_FOUND: msg := 'The specified file was not found.';
      ERROR_PATH_NOT_FOUND: msg := 'The specified path was not found.';
      ERROR_BAD_FORMAT: msg := 'The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).';
      SE_ERR_ACCESSDENIED: msg := 'The operating system denied access to the specified file.';
      SE_ERR_ASSOCINCOMPLETE: msg := 'The file name association is incomplete or invalid.';
      SE_ERR_DDEBUSY: msg := 'The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.';
      SE_ERR_DDEFAIL: msg := 'The DDE transaction failed.';
      SE_ERR_DDETIMEOUT: msg := 'The DDE transaction could not be completed because the request timed out.';
      SE_ERR_DLLNOTFOUND: msg := 'The specified DLL was not found.';
      SE_ERR_NOASSOC: msg := 'There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.';
      SE_ERR_OOM: msg := 'There was not enough memory to complete the operation.';
      SE_ERR_SHARE: msg := 'A sharing violation occurred.';
    else
      msg := 'Otro problema';
    end;
    if Resultado < 32 then
    begin
      Application.MessageBox(PChar('Problema al ejecutar' + #13 + TecladoPgm + #13 + msg), 'Error', MB_ICONERROR);
      Result := TecladoWND;
      Exit;
    end;
    EsperaSegundos(0.5); // Esperar a que se ejecute
    TecladoWND := FindWindow(nil, 'Teclado en pantalla'); //encuentra la nueva ventana
    if TecladoWND = 0 then
      Application.MessageBox('No encuentro la ventana del teclado', 'Error', MB_ICONERROR);
  end;
  Result := TecladoWND;
end;

procedure CierraTeclado();
var
  TecladoWND: HWND;
begin
  TecladoWND := FindWindow(nil, 'Teclado en pantalla'); // comprueba si es esta en ram
  if TecladoWND = 0 then
    Exit;
  CloseWindow(TecladoWND);  // minimiza
  PostMessage(TecladoWND, WM_CLOSE, 0, 0); // Cierra
end;
Responder Con Cita