Sending keystrokes

This is a discussion on Sending keystrokes within the C++ Programming forums, part of the General Programming Boards category; Hey, and thanks for your help in advance. What I want to do is send specific keystrokes to the system ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    16

    Sending keystrokes

    Hey, and thanks for your help in advance. What I want to do is send specific keystrokes to the system at certain times, kind of like a macro. As in, I want to run this program and have it "press" the ALT+F keys, or whatever. You get the idea. Moving the mouse would be cool, too, but not necessary. Can anyone help me out? Thanks again.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    what are you trying to make? some kind of virus?
    Away.

  3. #3
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    what operating system?
    Monday - what a way to spend a seventh of your life

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    50
    Talking about virus.. is it posible to create a virus using c++??
    (it's not what ur thinking, I am way too noob to create a virus anyway) Anyway, it would be fun to make somkindof program with opens automatically on startup or some keypress. Just to trick my brother!
    I dont know half as many of you half as well as I should like, and I like less than half of you half as well as you deserve...

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    1

    Post

    U can make a TSR (Terminate and stay resident program)
    It resides in memory after terminating until u reboot the system.

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    42

    I Think yea

    Yo FromHolland...

    I think yea, you can make a virus in C++
    Since most viruses are written in C, you can make a better virus in C++

    Once you become a pro in programming, making a virus will be so easy to you...

    You wouldn't risk losing your job for harming people you don't know..

    That's why no more than 20-80 viruses are made each day!
    I have a code which stops life!

  7. #7
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Dunno why I'm saying this, but you couldn't make a 'better' virus in C++ than C - more object oriented or generic perhaps.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  8. #8
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    a virus can be written in virtusally any language, how good it is depends on the programmers ability not the language. remember for everything you can think of to code, there are probably several hundred code application to solve it.

    And rememver : its not a virus (by definition) unless it self-replicates
    Monday - what a way to spend a seventh of your life

  9. #9
    _Elixia_
    Guest

    Re: Sending keystrokes

    Originally posted by nate11000
    Hey, and thanks for your help in advance. What I want to do is send specific keystrokes to the system at certain times, kind of like a macro. As in, I want to run this program and have it "press" the ALT+F keys, or whatever. You get the idea. Moving the mouse would be cool, too, but not necessary. Can anyone help me out? Thanks again.
    If your using Windows, then look into the SendInput function, which works for both mouse and keyboard. Here's an example:

    Code:
       INPUT i;
       i.type = INPUT_KEYBOARD;
       i.ki.wVk = 0; /* virtual key code goes here, or 0 if none */
       i.ki.wScan = 0x50; /* scan code goes here, 0 if none */
       i.ki.dwFlags = KEYEVENTF_SCANCODE; /* flags */
       i.ki.dwFlags = 0; /* more flags */
       i.ki.time = 0; /* time of keypress, 0 = now */
       i.ki.dwExtraInfo = NULL;
       SendInput (1, &i, sizeof(INPUT));

  10. #10
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    Doh! Ignore the line "i.ki.dwFlags = 0;". Ripped the code from one of my programs (modifies the way in which my "internet ready keyboard" works by remapping all the useless internet keys into useful functions)

    Think I'll register now too.

  11. #11
    Registered User
    Join Date
    Apr 2003
    Posts
    50

    Run on Startup

    Now I still don't know how to get my program to run on startup..
    It just has to be a text message wich appears when windows is opening.

    I (actually it's us, cuz the computer is not mine but also my brothers and my dad uses it etc..) use windows XP, and all user's have their own profile, but sometimes my (little)brother changes the password of my account so he can have acces to my files.. That's why I want this text message to appear!
    I dont know half as many of you half as well as I should like, and I like less than half of you half as well as you deserve...

  12. #12
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    To load on startup, you can a) place something in the Startup folder (in the Start menu), or b) tell your computer to start it automatically through the registry (HKEY_CURRENT_USER \ Software \ Run or HKEY_LOCAL_MACHINE \ Software \ Run, I think).
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  13. #13
    Registered User
    Join Date
    Jun 2003
    Posts
    7
    Originally posted by iain
    a virus can be written in virtusally any language, how good it is depends on the programmers ability not the language. remember for everything you can think of to code, there are probably several hundred code application to solve it.

    And rememver : its not a virus (by definition) unless it self-replicates
    It also depends on the compiler, as some have weaknesses and strengths, if your on one that has certain strengths and most of the headers, components, etc the programmer could build a deadly virus. It really doesn't matter since everything is compiled into binary anyways, so the end result is the same, whether it be Visual Basic, C, C++, Dephi, Pascal (I think), etc.

    However the only thing is the Compiler, as different compilers use different engines.

  14. #14
    Registered User
    Join Date
    Feb 2002
    Posts
    16

    thanks Elixia

    Thank you elixia for the sendinput function, i will check it out. This is NOT for a virus and I don't know how this whole thread turned into that... but anyway

  15. #15
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> my (little)brother changes the password of my account

    Sounds like the accounts are set up with administrator privilige. That being the case, change both your own and his, then he will not be able to change yours.

    If someone in my house changed my password, (they wouldn't but if), I would retaliate at the nuclear level, wipe him for example. That is just not done. You have a personal/personnel problem there - sort that out before resorting to silly tricks.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending keystrokes to another view
    By azeemanwer in forum C++ Programming
    Replies: 2
    Last Post: 08-28-2007, 11:41 AM
  2. sending a string as keyboard keystrokes wrongly
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 06-29-2007, 08:49 AM
  3. Sending keystrokes
    By chris1985 in forum Windows Programming
    Replies: 4
    Last Post: 12-20-2004, 01:26 PM
  4. Sending Keystrokes
    By evilmonkey in forum C++ Programming
    Replies: 1
    Last Post: 01-31-2002, 01:18 PM
  5. Sending keystrokes to window?(PLEASE ANSWER!)
    By SyntaxBubble in forum Windows Programming
    Replies: 5
    Last Post: 11-24-2001, 09:28 AM

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