simulating key with c++

This is a discussion on simulating key with c++ within the C++ Programming forums, part of the General Programming Boards category; Hi I need help with the use of doing simulating key press. I've been to MSDN and seen what they ...

  1. #1
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155

    simulating key with c++

    Hi I need help with the use of doing simulating key press. I've been to MSDN and seen what they said about it, but I dont fully get it what they are showing me. I know this sites good at showing/telling the use of code so I am hoping.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    getch()

    Here is a few example programs of it's use by moi.
    Sent from my iPadŽ

  3. #3
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Thanks i'll take a look at thes.

    Oh... no this is not what I am talking about. Thes see what you type then echo it back. What I want to do is simulat a keypress like a marco with my programe, so that it types out on other programs also.
    Last edited by adr; 12-24-2005 at 01:14 PM.

  4. #4
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    On Windows, something like this:

    Code:
    keybd_event( VK_RETURN, 0, 0, 0 );
    keybd_event( VK_RETURN, 0, KEYEVENTF_KEYUP, 0 );
    ?

    keybd_event
    On NT, 2000, and XP, you're supposed to use SendInput function, but I never could figure out how to use it.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  5. #5
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Ya I seen that used but I cant figer it out my self. Trying to understand it with NSMD but their way of showing is a little not thereXD.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    How about google?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    LOL, yes, I did try that. I also try yahoo. I dont get much help on thos that great.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You're trying to figure out how SendInput works?

    Try searching this board: http://cboard.cprogramming.com/searc...earchid=289138.

    [edit]
    Maybe codeplug's links at the end of this thread.
    [/edit]
    Last edited by dwks; 12-24-2005 at 01:46 PM.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    LOL goo thinkingXD i'm looking at like 20 websits for thisXD My head isnt thinking very good.

    Ok I found some new stuff on it and that I get with more working with the code. I'll check it out how ppl are setting it up on theirs and try to work with it for my use. Thanks^.^
    Last edited by adr; 12-24-2005 at 02:05 PM.

  10. #10
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Hi again, sorry I didnt want to make another post on this seeing as its the same thing as befor. Ok i've been almost everwhere trying to learn this I mean I dont have a problem LOL, but i've seem some differnt ways on how to simulate a key pressing. Like keybd_event() I can get this one, i've also seen SendInput(), SendMessage() and PostSendMessage () ,or something like that. I didnt see on much like how to use them tho, what I mean is, go in detail on them mostly. Yes i've look them up, but I had no luck on it much for how to use them. I was just asking if maybe someone could help me on the details a little on them or maybe make a little examples on them so I can see how to use them mostly.

    For keybd_event() I got this working ok.
    Code:
    	keybd_event(0x53,
    	0,
    	0,
    	0);
    	keybd_event(0x53,
    	0,
    	KEYEVENTF_KEYUP,
    	0);
    It simulates a "s" key, but even then I dont know much on whats going on in it. I do get most of it, like the top part is pressing the key then the botten part "un"press the key. The 0's I dont know much on tho. Sorry I dont mean to ask something so hug, I just like understand what something does befor using it really.
    Last edited by adr; 01-02-2006 at 03:35 PM.

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