[Visual Basic derp] Send keystroke through SendMessage/PostMessage menu

User Tag List

Results 1 to 11 of 11
  1. #1
    myojinyahiko's Avatar Contributor
    Reputation
    106
    Join Date
    Jul 2006
    Posts
    450
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Visual Basic derp] Send keystroke through SendMessage/PostMessage

    Hey guys, I've made a simple program to send a keystroke to WoW for automated DE/Milling/Prospecting for myself and to post here for others.

    Right now I have

    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
        Private Const EM_REPLACESEL = &HC2
    Code:
    sproc = System.Diagnostics.Process.GetProcessById(CB1.SelectedItem)
            SendString = StrokeTB.Text
            WowHwnd = sproc.MainWindowHandle
    Code:
    ret = SendMessage(WowHwnd, EM_REPLACESEL, 0&, SendString)
    I know the process ID is correct, not sure if the parameters are incorrect or if I'm grabbing the wrong handle. Running it works but nothing happens in-game then the stack becomes unbalanced.

    Any ideas? I'm not huge into coding but I have a basic grasp of it. I know I should at least be using C++ but I've never learned it well enough to try to do this.

    If this is a dumb question then let me know and I'll just delete thread =3

    Edit: V 5.1.0 (16357)
    Also not sure if I should move this to Bots Questions forum since this technically isn't memory reading/writing, if anyone thinks that I should move it lemme know and I will.

    Thanks in advance.
    Last edited by myojinyahiko; 02-01-2013 at 09:49 PM.

    [Visual Basic derp] Send keystroke through SendMessage/PostMessage
  2. #2
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u need to use WM_CHAR for each char in your string with SendMessage

  3. #3
    myojinyahiko's Avatar Contributor
    Reputation
    106
    Join Date
    Jul 2006
    Posts
    450
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll look that up now, only going to be one character. Thanks

    Edit: Still not working. =/
    Code:
    Const WM_CHAR = &H102
    Code:
    ret = SendMessage(WowHwnd, WM_CHAR, 45, SendString)
    Pretty sure the WM_CHAR constant is right.

    I'm somewhat confused on parameters though. Was testing this with "-" which is 45 in decimal. I could be doing that all wrong though.

    I'm starting to wonder if the main window handle is what I need to be sending it too, if it isn't I have no clue which child to send it to =3

    Still just getting an unbalanced stack.

    I had tried SendInput a while ago and didn't get any results either. Anyone have any ideas on what I should be trying? Sorry for being so awful =/
    Last edited by myojinyahiko; 02-01-2013 at 11:56 PM.

  4. #4
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The wParam isn't marshaled as string. https://github.com/Bananenbrot/Keybo...sageEmitter.cs and have a closer look at msdn.

  5. #5
    JuJuBoSc's Avatar Banned for scamming CoreCoins Purchaser
    Reputation
    1019
    Join Date
    May 2007
    Posts
    922
    Thanks G/R
    1/3
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    foreach (char c in Text)
                    SendMessage(Memory.WowWindowHandle, WM_CHAR, (uint)c, 0);

  6. #6
    myojinyahiko's Avatar Contributor
    Reputation
    106
    Join Date
    Jul 2006
    Posts
    450
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still running into the same problems. I'm just going to give up for now. Thanks though guys.

  7. #7
    siriuz's Avatar Active Member
    Reputation
    78
    Join Date
    Jun 2009
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should use spy++ to see what happens if you press a specific key

    in example for an space keystroke you have to send something like this:

    Code:
    SendMessage(hWnd, WM_KEYDOWN, VK_SPACE, IntPtr.Zero);
    SendMessage(hWnd, WM_KEYUP, VK_SPACE, IntPtr.Zero);
    Last edited by siriuz; 02-03-2013 at 07:57 PM.

  8. #8
    myojinyahiko's Avatar Contributor
    Reputation
    106
    Join Date
    Jul 2006
    Posts
    450
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by siriuz View Post
    you should use spy++ to see what happens if you press a specific key

    in example for an space keystroke you have to send something like this:

    Code:
    SendMessage(hWnd, WM_KEYDOWN, VK_SPACE, IntPtr.Zero);
    SendMessage(hWnd, WM_KEYUP, VK_SPACE, IntPtr.Zero);
    Spy is showing those lines sending and then receiving WM_NULL then stack unbalances. In game, pressing Q, I get WM_KEYDOWN (wParam 00000051, lParam 00100001), WM_CHAR (wParam 00000051, lParam 00100001), then WM_KEYUP (wParam 00000051, lParam C0100001) all posted rather than sent. Going to try posting those 3 with those parameters to try to emulate that, but still confused why the above two lines were shown as WM_NULL.

    Edit:
    Posting shows nothing on Spy and it is still unbalancing the stack. =/
    Last edited by myojinyahiko; 02-03-2013 at 11:03 PM.

  9. #9
    siriuz's Avatar Active Member
    Reputation
    78
    Join Date
    Jun 2009
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by myojinyahiko View Post
    but still confused why the above two lines were shown as WM_NULL./
    I guess u didn't defined WM_KEYDOWN, WM_KEYUP, VK_SPACE ?

    In C# that would be like:
    Code:
    const int WM_KEYDOWN = 0x100;
    const int WM_KEYUP = 0x101;
    const int VK_SPACE = 0x20;

  10. #10
    myojinyahiko's Avatar Contributor
    Reputation
    106
    Join Date
    Jul 2006
    Posts
    450
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They were defined with what I found on google.

    Code:
    Const WM_KEYUP = &H101
    Const WM_KEYDOWN = &H100
    I defined VK_SPACE correctly too when got the null.

  11. #11
    siriuz's Avatar Active Member
    Reputation
    78
    Join Date
    Jun 2009
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In C# this work like a charm:
    Code:
    [DllImport("user32.dll")]
    private static extern int SendMessage(IntPtr thWnd, int msg, int wParam, IntPtr lParam);
    
    const int WM_KEYDOWN = 0x100;
    const int WM_KEYUP = 0x101;
    const int VK_SPACE = 0x20;
    
    Process[] pr = Process.GetProcessesByName("wow");
    IntPtr hWnd_wow = Process.GetProcessById(pr[0].Id).MainWindowHandle;
    
    SendMessage(hWnd_wow, WM_KEYDOWN, VK_SPACE, IntPtr.Zero);
    SendMessage(hWnd_wow, WM_KEYUP, VK_SPACE, IntPtr.Zero);
    Maybe you can port it ...

Similar Threads

  1. [RELEASE] Visual Basic 2008 Codes
    By EmiloZ in forum Programming
    Replies: 25
    Last Post: 01-03-2009, 06:13 AM
  2. [Program] Visual Basic - Gamecard Generator Scam
    By Y R U A NUB ? in forum WoW Scam Prevention
    Replies: 30
    Last Post: 09-27-2008, 06:04 PM
  3. [AutoIT] Automate Sending Mail through Evil-Page
    By Trauts in forum World of Warcraft Bots and Programs
    Replies: 7
    Last Post: 08-08-2008, 03:01 AM
  4. Sending keystrokes to AoC window in background
    By Ghazban in forum Age of Conan Exploits|Hacks
    Replies: 1
    Last Post: 07-01-2008, 04:18 AM
  5. Visual Basic, I have an idea.
    By WoWLegend in forum World of Warcraft Bots and Programs
    Replies: 14
    Last Post: 11-11-2006, 02:36 PM
All times are GMT -5. The time now is 01:39 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search