|
You last visited: Today at 04:13
Advertisement
Send Messages to a Game.
Discussion on Send Messages to a Game. within the C/C++ forum part of the Coders Den category.
07/03/2012, 15:14
|
#1
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
Send Messages to a Game.
Hey,
I'm trying to send a mouseclick-message to a game, like this:
Code:
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
HWND hWnd = FindWindowA(NULL, "GAME");
if(!hWnd)
{
cout << "HWND Failed" << endl;
getchar();
getchar();
exit(1);
}
Sleep(5000);
SendMessage(hWnd,WM_LBUTTONDOWN,0,0);
Sleep(100);
SendMessage(hWnd,WM_LBUTTONUP,0,0);
}
But nothing happens. Any suggestions??
|
|
|
07/03/2012, 15:26
|
#2
|
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
|
because it is using directinput instead of the windows message queue i guess. so the window itself doesnt care about anything it receives unless it is a quitmessage.
|
|
|
07/03/2012, 15:58
|
#3
|
elite*gold: 0
Join Date: Jun 2012
Posts: 9
Received Thanks: 2
|
Quote:
Originally Posted by jackicola
Hey,
I'm trying to send a mouseclick-message to a game, like this:
Code:
...
SendMessage(hWnd,WM_LBUTTONDOWN,0,0);
Sleep(100);
SendMessage(hWnd,WM_LBUTTONUP,0,0);
}
But nothing happens. Any suggestions??
|
You should specify the coordinates of the cursor in lParam (and maybe set wParam to 1 when you send the WM_LBUTTONDOWN message)
|
|
|
07/03/2012, 16:13
|
#4
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
THX, but it's still not working.. I read that DirectX games in most cases ignore this kind of Messages. What can I do?
|
|
|
07/03/2012, 16:24
|
#5
|
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
|
get the handle of the directinput device and send your messages there. you won't find that one with FindWindow, you gotta query its GUID from the process and the try to copy the handle with full access, a rather complex process.
|
|
|
07/03/2012, 18:19
|
#6
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
if its not necessary that the window is in the background you can try SendInput with DInput keycodes.
otherwise you should do what tnd0 said, or hook dinput like this:
if you want to make a bot which works in the background, you should reverse the game and call the functions which get called when you press a key on your own.
|
|
|
07/04/2012, 14:00
|
#7
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
Thx for that link! I coded my DLL, but I get 2 Errors:
1: LPDIRECTINPUTDEVICE is not defined. (Maybe include a .dll/.lib?)
2: DI_OK is not defined.
How can I fix that?
Greets!
|
|
|
07/04/2012, 14:25
|
#8
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
include dinput.h
its in the dx sdk:
|
|
|
07/04/2012, 17:03
|
#9
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
Okay, I included this file and now it says:
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
How to fix that?
Greets!
|
|
|
07/04/2012, 17:07
|
#10
|
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
|
before including dxinput.h:
Code:
#define DIRECTINPUT_VERSION 2048
|
|
|
07/04/2012, 19:09
|
#11
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
THX for ur help it's working now (Atleast with that test-program).
I tried to inject it in "Aion", a MMORPG, and the Log looks like this:
Code:
Log Added (07/04/12 19:04:55): ==========LOG START==========
Log Added (07/04/12 19:04:55): DLL Attached
Log Added (07/04/12 19:04:55): Creating Thread...
Log Added (07/04/12 19:04:55): Thread Created
Log Added (07/04/12 19:04:55): Searching dinput8.dll...
Log Added (07/04/12 19:04:55): Found dinput8.dll: 58690000 !
Log Added (07/04/12 19:04:55): Searching GetDeviceState...
Log Added (07/04/12 19:04:55): Found DirectInput8Create: 5869cc8e !
Log Added (07/04/12 19:04:55): GetDevicestate is here (DirectInput8Create - 0x62B1): 586969dd
Log Added (07/04/12 19:04:55): Hooking GetDeviceState...
Log Added (07/04/12 19:04:55): Hooked GetDeviceState - Trampolin: 3b4b14c0 - New: 58541177 !
Log Added (07/04/12 19:06:06): DLL Detached
Log Added (07/04/12 19:06:06): ==========LOG END==========
And I changed the new Function to this:
Code:
HRESULT __stdcall hkGetDeviceState(LPDIRECTINPUTDEVICE lpDevice, DWORD cbData, LPVOID lpvData)
{
static BYTE buffer[256];
HRESULT temp = DI_OK;
------------------>add_log("LOOP"); <------------------
if (!Freeze)
{
temp = pGetDeviceState(lpDevice, cbData, lpvData);
memcpy(buffer, lpvData, cbData);
} else {
memcpy(lpvData, buffer, cbData);
}
return temp;
}
But it doesn't say "LOOP" a single time in the Log. So something is going wrong. Can you please help me again?
|
|
|
07/04/2012, 19:28
|
#12
|
elite*gold: 0
Join Date: Jun 2012
Posts: 187
Received Thanks: 58
|
Im pretty positive Aion has some complex anti-cheat mechanisms. Rule #2 on asian software: it's not what it looks like. (rule #1: never trust it)
Try it on some other games, preferably singleplayer indie-games.
|
|
|
07/04/2012, 20:36
|
#13
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
Yeah,ok, but my goal was to make a bot for Aion. Do you have any ideas how I could make this work?
THX!
|
|
|
07/04/2012, 21:39
|
#14
|
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
|
check if your detour installed correctly.
if not, try vtable replacing, mid-function hooks, etc.
|
|
|
07/04/2012, 21:59
|
#15
|
elite*gold: 0
Join Date: Jan 2009
Posts: 129
Received Thanks: 15
|
And how can I check this? Doesn't the Log say it was installed correctly?
|
|
|
|
|
Similar Threads
|
How to send keystrokes to a game
01/14/2012 - C/C++ - 13 Replies
Dear reader,
I am recently starting to learn C++.
I have the following problem:
I build this GUI program which should repeat my shouts
by a simple method.
Send a "space", then "up key", then "enter key" command.
Only this is, that it will not respons if the window is not focussed.
|
Game Starting *Don't Send*
08/25/2011 - Dekaron - 5 Replies
When I start dekaron, it says Game Starting *Don't Send*, i tried reinstalling so many time, what should I do?
|
can someone send me game.exe *German*
11/30/2010 - Shaiya Hacks, Bots, Cheats & Exploits - 1 Replies
hi can some1 pls help me i accidentally deleted the game.exe of German Shaiya pls send 1 the original... [email protected] tnx alot
|
[Help] send messages
08/12/2009 - Kal Online - 0 Replies
hi...
i have points on the kal window that i need to click on
now...i tried to simply send them at the beggining..
but than i realized that its stupid since all the pixel bots are detected
so...i need help
after that i tried to "sniff" (Spy++) the messages and i got that 3 messages are sent when u move the mouse:
cool...i sent them all as a set every 100milisec so that the game "think" i am moving the mouse over the game window
and..now for the clicking part:
i found those-
|
can any body send me the latest version of the game client?
11/16/2008 - Conquer Online 2 - 0 Replies
i tried downloading the latest version of the client but i can't download it..
can anybody send me the latest game client in my yahoo email account? is it possible? [email protected].. thanks
|
All times are GMT +2. The time now is 04:13.
|
|