ItsMods

Full Version: Read from console rcon in Delphi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
var
Pai,txtbox,console:HWND;
s:array[0..63] of Char;
begin
Pai:=FindWindow(nil,'Call of Duty: Modern Warfare 3 Multiplayer');
txtbox:=FindWindowEx(Pai,0,'Edit',nil);
console:=FindWindowEx(Pai,txtbox,'Edit',nil);
SendMessage(console,WM_GETTEXT,63,Integer(@s));
Edit1.Text:=StrPas(s);

what did I do wrong?
delphi? wtf
Delphi 7, whats wrong with using delphi?
I asked, send pm, not responded.
(11-30-2012, 01:41)richard1994x Wrote: [ -> ]I asked, send pm, not responded.

Just wait, he will respond asap.

Thanks Barata...
I used a pointer to get the console window. I think I shared the code several times here.
http://www.itsmods.com/forum/Thread-Help...3#pid85743

You need the pointer though, I got it from @Nukem , not sure how he got it, perhaps I could get it myself but no idea.
I think barata's tool gives it. Not sure.
You probably don't have to rely on the parent HWND pointer in order to read the console. What you posted should work (I am not farmilar with Delphi, but the parameters seem OK). Instead of relying on the window title, try using the window class name.

Code:
Pai:=FindWindow('IW5 WinConsole', nil);

EDIT - Just tested it in C# externally without using that pointer, worked fine.
Just a few pages back and you get an exactly same thread
CSHARP Code
  1. unsafe string MW3Console
  2. {
  3. get
  4. {
  5. IntPtr form = FindWindow("IW5 WinConsole", "Call of Duty: Modern Warfare 3 Dedicated Server");
  6. IntPtr txtbox = FindWindowEx(form,IntPtr.Zero,"Edit",null);
  7. IntPtr console = FindWindowEx(form, txtbox, "Edit", null);
  8. StringBuilder sb = new StringBuilder(9999999);
  9. int result = SendMessageTimeout(
  10. console,
  11. 0x0D /*WM_GETTEXT*/,
  12. 9999999,
  13. sb,
  14. 10 /*SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG*/,
  15. 500,
  16. IntPtr.Zero);
  17. return sb.ToString();
  18. }
  19. }
  20.  
  21. [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Ansi)]
  22. public static extern IntPtr FindWindow(string className, string windowName);
  23. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
  24. public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
  25.  
  26. [DllImport("User32.dll", SetLastError = true)]
  27. public static extern int SendMessageTimeout(
  28. IntPtr hWnd,
  29. uint uMsg,
  30. uint wParam,
  31. StringBuilder lParam,
  32. uint fuFlags,
  33. uint uTimeout,
  34. IntPtr lpdwResult);

Should work for all versions
Guys, i found the error, i need create a program "RCON Advanced" for facilitate manipulation the administration for ADMIN's.

This code above is work for iw5mp_server.exe, i need code for iw5mp.exe, i try this code but not work, the game is protected with function FindWindowEx?

Code:
var
Pai,txtbox,console:HWND;
s:array[0..63] of Char;
begin
Pai:=FindWindow('IW5','Call of Duty: Modern Warfare 3 Multiplayer');
txtbox:=FindWindowEx(Pai,0,'Edit',nil);
console:=FindWindowEx(Pai,txtbox,'Edit',nil);
SendMessage(console,WM_GETTEXT,63,Integer(@s));
Edit1.Text:=StrPas(s);

i need help, i don't speak english, so sorry with for any inconvenience.

Thanks in advance.

Richard Alexander.