C program to press keyboard keys

This is a discussion on C program to press keyboard keys within the Windows Programming forums, part of the Platform Specific Boards category; I want to develop a C program which when double clicked will press both Ctrl+B key combined...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32

    C program to press keyboard keys

    I want to develop a C program which when double clicked will press both Ctrl+B key combined

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    What do you mean by your program being "double clicked"?????

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    A C program cannot press keyboard keys, unless it controls some physical agent (hardware, biological, etc) that performs the physical act.

    If you want a program that can simulate keystrokes as input to another program (i.e. get another program to act as if the user has hit those keys) the techniques depend on your operating system and compiler/library.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    I am using windows xp. I actually wanted a .exe file which when executed will press the keys CTRL+B in the desktop(this key is the boss key of my bittorrent software)

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Pressing ctrl-b will be a lot quicker than fumbling around for an exe file to do the same.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    It would be lot easier but i want it to be done in startup of windows xp

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    That implies you're running bittorrent at startup too. If so, simply start it minimised. No need to have another program do that.

    Of course, if you're trying to conceal your downloading of porn from an employer, hiding bittorrent is not enough. Employers who care to can easily monitor your internet usage without touching your desktop computer, since they have control of the networking infrastructure that your computer connects to.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

  8. #8
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    They seem dumb at that level. But they can check the taskbar. Any way do my problem has any solution "pressing keystroke in windows xp desktop using C function

  9. #9
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    This is something that is actually pretty difficult to find through google and such (at least it was for me when I looked for it a long time ago, took me ages to find).

    Look into Windows Function keybd_event() or get the window handle and SendMessage.

    You'll also have to take into account keyboard focus (in the first method).

    EDIT: As already mentioned by other posters, this is a very unclean way to do it, but it should do the job I guess. If it can be avoided, it should be.
    Last edited by DeadPlanet; 03-25-2010 at 09:46 AM.

  10. #10
    Registered User
    Join Date
    Mar 2010
    Location
    pkr
    Posts
    32
    Thanks
    It is solved for now
    I will try not using these

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Encryption Program (help me please)
    By Arkanos in forum Windows Programming
    Replies: 7
    Last Post: 10-30-2005, 08:01 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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