wc3edit.net
https://forum.wc3edit.net/

A few questions
http://forum.wc3edit.net/tech-support-f37/a-few-questions-t23543.html
Page 1 of 1

Author:  Durge [ December 13th, 2011, 3:52 am ]
Post subject:  A few questions

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);

Author:  haxorico [ December 13th, 2011, 6:45 pm ]
Post subject:  Re: A few questions

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.)

Author:  owner123 [ December 13th, 2011, 9:49 pm ]
Post subject:  Re: A few questions

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:
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:
SendKeys.Send("{ENTER}");

You can also do that for others like arrow keys, tab, etc.

Author:  Durge [ December 13th, 2011, 10:00 pm ]
Post subject:  Re: A few questions

Ok, that helps, but how would I make an if statement like if player typed <insert text> then send the message

Author:  owner123 [ December 13th, 2011, 11:35 pm ]
Post subject:  Re: A few questions

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.

Author:  Durge [ December 14th, 2011, 12:26 am ]
Post subject:  Re: A few questions

Well its not for WC3, which is why I posted it in tech section, not in a wc3 section :p

Author:  haxorico [ December 14th, 2011, 4:14 pm ]
Post subject:  Re: A few questions

Doesn't matter if it wc3 or not. You still require the data rad from the game.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/