![]() |
|
#1
|
|||
|
|||
SendMessage (WinAPI)Hello guys, I've been working on a program that will send text to a game, like a chatbot. The game is JO (Jedi Outcast) and it is Quake 3 Engine based. All commands are logged and can be issued through the console, which can be entered by pressing SHIFT and ~. I already have the console's name, it is 'jk2mp winconsole', thanks to some VB source code for a previous program of this sort. Here is the snippet of source I think is what finds the window and sends the text:
Code:
So the test function I've come up with in C++ is the following: CPP / C++ / C Code:
Notice I put say before the message in the buffer sent, that is the command to 'say' something in the game, anything after that command is shown to all players. Instead of \r after it to simulate the 'ENTER' key, I used the SendMessage with WM_CHAR wparam 13, is this correct? When the game is running and I run this program, nothing shows up in the game. So I start up Spy++ and I go to the edit control under jk2mp winconsole, and it shows up there. I think the command is being typed in the console but not submitted, so the SendMessage WM_CHAR wparam 13 is possibly not working, maybe because in VB it was SendMessageByLong. After looking around the VB source code, I found declarations for the windows messages, could these possibly be customized for the game? (I might be wrong) I've heard that for VB you have to declare these things. Here they are: Code:
If they are, I think I would have to declare WM_SETTEXT is equal to up there. I would like to know what's going on here, I've tried all kinds of error detection things and the FindWindow functions seem to be working, otherwise the text wouldn't end up in the edit control of jk2mp winconsole in Spy++, and yes, that's where they should be, since when someone else says something, it shows up there. It might be that mine isn't being entered correctly. Thanks guys, I hope someone can help. EDIT: The compiler shows a warning about the conversion from LPSTR to LRESULT might lead to loss of data, but it doesn't seem that way in Spy++. |
|
#2
|
|||
|
|||
|
I think you have errors in your VB to C++ conversion.
You forgot assign the return value of FindWindow(..). Your VB version assign it to the jkmpwinconsole. Also the assignment to editx.. so: CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
|
Oh, right, I'm sorry I usually have always done that it's just that after trying different things I guess I did that instead, sorry. This is my code so far, just ignore the MyColor header along witth the MyColor classes, they shouldn't be a problem, those are just to change the text color:
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
|
You are'nt going to use this program for anything evil are you? I hate to imagine what would happen if this program were to somehow end up in an infinite loop.
|
|
#5
|
|||
|
|||
|
The game has a delay between messages, dont worry, even if I could it wouldn't let me send messages that fast, and no, nothing evil. Dont see how something could be evil with chatting, just to send commands to it so it can play music etc. but this is the first step and was really hoping you guys would help out
|
|
#6
|
||||
|
||||
|
Quote:
Since it is generally frouned upon to have 2 returns in a single function unless absolutely necessary, you might consider this as an alternative: CPP / C++ / C Code:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#7
|
|||
|
|||
|
Thanks, I've been staring at the source for a long time now and still dont see what could be wrong. Here's what I have so far, it should send a message to the game:
CPP / C++ / C Code:
|
|
#8
|
|||
|
|||
Re: SendMessage (WinAPI)When I tried
::SendMessage(fwhs.hWndFound, WM_SETTEXT, 0, (LPARAM)buffer); on Notepad it changed the main Title bar from Untitled - Notepad, lol. Looks like WM_SETTEXT will set the window title unless the window has no title like an edit box. |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| yet another winapi problem | ubergeek | CPP / C++ Forum | 7 | 20-Mar-2005 19:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The