I am making a bot for an FPS game called Combat Arms, its full screen. The problem here is my code works, but when I open up the full screen combat arms window, it does noting at all...
It is a simple AFK Bot, with simple key presses, and mouse clicks.
Can someone tell me why it doesn't work when I go in game?
Btw don't quote the code please, I wish to remove the code once answered.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"
#include <iostream>
#include <cstdio>
#include <winable.h>
using namespace std;
HWND CAHandle()
{
return FindWindow(NULL, "Combat_Arms");
}
// Key Inputs
void GenerateKey(BYTE vk)
{
INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = vk;
SendInput(1, &Input, sizeof(INPUT));
return;
}
// InGame Functions
int InGame()
{
GenerateKey((UCHAR)VkKeyScan('4'));
for (int GoInGame=0;GoInGame<5;GoInGame++)
{
SetCursorPos(1296, 8);
INPUT Input[2];
ZeroMemory(Input, sizeof(INPUT) * 2);
Input[0].type = INPUT_MOUSE;
Input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
Input[1].type = INPUT_MOUSE;
Input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(2, Input, sizeof(INPUT));
}
GenerateKey((UCHAR)VkKeyScan('1'));
GenerateKey((UCHAR)VkKeyScan('d'));
GenerateKey((UCHAR)VkKeyScan('i'));
GenerateKey((UCHAR)VkKeyScan('n'));
GenerateKey((UCHAR)VkKeyScan('g'));
GenerateKey((UCHAR)VkKeyScan(' '));
return 0;
}
//Click the start button to go in-game
int GoInGame()
{
for (int GoInGame=0;GoInGame<5;GoInGame++)
{
SetCursorPos(410, 650);
INPUT Input[2];
ZeroMemory(Input, sizeof(INPUT) * 2);
Input[0].type = INPUT_MOUSE;
Input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
Input[1].type = INPUT_MOUSE;
Input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(2, Input, sizeof(INPUT));
}
return 0;
}
// Click QuickJoin
int QuickJoin()
{
int join = 0;
while (join<100)
{
Sleep(1);
keybd_event( VK_SPACE, 0x45, KEYEVENTF_EXTENDEDKEY, 0 );
keybd_event( VK_SPACE, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
join++;
}
return 0;
}
// Starts the full bot
int StartBot()
{
return 0;
}
HINSTANCE hInst;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
/*
* TODO: Add code to initialize the dialog.
*/
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
/*
* TODO: Add more control ID's, when needed.
*/
case IDC_BTN_QUIT:
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_BTN_START:
if(CAHandle() != 0)
{
HDC hdc = GetDC(CAHandle());
ShowWindow(CAHandle(),SW_SHOWNORMAL);
SetForegroundWindow(CAHandle());
Sleep(9000);
CAHandle();
GoInGame();
}
else
{
MessageBox(hwndDlg, "Could not find Combat Arms!", "Error", MB_ICONINFORMATION);
}
return TRUE;
}
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
// The user interface is a modal dialog box
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, DialogProc);
}