Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 04-01-2020
MaxiDucoli MaxiDucoli is offline
Miembro
 
Registrado: feb 2006
Posts: 134
Poder: 19
MaxiDucoli Va por buen camino
Cerrar mi aplicación de consola con ESCAPE o DOS BOTONES DE JOYSTICK

Hola a todos.
FELIZ AÑO!!!!!!
Les quería hacer una consulta.
Les voy a pasar mi código y quisiera saber si hay alguna manera de cerrar el proceso de una función con la tecla ESCAPE o una combinación de dos botones de algún joystick


Código Delphi [-]
program RLCExe;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, StrUtils,Classes, ShellApi, windows;
var
CMD, DRIVE,  GAMECONSOLE,LauncherBAT, CONSOLEPROGRAM , FName, BatFilePath : String;
i : integer;
FBat : TextFile;



function EjecutarYEsperar( sPrograma: String; Visibilidad: Integer ): Integer;
var
  sAplicacion: array[0..512] of char;
  DirectorioActual: array[0..255] of char;
  DirectorioTrabajo: String;
  InformacionInicial: TStartupInfo;
  InformacionProceso: TProcessInformation;
  iResultado, iCodigoSalida: DWord;


begin
  StrPCopy( sAplicacion, sPrograma );
  GetDir( 0, DirectorioTrabajo );
  StrPCopy( DirectorioActual, DirectorioTrabajo );
  FillChar( InformacionInicial, Sizeof( InformacionInicial ), #0 );
  InformacionInicial.cb := Sizeof( InformacionInicial );

  InformacionInicial.dwFlags := STARTF_USESHOWWINDOW;
  InformacionInicial.wShowWindow := Visibilidad;
  CreateProcess( nil, sAplicacion, nil, nil, False,
                 CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
                 nil, nil, InformacionInicial, InformacionProceso );


  // Espera hasta que termina la ejecución
  repeat
    iCodigoSalida := WaitForSingleObject( InformacionProceso.hProcess, 1000 );
    //Application.ProcessMessages;
//    if  then break;

  until ( iCodigoSalida <> WAIT_TIMEOUT );

  GetExitCodeProcess( InformacionProceso.hProcess, iResultado );
  MessageBeep( 0 );
  CloseHandle( InformacionProceso.hProcess );
  Result := iResultado;
end;

function ExtractTextBetween(const Input, Delim1, Delim2: string): string;
var
  aPos, bPos: Integer;
begin
  result := '';
  aPos := Pos(Delim1, Input);
  if aPos > 0 then begin
    bPos := PosEx(Delim2, Input, aPos + Length(Delim1));
    if bPos > 0 then begin
      result := Copy(Input, aPos + Length(Delim1), bPos - (aPos + Length(Delim1)));
    end;
  end;
end;

function GetCommandLine : String;
var
i : integer;
CMD : String;
begin
CMD := '';

    for  i := 0 to ParamCount do
    begin
    CMD  := CMD + ' ' + ParamStr(i);
    //CMD := TRIM(CMD);
    end;

    if CMD <> '' then
    begin
        Result := CMD;
    end else
    begin
        Result := '';
    end;

end;

function ExtractGameConsole(s : string) : String;
var
cmd : String;
begin

CMD := ExtractTextBetween(s,'\roms\','\');

if CMD <> '' then
begin
  Result := CMD;
end else
begin
Result := '';
end;


end;

procedure EditOpt (SysNew : String);
var
Lst : TStringList;
DRV, SysOld : String;
i : integer;
begin

DRV := ExtractFileDrive(ParamStr(0));

Try
  Lst := TStringList.Create;
  Lst.LoadFromFile(DRV + '\RetroLife\emulators\retroarch\retroarch-core-options.cfg');

  for I := 0 to Lst.Count -1 do
    begin
           if AnsiContainsText(Lst[i],'atari800_system = "') then
           SysOld := ExtractTextBetween(Lst[i], 'atari800_system = "','"');

           if SysOld <> '' then
           begin
             Lst[i] := AnsiReplaceText(Lst[i],SysOld,SysNew);
             Break;
           end;

    end;

Finally
Lst.SaveToFile(DRV + '\RetroLife\emulators\retroarch\retroarch-core-options.cfg');
Lst.Free;
End;

end;

Function GetSystemProgram(s : String) : String;

CONST CONSOLABASE : string = '\RetroLife\emulators\';
var DRIVE : String;
begin
DRIVE := ExtractFileDrive(ParamStr(0));

if s = '3ds' then Result := DRIVE + CONSOLABASE + s + '\' + 'citra-qt.exe';

if s = 'scummvm' then Result := DRIVE + CONSOLABASE + s + '\' + 'scummvm.exe';

if s = 'wiiu' then Result := DRIVE + CONSOLABASE + s + '\' + 'Cemu.exe';

//if s = 'psp' then Result := DRIVE + CONSOLABASE + s + '\' + 'PPSSPP.exe';

if s = 'mame64' then Result := DRIVE + CONSOLABASE + s + '\' + 'mame64.exe';

if s = 'psp' then Result := DRIVE + CONSOLABASE + s + '\' + 'PPSSPPWindows64.exe';

if s = 'wii' then Result := DRIVE + '\RetroLife\emulators\wii-gamecube\Dolphin.exe';

if s = 'gamecube' then Result := DRIVE + '\RetroLife\emulators\wii-gamecube\Dolphin.exe';

if s = 'dreamcast' then Result := DRIVE + '\RetroLife\emulators\dreamcast\redream.exe';

if s = 'ps2' then Result := DRIVE + '\RetroLife\emulators\ps2\pcsx2.exe';

if s = 'amigacd32' then Result := DRIVE + '\RetroLife\emulators\amiga\System\Launcher\Windows\x86-64\fs-uae-launcher.exe';

if s = 'amigacdtv' then Result := DRIVE + '\RetroLife\emulators\amiga\System\Launcher\Windows\x86-64\fs-uae-launcher.exe';

if s = 'amiga' then Result := DRIVE + '\RetroLife\emulators\amiga\System\Launcher\Windows\x86-64\fs-uae-launcher.exe';

if s = 'daphne' then Result := DRIVE + '\RetroLife\emulators\daphne\daphne.exe';

if s = 'neogeocd' then Result := DRIVE + '\RetroLife\emulators\retroarch\retroarch.exe';

if s = 'atari800' then
begin
EditOpt('400/800 (OS B)');
Result := DRIVE + '\RetroLife\emulators\retroarch\retroarch.exe';
end;

if s = 'atari5200' then
begin
EditOpt('5200');
Result := DRIVE + '\RetroLife\emulators\retroarch\retroarch.exe';
end;

if s = 'gamecom' then Result := DRIVE + CONSOLABASE + 'mame64\mame64.exe';

if s = 'gx4000' then Result := DRIVE + CONSOLABASE + 'mame64\mame64.exe';

end;

Function GetFileName (s : String) : String;
var
i : integer;
FileName, FDrive : String;
Begin
FDrive := ExtractFileDrive(ParamStr(0));
i := POS('.exe',s);

if i <> 0  then
begin
  FileName := Copy(s,i + 5,Length(s) - i + 5);
end;

if FileName <> '' then Result := FDrive + Filename;

End;

function ReadTXT (s : String) : String;
var
F : TStringList;
a : String;
begin
//AssignFile(f,s);

//Rewrite(F);

F := TStringList.Create;
//ReadLn(F,a);

F.LoadFromFile(s);
a := f.Text;

if a <> '' then
begin
  Result := a;
end else
begin
  Result := '';
end;

F.Free;

end;

Procedure CreateBat (ConsoleGAME,ConsolePROGRAM,FileGAME : String);
var
Lst : TStringlist;
//EMUPATH,
SCUMMVMGAME, DAPHNENAME : String;
begin

Lst := TStringList.create;
Lst.Clear;

  try

    if ConsoleGAME = '3ds' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "citra-qt.exe"' + ' "' + FileGAME + '" -f');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'scummvm' then
    begin

    SCUMMVMGAME := ReadTXT(FileGAME);
    Lst.Add ('echo START');
    Lst.Add ('set HOME="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add ('set GAMEFILE="' + FileGAME + '"');
//Type %TEXTFILE%
//Lst.Add( ExtractFileDrive(ConsoleProgram));
//Lst.Add('CD ' + ExtractFilePath(ConsoleProgram));
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D ' + '"' + ExtractFilePath(ConsoleProgram) + '"'  +
    ' "scummvm.exe" -f --joystick --savepath="' + ExtractFileDrive(ConsoleProgram) + '\RetroLife\saves\scummvm"' +
    ' -p "' + ExtractFilePath(FileGAME) + '\" ' + SCUMMVMGAME);
//@echo Done
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'psp' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "PPSSPPWindows64.exe"' + ' "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'wii' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "Dolphin.exe"' + ' /b /e "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'gamecube' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "Dolphin.exe"' + ' /b /e "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'dreamcast' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "redream.exe"' + ' "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'ps2' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "pcsx2.exe"' + ' --portable --fullscreen --nogui "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'amigacd32' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "fs-uae-launcher.exe"' +
    ' "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;
//\RetroLife\emulators\amiga\System\Launcher\Windows\x86-64\fs-uae-launcher.exe
    if ConsoleGAME = 'amigacdtv' then
    begin
   Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "fs-uae-launcher.exe"' +
    ' "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'amiga' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
//    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "fs-uae-launcher.exe" ' +
    '-config:floppy-drive-count=1 "' + FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'daphne' then
    begin
    DAPHNENAME := ExtractFileName(FileGAME);
    DAPHNENAME := ChangeFileExt(DAPHNENAME,'');
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "daphne.exe" ' +
    DAPHNENAME + ' vldp -opengl -homedir "\RetroLife\roms\daphne" -fullscreen');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'neogeocd' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "retroarch.exe"' +
    ' -L "\RetroLife\emulators\retroarch\cores\fbneo_libretro.dll" --subsystem neocd "' +
    FileGAME + '"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'atari800' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "retroarch.exe"' +
    ' -L "\RetroLife\emulators\retroarch\cores\atari800_libretro.dll"' +
    ' --config "\RetroLife\emulators\retroarch\retroarch.cfg" --appendconfig "\RetroLife\emulators\retroarch\config\retroarch-override.cfg" "' +
    FileGAME + '"' + ' --log-file "\RetroLife\logs\atari800-Logfile.txt" -v');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'atari5200' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "retroarch.exe"' +
    ' -L "\RetroLife\emulators\retroarch\cores\atari800_libretro.dll"' +
    ' --config "\RetroLife\emulators\retroarch\retroarch.cfg" --appendconfig "\RetroLife\emulators\retroarch\config\retroarch-override.cfg" "' +
    FileGAME + '"' + ' --log-file "\RetroLife\logs\' + ConsoleGAME + '-Logfile.txt" -v');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'gamecom' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "mame64.exe"' +
    ' gamecom -cart1 "' +
    FileGAME + '" -v >"\RetroLife\logs\gamecom-logFile.txt"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    if ConsoleGAME = 'gx4000' then
    begin
    Lst.Add ('echo START');
    Lst.Add ('set RUTA="' + ExtractFilePath(ConsoleProgram) + '"');
    Lst.Add('START "LAUNCHIMG" /B /D "\RetroLife" "FrmClose.exe" "\RetroLife\LaunchIMGS\' + ConsoleGAME + '.jpg"');
    Lst.Add('START "RUN-EMU" /W /B /D "' + ExtractFilePath(ConsoleProgram)+ '"' + ' "mame64.exe"' +
    ' gx4000 -cart "' +
    FileGAME + '" -v >"\RetroLife\logs\gamecom-logFile.txt"');
    Lst.Add('del %0');
    Lst.Add('@echo Done');
    LauncherBAT := 'Launcher' + ConsoleGAME + '.bat';
    end;

    //--amiga-model=CD32 --cdrom-drive-0=
  finally
  Lst.SaveToFile(ExtractFilePath(ConsoleProgram) +  LauncherBAT);
  Lst.Free;
  end;
  end;



begin

  try
    { TODO -oUser -cConsole Main : Insert code here }


    CMD := GetCommandLine;
    GAMECONSOLE := ExtractGameConsole(CMD);
    CONSOLEPROGRAM := GetSystemProgram(GAMECONSOLE);
    FName := GetFileName(CMD);
    CreateBat(GAMECONSOLE,CONSOLEPROGRAM,FName);

    BatFilePath := ExtractFilePath(CONSOLEPROGRAM) + LauncherBAT;
    //ShellExecute(0,nil,PWideChar(BatFilePath),nil,nil,SW_HIDE);
    ejecutaryesperar(BatFilePath,SW_HIDE);
     {unhook the keyboard interception}


  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;


end.

Yo creo que se debería poner algo en EjecutarYEsperar para cortar el proceso, pero no sé qué ni como.
Lo que hace este programa es agarrar los parámetros de una linea de comandos y prepara la línea de comandos del emulador que corresponda, una vez hecha la linea de comandos la guarda en un archivo BAT y luego con EjecutarYEsperar corre ese BAT y hasta que no termina, el programa de consola no se cierra.

Mientras el programa de consola está de fondo esperando, se ejecuta un emulador y es éste el que mantiene el foco todo el tiempo hasta que se cierra.


Es posible poner algún código para cerrar este proceso con ESCAPE o dos botones de Joysticks???

Muchas gracias!
Responder Con Cita
  #2  
Antiguo 04-01-2020
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Código Delphi [-]
  // Espera hasta que termina la ejecución
  repeat
    iCodigoSalida := WaitForSingleObject( InformacionProceso.hProcess, 1000 );
  until ( iCodigoSalida <> WAIT_TIMEOUT ) or (GetAsyncKeyState(VK_ESCAPE) <> 0);


Saludos.
Responder Con Cita
  #3  
Antiguo 04-01-2020
MaxiDucoli MaxiDucoli is offline
Miembro
 
Registrado: feb 2006
Posts: 134
Poder: 19
MaxiDucoli Va por buen camino
Cita:
Empezado por escafandra Ver Mensaje
Código Delphi [-]
  // Espera hasta que termina la ejecución
  repeat
    iCodigoSalida := WaitForSingleObject( InformacionProceso.hProcess, 1000 );
  until ( iCodigoSalida <> WAIT_TIMEOUT ) or (GetAsyncKeyState(VK_ESCAPE) <> 0);


Saludos.
MARAVILLOSO!!!!!!!

Estuve toda la tarde de ayer poniendo mil cosas en ese Repeat.
Jamás entendí de todo lo que leí (el 90% en inglés) lo que hacía GetAsyncKeyState().
MUCHAS GRACIAS!!!!
Responder Con Cita
  #4  
Antiguo 04-01-2020
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Cita:
Empezado por MaxiDucoli Ver Mensaje
MARAVILLOSO!!!!!!!

Estuve toda la tarde de ayer poniendo mil cosas en ese Repeat.
Jamás entendí de todo lo que leí (el 90% en inglés) lo que hacía GetAsyncKeyState().
MUCHAS GRACIAS!!!!

Básicamente devuelve un SHORT (DWORD) en el que pone a 1 el bit mas significativo si la tecla está pulsada en la llamada y a 1 el menos significativo se se pulsó la tecla y ya no está pulsada.
Código Delphi [-]
Tecla pulsada durante la llamada: 1000 0000 0000 0001b = 8001h = 32769d 
Tecla se pulsó y se soltó:        0000 0000 0000 0001b =    1h =     1d

En ambos casos el resultado es distinto de 0 por lo que si no te interesa saber si permanece pulsada, basta esta comparación.

Saludos.
Responder Con Cita
  #5  
Antiguo 04-01-2020
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola a todos,

Que dice el foro que no puedo añadirte más reputación, escafandra, de modo que dejo aquí este comentario: estupenda respuesta la que has dado. Yo ví el hilo anteriormente... y lo ví casi imposible... y resulta que no podía ser más ***sencillo***... en fin, por hilos como estos merece la pena este sitio.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #6  
Antiguo 04-01-2020
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Cita:
Empezado por dec Ver Mensaje
Hola a todos,

Que dice el foro que no puedo añadirte más reputación, escafandra, de modo que dejo aquí este comentario: estupenda respuesta la que has dado. Yo ví el hilo anteriormente... y lo ví casi imposible... y resulta que no podía ser más ***sencillo***... en fin, por hilos como estos merece la pena este sitio.
Pues reputación no tengo mucha, aunque la pregunta era facilona, al menos conociendo la API de windows. En realidad se me ocurren muchas formas de contestar este hilo pero tal como está expuesto el código de MaxiDucoli, la opción más sencilla y directa es GetAsyncKeyState




Saludos.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Cerrar FORM con la tecla escape lmpadron C++ Builder 3 11-12-2013 22:14:22
PageControl con botones cerrar Comandant Varios 10 16-11-2012 04:46:52
código para cerrar aplicación consola en Delphi 2010 kharen Varios 4 31-05-2011 17:01:40
Creacion de botones runtime, los cuales se mantengan despues de cerrar la aplicación giocatore Varios 18 25-01-2011 20:29:38
borrar, cerrar botones PHP arespremium PHP 3 04-08-2007 18:34:29


La franja horaria es GMT +2. Ahora son las 12:37:13.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi