Help me with PostMessage to send ALT+Key

This is a discussion on Help me with PostMessage to send ALT+Key within the Windows Programming forums, part of the Platform Specific Boards category; I have try many way but nothing happen, look some of my code below: PostMessage (windowHandle, WM_SYSKEYDOWN , VK_MENU, 1); ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Help me with PostMessage to send ALT+Key

    I have try many way but nothing happen, look some of my code below:

    PostMessage (windowHandle, WM_SYSKEYDOWN , VK_MENU, 1);
    PostMessage (windowHandle, WM_KEYDOWN, 0x33, 0 );
    PostMessage (windowHandle, WM_KEYUP, 0x33, 0 );
    PostMessage (windowHandle, WM_SYSKEYUP, VK_MENU, 0 );


    I want to send ALT+3 to the handle.
    Someone can help me pls. Thank you

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Use SendMessage() instead. Also, there are several messages that programs use to recieve keypresses. Depending ont the programmers choice, you may just be choosing the wrong ones.

    Also, you shoul dbe settign bit 29 on the keycode, not sending alt key presses.

    Code:
    SendMessage (windowHandle, WM_KEYDOWN, 0x20000033, 0 );
    
    SendMessage (windowHandle, WM_KEYUP, 0x20000033, 0 );
    Last edited by abachler; 03-17-2008 at 01:38 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    9
    I try with your code but my destination program got crash something worng, can you check it pls
    By the way

    Can you tell me, how can found this value >>>0x20000033
    ex: if I want send another Message like: Alt - 4 or Alt - 5 ...
    Thank you

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Moved to Windows programming.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by meokhung1980 View Post
    I try with your code but my destination program got crash something worng, can you check it pls
    By the way

    Can you tell me, how can found this value >>>0x20000033
    ex: if I want send another Message like: Alt - 4 or Alt - 5 ...
    Thank you
    As I stated, you have to set bit 29 for the Msg to indicate that the alt key was held down when the key was pressed. 2^29 = 0x20000000

    What program are you trying to send the message to?
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  6. #6
    Registered User
    Join Date
    Mar 2008
    Posts
    9
    Iam write auto pot for the game The Perfect World at add: www.thegioihoanmy.vn (my country server)

    In game have function can controler with Alt - 2 to 5 send command attack to Pet to kill monster.



    By the way, i continued got crash.

    or why dont use SYSKEYDOWN replace to KEYDOWN ?

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Most games check against GetAsyncKeyState() to make sure the real key is actually pressed. They do this specifically to thwart macro farming. The error you get may be intentional or an artifact. You can however use keybd_event(), this may work better.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Have you tried using SendInput? Here is a link to some sample code.

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    ooo, that looks dreamy Gonna write my own macro miner now Its a sad day when it becomes cheaper to write a custom app than hire a village in the third world to work ina gaming sweatshiop
    Last edited by abachler; 03-19-2008 at 01:41 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #10
    Registered User
    Join Date
    Mar 2008
    Posts
    9
    I cant use SendInput because my game run underground ( because my boss check alway when i working, i cant play game ^^) and SendInput must be actvive window and focus it (or i wrong?)

    Now my app can send any key but cant send keychoke (Alt + key) and big problem is in game have very important func must call and it use keychoke to call >.< someone help me

    @abachler : Can you give me sample code to send ALT+KEY use keybd_event()?
    maybe it'll work.


    Thank you

  11. #11
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    No, keybd_event() is depreciated -- use SendInput() instead.

    Sounds like,
    A. you're trying to write a 'hack' or some sort of 'bot', OR
    B. you're being sneaky

    Either way, I don't think it's in your best interest to do either. If your boss checks on you while you're 'working' then you should be working!

    If the game is out of focus it probably is going to ignore all input anyway (if it's a bigish game).

  12. #12
    Registered User
    Join Date
    Mar 2008
    Posts
    9
    Quote Originally Posted by zacs7 View Post
    No, keybd_event() is depreciated -- use SendInput() instead.

    Sounds like,
    A. you're trying to write a 'hack' or some sort of 'bot', OR
    B. you're being sneaky

    Either way, I don't think it's in your best interest to do either. If your boss checks on you while you're 'working' then you should be working!

    If the game is out of focus it probably is going to ignore all input anyway (if it's a bigish game).
    Thank your of ur "advisory ", but if you play that game, you will understand its possession attractive force..
    When I say game run underground mean that it run "hidden ", during Post/SendMessage can sends "signal" and SendInput() will impossibly.

    Very please if someone can help me slover this problem (send keychoke to the handle like Alt+Key or Shift+key).

    Thank you !

    PS to zacs7 :: yes, that is a auto pot (so hard to get lv when you had high level)
    Last edited by meokhung1980; 03-20-2008 at 12:46 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21