A few questions

Get help with just about anything and everything NOT Warcraft related. Computers, consoles, phones, whatever!
User avatar
Durge
Senior Member
Posts: 199
Joined: April 19th, 2009, 12:46 pm

A few questions

Post by Durge »

Sorry guys, I'm probably being a massive pain in your side, but I always try google before this and search for stuff.
Anyway, I have SendMessage defined and everything, but I can't find a decent example of how to use it in a function.

Someone said to try this, but I'm not sure what to do with it, I'm hoping to use this to send messages into the console of the game im using to execute commands.

EDIT:I want to use this to be able to say commands in the game such as !place and have the utility send a message into the game such as place misc_model_breakable 0 model,map_objects/factory/f_con1,spawnflags,1

so basically, the person says !place and it sends the above command into the game.

Spoiler:
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
Last edited by Durge on December 13th, 2011, 9:37 pm, edited 1 time in total.
ImageImageImage
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: A few questions

Post by haxorico »

ammm what? As before, more explenation would be awesome.
For what I understand, you want either one of two things.

1) You want to have a message displayed to a user in some way, I do think a messagebox is the best way for you (if your making a win32 application)
2) You want to have a command given to the game as it loads, same way it does for a short-cut executer. Like WarCraft for an example. Make a shortcut to the .exe and add -windowed at the end will make the game play in window mod.

P.S: As before I assume you use C#. But seriosly, more info. I am no psychic (don't know about any one else, I'm pretty sure they are not psychic also.)
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: A few questions

Post by owner123 »

First, you're not being a pain. We all signed up for this, we're not being forced to help.
You want to send commands into an external application?
Best way to do this is the SendKeys.Send method.
Here's an example.

Code: Select all

SendKeys.Send("Hello Durge");

This will send the keys "Hello Durge" to the application you have open and focused. It will be just like you typing the keys on the keyboard.
However if you want to send commands to WC3 you need to send new lines too (the return key)
You do this like:

Code: Select all

SendKeys.Send("{ENTER}");

You can also do that for others like arrow keys, tab, etc.
User avatar
Durge
Senior Member
Posts: 199
Joined: April 19th, 2009, 12:46 pm

Re: A few questions

Post by Durge »

Ok, that helps, but how would I make an if statement like if player typed <insert text> then send the message
ImageImageImage
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: A few questions

Post by owner123 »

Um.. I think you would have to read the memory of WC3. I'm not exactly sure how to do it myself, but I can give you the function for reading memory.
Spoiler:
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out] byte[] lpBuffer,
int dwSize,
out int lpNumberOfBytesRead
);

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out, MarshalAs(UnmanagedType.AsAny)] object lpBuffer,
int dwSize,
out int lpNumberOfBytesRead
);

[DllImport("kernel32.dll", SetLastError = true)]
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
IntPtr lpBuffer,
int dwSize,
out int lpNumberOfBytesRead
);

Try to google a tutorial for reading text from WC3. Maybe someone made one.
User avatar
Durge
Senior Member
Posts: 199
Joined: April 19th, 2009, 12:46 pm

Re: A few questions

Post by Durge »

Well its not for WC3, which is why I posted it in tech section, not in a wc3 section :p
ImageImageImage
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: A few questions

Post by haxorico »

Doesn't matter if it wc3 or not. You still require the data rad from the game.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?