♪~ ᕕ(ᐛ)ᕗ (08-03-2011),aIW|Convery (09-05-2011),rkaf (08-30-2011),shadowx360 (08-03-2011)
Code:void WriteCommandToConsole(string Command) { HWND hwnd = FindWindow(NULL,L"aIW Console"); HWND childHwnd = FindWindowEx(hwnd,NULL,L"Edit",NULL); const int Lenght = Command.length(); char cCommand[Lenght]; for(int i = 0; i < Command.size();i++) { cCommand[i] = Command.at(i); } for(int i = 0,inInt; i < Command.size(); i++) { inInt = cCommand[i]; SendMessage(childHwnd,WM_CHAR,inInt,true); } SendMessage(childHwnd,WM_CHAR,VK_RETURN,true); }
Usage:
Creditz: meCode:WriteCommandToConsole("cg_drawFps 1");
Enjoy
I found out a good type cast so here is a improved version:
Code:void SendCommand(LPCTSTR Command) { static HWND editBox = FindWindowEx(FindWindow(NULL, L"aIW Console"),0,L"Edit",0); if(editBox == NULL) return; else { SendMessage(editBox,WM_SETTEXT,0,(LPARAM)((LPCTSTR)Command)); SendMessage(editBox,WM_CHAR,VK_RETURN,0); } }
Last edited by Heartview; 08-05-2011 at 09:06 AM.
♪~ ᕕ(ᐛ)ᕗ (08-03-2011),aIW|Convery (09-05-2011),rkaf (08-30-2011),shadowx360 (08-03-2011)
amazing, and no need for offsets. +1
Wow, nice one, definitely some rep + for this.
Question though, why the double for loops? Doesn't this work?
Optimizations: Shorts instead of ints as messages are never 2.1 billion in length, changed i++ to ++i to make use of the INC instruction instead of the ADD instruction in assembly, instead of calling command.length() every loop (I learned that it actually checks the length every single loop and ends up slowing down the loops when I was learning PHP), and straight casting into int instead of using a temporary int holder. The handle to Edit is only initialized once as it's static, since the window handle shouldn't change between writes.Code:void WriteCommandToConsole(string Command) { static HWND childHwnd = FindWindowEx(FindWindow(NULL,L"aIW Console"),NULL,L"Edit",NULL); short length = Command.length(); for(short i = 0; i < length; ++i) { SendMessage(childHwnd,WM_CHAR,(int)Command.at(i),true); } SendMessage(childHwnd,WM_CHAR,VK_RETURN,true); }
Last edited by shadowx360; 08-03-2011 at 10:09 AM.
@shadowx360 You can use an unsigned short because i is never negative. You should also beware that if you call this function before the console is open, it will not work.
Fixed issue in case the hwnd is null.Code:void WriteCommandToConsole(string Command) { static HWND childHwnd = FindWindowEx(FindWindow(NULL,L"aIW Console"),NULL,L"Edit",NULL); if(childHwnd == NULL) { childHwnd = FindWindowEx(FindWindow(NULL,L"aIW Console"),NULL,L"Edit",NULL); if(childHwnd == NULL) return; } short length = Command.length(); for(short i = 0; i < length; ++i) { SendMessage(childHwnd,WM_CHAR,(int)Command.at(i),true); } SendMessage(childHwnd,WM_CHAR,VK_RETURN,true); }
I found out a good type cast so here is a improved version:
Code:void SendCommand(LPCTSTR Command) { static HWND editBox = FindWindowEx(FindWindow(NULL, L"aIW Console"),0,L"Edit",0); if(editBox == NULL) return; else { SendMessage(editBox,WM_SETTEXT,0,(LPARAM)((LPCTSTR)Command)); SendMessage(editBox,WM_CHAR,VK_RETURN,0); } }
Last edited by winberg; 08-04-2011 at 10:37 AM.
shadowx360 (08-04-2011)
And if you're not compiling in Unicode you can just directly cast from char* to LPARAM
winberg I think you should put that into the main post. But do not delete the old code, who knows?
I make a .dll file with first codes and join a server inject the .dll file and write second command... Right?
------------------------------------------------------
------------------------------------------------------
Donate:
BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9
Handy Tools/Hacks:
Extreme Injector v3.7.3
A powerful and advanced injector in a simple GUI.
Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!
Minion Since: 13th January 2011
Moderator Since: 6th May 2011
Global Moderator Since: 29th April 2012
Super User/Unknown Since: 23rd July 2013
'Game Hacking' Team Since: 30th July 2013
--My Art--
[Roxas - Pixel Art, WIP]
[Natsu - Drawn]
[Natsu - Coloured]
All drawings are coloured using Photoshop.
--Gifts--
[Kyle]