Procedure TForm1.SendCommandToProg(SpecialKey :
String ; Key :
String ;
CommandType :
String ; ProgHandle : THandle);
Var
KeyInt,SpecialKeyInt : Integer;
DefaultBool, ShowCommandFailure : Boolean;
begin
DefaultBool := False;
ShowCommandFailure := GP_ConfigObject.GetValue('
ShowProgFailure',DefaultBool);
KeyInt := StrToInt(Key);
SpecialKeyInt := StrToInt(SpecialKey);
if GP_ConfigObject.GetValue('
CommandDebugMode',DefaultBool) = True
then
begin
MemoCommand.Lines.Add('
Tastenbefehl konnte nicht gesendet werden!');
MemoCommand.Lines.Add('
Programm: '+FCurrentProgrammName);
MemoCommand.Lines.Add('
Kommando Typ: '+CommandType);
MemoCommand.Lines.Add('
SpecialKey: '+SpecialKey);
MemoCommand.Lines.Add('
Key: '+Key);
MemoCommand.Lines.Add('
Programm Handel: '+inttostr(ProgHandle));
end;
//-----------------------------------------------------------------
if SpecialKeyInt = 00
then
begin
if ShowCommandFailure = True
then
begin
postmessage(ProgHandle,WM_KEYDOWN,KeyInt,0);
IF postmessage(ProgHandle,WM_KEYUP,KeyInt,0) = False
then
begin
MemoCommand.Lines.Add('
Tastenbefehl konnte nicht gesendet werden!');
MemoCommand.Lines.Add('
'+FCurrentProgrammName);
MemoCommand.Lines.Add('
'+CommandType);
MemoCommand.Lines.Add('
SpecialKey: '+SpecialKey);
MemoCommand.Lines.Add('
Key: '+Key);
MemoCommand.Lines.Add('
Programm Handel: '+inttostr(ProgHandle));
ModLogger.AddToLog('
Konnte Kommando nicht and Handle senden. Programm: '+FCurrentProgrammName+'
Commandtype: '+CommandType+'
SpecialKey: '+SpecialKey+'
Key: '+Key+'
Programm Handel: '+inttostr(ProgHandle),ModError);
end;
end else
begin
postmessage(ProgHandle,WM_KEYDOWN,KeyInt,0);
postmessage(ProgHandle,WM_KEYUP,KeyInt,0);
MemoCommand.Lines.Add( FCurrentProgrammName+'
Kommando erhalten: '+CommandType);
end;
end;
if SpecialKeyInt = 01
then
begin
if ShowCommandFailure = True
then
begin
PostMessage(ProgHandle, WM_KEYDOWN, VK_CONTROL,0);
// Ctrl runter
PostMessage(ProgHandle, WM_KEYDOWN, KeyInt, 0);
// Taste runter
PostMessage(ProgHandle, WM_KEYUP, KeyInt, 0);
// Taste rauf
IF PostMessage(ProgHandle, WM_KEYUP, VK_CONTROL, 0) = False
then // Ctrl rauf
begin
MemoCommand.Lines.Add('
Tastenbefehl konnte nicht gesendet werden!');
MemoCommand.Lines.Add('
'+FCurrentProgrammName);
MemoCommand.Lines.Add('
'+CommandType);
MemoCommand.Lines.Add('
SpecialKey: '+SpecialKey);
MemoCommand.Lines.Add('
Key: '+Key);
MemoCommand.Lines.Add('
Programm Handel: '+inttostr(ProgHandle));
ModLogger.AddToLog('
Konnte Kommando nicht and Handle senden. Programm: '+FCurrentProgrammName+'
Commandtype: '+CommandType+'
SpecialKey: '+SpecialKey+'
Key: '+Key+'
Programm Handel: '+inttostr(ProgHandle),ModError);
end;
end else
begin
PostMessage(ProgHandle, WM_KEYDOWN, VK_CONTROL,0);
// Ctrl runter
PostMessage(ProgHandle, WM_KEYDOWN, KeyInt, 0);
// Taste runter
PostMessage(ProgHandle, WM_KEYUP, KeyInt, 0);
// Taste rauf
PostMessage(ProgHandle, WM_KEYUP, VK_CONTROL, 0);
// Ctrl rauf
MemoCommand.Lines.Add( FCurrentProgrammName+'
Kommando erhalten: '+CommandType);
end;
end;
if SpecialKeyInt = 02
then
begin
if ShowCommandFailure = True
then
begin
PostMessage(ProgHandle, WM_KEYDOWN, VK_MENU,0);
// Alt runter
PostMessage(ProgHandle, WM_KEYDOWN, KeyInt, 0);
// Taste runter
PostMessage(ProgHandle, WM_KEYUP, KeyInt, 0);
// Taste rauf
IF PostMessage(ProgHandle, WM_KEYUP, VK_MENU, 0) = False
then // Alt rauf
begin
MemoCommand.Lines.Add('
Tastenbefehl konnte nicht gesendet werden!');
MemoCommand.Lines.Add('
'+FCurrentProgrammName);
MemoCommand.Lines.Add('
'+CommandType);
MemoCommand.Lines.Add('
SpecialKey: '+SpecialKey);
MemoCommand.Lines.Add('
Key: '+Key);
MemoCommand.Lines.Add('
Programm Handel: '+inttostr(ProgHandle));
ModLogger.AddToLog('
Konnte Kommando nicht an Handle senden. Programm: '+FCurrentProgrammName+'
Commandtype: '+CommandType+'
SpecialKey: '+SpecialKey+'
Key: '+Key+'
Programm Handel: '+inttostr(ProgHandle),ModError);
end;
end else
begin
PostMessage(ProgHandle, WM_KEYDOWN, VK_MENU,0);
// Alt runter
PostMessage(ProgHandle, WM_KEYDOWN, KeyInt, 0);
// Taste runter
PostMessage(ProgHandle, WM_KEYUP, KeyInt, 0);
// Taste rauf
PostMessage(ProgHandle, WM_KEYUP, VK_MENU, 0);
// Alt rauf
MemoCommand.Lines.Add( FCurrentProgrammName+'
Kommando erhalten: '+CommandType);
end;
end;
end;