[Help]Key Press menu

Shout-Out

User Tag List

Results 1 to 7 of 7
  1. #1
    kosacid's Avatar Active Member
    Reputation
    19
    Join Date
    May 2009
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Help]Key Press

    is there a function i can hook because i cant get this to work
    Code:
    void KeyPress(string keys)
    {
    	keybd_event(VK_RETURN,0x9C,0,0);
    	keybd_event(VK_RETURN,0x9C,KEYEVENTF_KEYUP,0);
    	string::iterator iter;
    	for(iter = keys.begin(); iter != keys.end(); iter++)
    	{
    		keybd_event(VkKeyScan(*iter),0,0,0);
    	}
    	keybd_event(VK_RETURN,0x9C,0,0);
    	keybd_event(VK_RETURN,0x9C,KEYEVENTF_KEYUP,0);
    }
    if i remove keybd_event(VK_RETURN,0x9C,KEYEVENTF_KEYUP,0);
    it works but the last enter key dosent and i also end with stuck keys even when i use
    keybd_event(VkKeyScan(*iter),0,0,0);
    keybd_event(VkKeyScan(*iter),0,KEYEVENTF_KEYUP,0);

    [Help]Key Press
  2. #2
    Mr.Sergey's Avatar Contributor
    Reputation
    117
    Join Date
    Apr 2009
    Posts
    201
    Thanks G/R
    6/23
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use PostMessage function:

    PostMessage(hWnd, 0x100, key, 0); // key down
    PostMessage(hWnd, 0x101, key, 0); // key up
    For example, if you need press "A", you should write:
    PostMessage(hWnd, 0x100, 0x41, 0); // A down
    PostMessage(hWnd, 0x101, 0x41, 0); // A up

  3. #3
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Magic numbers are ugly and error prone. And try to read the docs on the required params next time.
    Code:
    #define KEYUP_FLAGS 0xC0000001
    PostMessage(wnd, WM_KEYDOWN, 'A', 0);
    PostMessage(wnd, WM_KEYUP,   'A', KEYUP_FLAGS);

  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)

  5. #5
    kosacid's Avatar Active Member
    Reputation
    19
    Join Date
    May 2009
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got both working i wasent giving the the text box enough time to take the input but here both examples

    Code:
    #define KEYUP_FLAGS 0xC0000001
    void KeyPress(string keys)
    {
    	HWND hwnd = FindWindow(NULL,"World of Warcraft");
    	PostMessage(hwnd,WM_KEYDOWN,VK_RETURN,0);
    	Sleep(30);
    	string::iterator iter;
    	for(iter = keys.begin(); iter != keys.end(); iter++)
    	{
    		PostMessage(hwnd,WM_KEYDOWN,VkKeyScan(*iter),0);
    	    PostMessage(hwnd,WM_KEYUP,VkKeyScan(*iter),KEYUP_FLAGS);
    	}
    	Sleep(30);
    	PostMessage(hwnd,WM_KEYUP,VK_RETURN,KEYUP_FLAGS);
    	PostMessage(hwnd,WM_KEYDOWN,VK_RETURN,0);
    	PostMessage(hwnd,WM_KEYUP,VK_RETURN,KEYUP_FLAGS);
    }
    
    
    void KeyPress(string keys)
    {
    	keybd_event(VK_RETURN,0x9C,0,0);
    	keybd_event(VK_RETURN,0x9C,KEYEVENTF_KEYUP,0);
    	Sleep(30);
    	string::iterator iter;
    	for(iter = keys.begin(); iter != keys.end(); iter++)
    	{
    		keybd_event(VkKeyScan(*iter),0,0,0);
    		keybd_event(VkKeyScan(*iter),0,KEYEVENTF_KEYUP,0);
    	}
    	Sleep(30);
    	keybd_event(VK_RETURN,0x9C,0,0);
    	keybd_event(VK_RETURN,0x9C,KEYEVENTF_KEYUP,0);
    }

  6. #6
    greenegzofyoshi's Avatar Banned
    Reputation
    10
    Join Date
    Jun 2009
    Posts
    23
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't post here often but thank you for the link. Tremendous help. +rep if i can

  7. #7
    Xelper's Avatar ★ Elder ★
    Reputation
    1024
    Join Date
    Mar 2007
    Posts
    860
    Thanks G/R
    0/8
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    C# but whatever, shows an easy way to do it.

    Code:
            [DllImport("user32.dll")]
            static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
    
            public static void KeyPress(Keys Key)
            {
                KeyDown(Key);
                KeyUp(Key);
            }
    
            private static void KeyUp(Keys Key)
            {
                SendMessage(clsMemory.CurrentWindowHandle, (uint)0x101, (int)Key, 0);
                
            }
            private static void KeyDown(Keys Key)
            {
                SendMessage(clsMemory.CurrentWindowHandle, (uint)0x100, (int)Key, 0);
            }
    clsMemory.CurrentWindowHandle is just the hWnd of my WoW process, easy enough to find.

Similar Threads

  1. Bots not passing key presses through to game
    By adamtech in forum Final Fantasy XIV
    Replies: 6
    Last Post: 09-21-2013, 10:54 PM
  2. Key pressing with honorbuddy
    By howardiv in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 11-02-2012, 02:01 PM
  3. Replies: 7
    Last Post: 04-12-2011, 11:01 AM
  4. [Help] Key logger?
    By gothikaboy in forum Programming
    Replies: 12
    Last Post: 09-30-2008, 03:02 PM
All times are GMT -5. The time now is 12:03 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search