Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    winberg's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    70
    Reputation
    14
    Thanks
    14
    My Mood
    Stressed

    aIW|SendCommand from external app

    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:

    Code:
    WriteCommandToConsole("cg_drawFps 1");
    Creditz: me

    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.

  2. The Following 4 Users Say Thank You to winberg For This Useful Post:

    ♪~ ᕕ(ᐛ)ᕗ (08-03-2011),aIW|Convery (09-05-2011),rkaf (08-30-2011),shadowx360 (08-03-2011)

  3. #2
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    amazing, and no need for offsets. +1

  4. #3
    winberg's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    70
    Reputation
    14
    Thanks
    14
    My Mood
    Stressed
    Quote Originally Posted by Huey Freeman View Post
    amazing, and no need for offsets. +1
    Thank you, i am back now

  5. #4
    shadowx360's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    305
    Reputation
    15
    Thanks
    69
    My Mood
    Cynical
    Wow, nice one, definitely some rep + for this.

    Question though, why the double for loops? Doesn't this work?
    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);
    
    }
    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.
    Last edited by shadowx360; 08-03-2011 at 10:09 AM.

  6. #5
    alteriw-norecoil's Avatar
    Join Date
    Jul 2011
    Gender
    male
    Location
    having a threesome with your sister and your mom
    Posts
    23
    Reputation
    7
    Thanks
    11
    My Mood
    Aggressive
    @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.

  7. #6
    winberg's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    70
    Reputation
    14
    Thanks
    14
    My Mood
    Stressed
    Quote Originally Posted by alteriw-norecoil View Post
    @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.
    If you want to follow the syntax rules you should use a LPARAM(long)

  8. #7
    shadowx360's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    305
    Reputation
    15
    Thanks
    69
    My Mood
    Cynical
    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);
    
    }
    Fixed issue in case the hwnd is null.

  9. #8
    winberg's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    70
    Reputation
    14
    Thanks
    14
    My Mood
    Stressed
    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.

  10. The Following User Says Thank You to winberg For This Useful Post:

    shadowx360 (08-04-2011)

  11. #9
    shadowx360's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    305
    Reputation
    15
    Thanks
    69
    My Mood
    Cynical
    And if you're not compiling in Unicode you can just directly cast from char* to LPARAM

  12. #10
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    winberg I think you should put that into the main post. But do not delete the old code, who knows?

  13. #11
    DahInternetz's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    24
    Reputation
    10
    Thanks
    7
    My Mood
    Fine
    I make a .dll file with first codes and join a server inject the .dll file and write second command... Right?


    ------------------------------------------------------



    ------------------------------------------------------

  14. #12
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,667
    My Mood
    Breezy
    Quote Originally Posted by DahInternetz View Post
    I make a .dll file with first codes and join a server inject the .dll file and write second command... Right?
    You don't even need to inject a DLL to use this code.

    Also, the syntax into your signature is wrong.
    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]

  15. #13
    greg123's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    how use this code

  16. #14
    winberg's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    70
    Reputation
    14
    Thanks
    14
    My Mood
    Stressed
    Quote Originally Posted by Huey Freeman View Post
    winberg I think you should put that into the main post. But do not delete the old code, who knows?
    I doesn't seem to be able to edit it should i create a new thread?

    Quote Originally Posted by greg123 View Post
    how use this code
    Do you know any programming language?
    Last edited by winberg; 08-05-2011 at 05:46 AM.

  17. #15
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by winberg View Post
    I doesn't seem to be able to edit it should i create a new thread?



    Do you know any programming language?
    ask @master131 or @Heartview to fix dat.

Page 1 of 2 12 LastLast

Similar Threads

  1. [Release] .NET External BoxESP 1.1 [aIW|Steam]
    By master131 in forum Call of Duty 6 - Modern Warfare 2 (MW2) Hacks
    Replies: 211
    Last Post: 11-06-2011, 10:05 PM
  2. [Solved] Banned From AIW, waited 3 days, still banned??!
    By xZaapz in forum Call of Duty Modern Warfare 2 Help
    Replies: 30
    Last Post: 08-10-2011, 12:19 AM
  3. [Release] WildCatzNet: Official Beta Release! (Banned From aIW? Play Here!)
    By NutriGrain in forum Call of Duty Modern Warfare 2 Private Servers
    Replies: 88
    Last Post: 12-30-2010, 11:44 PM
  4. [Release] aIW External Hacks Patch v2 [1.3.37a]
    By House in forum Call of Duty Modern Warfare 2 Private Servers
    Replies: 173
    Last Post: 12-04-2010, 11:52 AM
  5. [TUT]How to unbanned from aIW
    By Beremix in forum Call of Duty Modern Warfare 2 Tutorials
    Replies: 12
    Last Post: 12-01-2010, 02:35 AM