ItsMods

Full Version: Reading from console
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to read the console output from a script?
Probably but why would you need that?
My external rcon plugin
It's possible, Mine was able to do it.
You need to get the window offset and need to use some windows api functions though
i am able to read the last used command in black ops console so its possible (commands like, +melee -melee or even dvars)
it was just some address
0x03536C5C for black ops, i will try to update this post if i find it for mw3

EDIT: cant find. Sad
I don't understand this offset thing can you tell me how to do this?
CSHARP Code
  1. unsafe string MW3Console
  2. {
  3. get
  4. {
  5. IntPtr form = *(IntPtr*)0x5933A50;
  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);


The offset (line 5) is outdated and I got it from nukem.
I think (but not entirely sure) that barata's tool can tell you what it is.
This worked for me
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);