Code:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "windows.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "trayicon"
#pragma resource "*.dfm"
TForm1 *Form1;
int active = 0;
HDC mutex;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//aby program byl spustenej jen jednou
SetLastError(0);
mutex=CreateMutex(NULL,0,"FPSInjector-Jirka");
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
ShowMessage("FPS:Injector is already running.");
Application->Terminate();
// ExitProces();
}
//------------------------------------
active =0;
btnButton1->BringToFront();
btnButton2->SendToBack();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::tmrKeyboardTimer(TObject *Sender)
{
if (active ==0)
{
return;
}
/*
w=119
W=87
*/
if(GetAsyncKeyState(119))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'w' pressed ==> Arrow up");
keybd_event(VK_UP,MapVirtualKey(VK_UP,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_UP,MapVirtualKey(VK_UP,0),KEYEVENTF_KEYUP,0);
}
if(GetAsyncKeyState(87))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'W' pressed ==> Arrow up");
keybd_event(VK_UP,MapVirtualKey(VK_UP,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_UP,MapVirtualKey(VK_UP,0),KEYEVENTF_KEYUP,0);
}
/*
A=65
a=97
*/
if(GetAsyncKeyState(65))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'A' pressed ==> Arrow left");
keybd_event(VK_LEFT,MapVirtualKey(VK_LEFT,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_LEFT,MapVirtualKey(VK_LEFT,0),KEYEVENTF_KEYUP,0);
}
if(GetAsyncKeyState(97))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'a' pressed ==> Arrow left");
keybd_event(VK_LEFT,MapVirtualKey(VK_LEFT,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_LEFT,MapVirtualKey(VK_LEFT,0),KEYEVENTF_KEYUP,0);
}
/*
S=83
s=115
*/
if(GetAsyncKeyState(83))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'S' pressed ==> Arrow down");
keybd_event(VK_DOWN,MapVirtualKey(VK_DOWN,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_DOWN,MapVirtualKey(VK_DOWN,0),KEYEVENTF_KEYUP,0);
}
if(GetAsyncKeyState(115))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 's' pressed ==> Arrow down");
keybd_event(VK_DOWN,MapVirtualKey(VK_DOWN,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_DOWN,MapVirtualKey(VK_DOWN,0),KEYEVENTF_KEYUP,0);
}
/*
D=68
d=100
*/
if(GetAsyncKeyState(68))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'D' pressed ==> Arrow right");
keybd_event(VK_RIGHT,MapVirtualKey(VK_RIGHT,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_RIGHT,MapVirtualKey(VK_RIGHT,0),KEYEVENTF_KEYUP,0);
}
if(GetAsyncKeyState(115))
{
Form2->mmoOutput->Lines->Add(TimeToStr(Time()) + " 'd' pressed ==> Arrow right");
keybd_event(VK_RIGHT,MapVirtualKey(VK_RIGHT,0),0,0);
//keybd_event('C',MapVirtualKey('C',0),0,0);
//keybd_event('C',MapVirtualKey('C',0),KEYEVENTF_KEYUP,0);
keybd_event(VK_RIGHT,MapVirtualKey(VK_RIGHT,0),KEYEVENTF_KEYUP,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::imgBackgroundDblClick(TObject *Sender)
{
Form2->Show();
Form2->Width = Form1->Width;
if(TrayIcon->Visible==true)
{
TrayIcon->Visible=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnButton2Click(TObject *Sender)
{
btnButton2->SendToBack();
btnButton1->BringToFront();
active=0;
//tmrKeyboard->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender)
{
ShellExecute(Application->Handle,"open","http://www.Clan-OutlawZ.info",NULL, NULL, SW_SHOWDEFAULT);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WndProc(Messages::TMessage &Message)
{
switch(Message.Msg)
{
case WM_SYSCOMMAND:
if(Message.WParam==SC_MINIMIZE)
{
TrayIcon->Visible=true;
}
break;
}
TForm::WndProc(Message);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
CloseHandle(mutex);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TrayIconRestore(TObject *Sender)
{
TrayIcon->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::mnuExitClick(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::mnuActivateClick(TObject *Sender)
{
if(mnuActivate->Caption=="A&ctivate")
{
//aktivace
btnButton1Click(NULL);
mnuActivate->Caption="&Deactivate";
return;
}
//deakticvace
btnButton2Click(NULL);
mnuActivate->Caption="A&ctivate";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::mnuTheOutlawZClick(TObject *Sender)
{
Image1Click(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnButton1Click(TObject *Sender)
{
btnButton1->SendToBack();
btnButton2->BringToFront();
active=1;
//tmrKeyboard->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Form2->Top = Form1->Top + Form1->Height;
Form2->Left = Form1->Left;
}
//---------------------------------------------------------------------------