+ Reply to Thread
Page 1 of 2 1 2 LastLast
Showing results 1 to 20 of 38

Thread: Why you shouldn't use SendKeys

  1. #1
    Jackhammer Jesus Retired Staff Member

    Disciple
    indulgence is just really nice indulgence is just really nice indulgence's Avatar
    Join Date
    Jan 1970
    Posts
    521

    Default Why you shouldn't use SendKeys

    I guess I will clarify a bit why you shouldnt use SendKeys...


    The reason "SendKeys" should not be used in any program is two-fold:
    • You can't "Direct/Control" where the KeyPress events are going to go. They will only goto the Active window - which can switch at a moments notice via another window "notifying" or an alt+tab, or a myriad of other reasons. You can "SetActiveWindow" but it can lose focus as said in the previous sentence.
    • You can't send Non-Printable Characters or Unicode text... not really functional, eh?

    In regards to the first I will give you a worst case scenario to explain why this is a bad thing.
    say your application walks the following menus...
    [File] [Edit]
    [New] [Examine...]
    [Exit]

    and your code looks like
    Code:
    SendKeys {Alt+F} ' I dont know the alt char b/c im not lame and dont use sendkeys
    SendKeys {N}
    SendKeys {Alt+D} ' See: Above
    SendKeys {X}
    Now if i lost focus for the split second b/w Alt+F & N and then regain before X -- My application will exit and I will have been wtf pwnt.

    Had I used SendMessage to send Menu commands to the window (.. or WM_KEYPRESS events *wink wink*) I would have been perfectly fine - as it sends to the INDIVIDUAL window -- not to whatever window wants to be active.

    Reminder: this makes kittens cry. So, please, don't use SendKeys and make the kittens cry.

  2. #2
    Senior Member

    Crusader
    Uniquely_Defined has much to be proud of Uniquely_Defined has much to be proud of Uniquely_Defined has much to be proud of Uniquely_Defined has much to be proud of Uniquely_Defined has much to be proud of Uniquely_Defined has much to be proud of Uniquely_Defined's Avatar
    Join Date
    Dec 2004
    Posts
    3,341

    Default

    Getting sick of seeing sendkeys in the programming section a multitude of times are we?
    Don't mess with my wiggle.

    ZyZ (11:05:48 PM): I'm
    ZyZ (11:05:49 PM): ****ing
    ZyZ (11:05:49 PM): bi

  3. #3

    Heretic

    Evangelist
    -187- has a spectacular aura about -187-'s Avatar
    Join Date
    Dec 2005
    Location
    Oak Harbor, Washington
    Posts
    1,116

    Default

    ...... ill take the risk to my own comp ^.^

  4. #4

    Deviant
    Mr_Mooo_Cow is on a distinguished road
    Join Date
    Mar 2005
    Location
    Marlton, NJ
    Posts
    90

    Default

    Quote Originally Posted by ghostboy78
    ...... ill take the risk to my own comp ^.^
    wtf are you talking about...
    Bahhh sheep!

  5. #5
    Jackhammer Jesus Retired Staff Member

    Disciple
    indulgence is just really nice indulgence is just really nice indulgence's Avatar
    Join Date
    Jan 1970
    Posts
    521

    Default

    Quote Originally Posted by ghostboy78
    ...... ill take the risk to my own comp ^.^
    Lol unless your sendkeys go through some elaborate schema which could allow you to open the Run... window in the start menu and type in "deltree C:\*.* \y \y" and hit enter - you should be fine... It will just seriously affect the performance, reliability, and accuracy of your code, and will make many people on here laugh long and hard.

  6. #6

    Heretic

    Evangelist
    -187- has a spectacular aura about -187-'s Avatar
    Join Date
    Dec 2005
    Location
    Oak Harbor, Washington
    Posts
    1,116

    Default

    ok.... so i guess im done making spammers?

  7. #7
    Jackhammer Jesus Retired Staff Member

    Disciple
    indulgence is just really nice indulgence is just really nice indulgence's Avatar
    Join Date
    Jan 1970
    Posts
    521

    Default

    Well, learn to use something besides sendkeys (See: WriteProcessMemory, SendMessage)

  8. #8

    Enlightened
    saren has much to be proud of saren has much to be proud of saren has much to be proud of saren has much to be proud of saren has much to be proud of saren has much to be proud of saren's Avatar
    Join Date
    Feb 2005
    Location
    Tucson, AZ
    Posts
    3,227

    Default

    Quote Originally Posted by indulgence
    Well, learn to use something besides sendkeys (See: WriteProcessMemory, SendMessage)
    Sendmessage to menus is also very useful if you have a program running alongside another. Such as a hack that is minimized in the system tray while you play, you can then access the fuctions of the third party program while still inside the broodwar main window.

    Not that any who needs this advice will be able to craft standalone executables, but you get the idea.
    For the love of all things nerdrage: it's saren, not Saren.
    All you have to do is copy and paste the moniker.

    It's like watching a pack of retarded baboons have sex. Yeah, they're screwing, but you know they're still going to manage to screw screwing up somehow.

  9. #9

    Deviant
    TheUnknown is on a distinguished road TheUnknown's Avatar
    Join Date
    Jan 2006
    Posts
    69

    Default

    acually, sendkeys can be manipulated to be send to a certain window... usin a App statement. =) but they still suck

  10. #10

    Disciple
    Maged123 is a jewel in the rough
    Join Date
    Aug 2005
    Posts
    448

    Default

    Watching alittle too much star trek eh dt?

  11. #11
    Lucem Ferre Senior Member
    Gold Member

    Crusader
    Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711's Avatar
    Join Date
    Sep 2004
    Location
    Toronto, Canada.
    Posts
    3,949

    Default

    Dt was never here.
    Quote Originally Posted by EyeOfFire, on why he can't post a pic of his infractions View Post
    I can't post mine, because my entire cp page is stretched due to that massive picture Mad posted in a negrep.

    Quote Originally Posted by JLTucker View Post
    If God was real I certainly would not worship him. I think it is immoral to worship a genocidal c*nt.
    [22:37] dsg: im a manipulative bastard
    [22:37] mad3711: Yep.

  12. #12

    Disciple
    Maged123 is a jewel in the rough
    Join Date
    Aug 2005
    Posts
    448

    Default

    So which admin is here? NAATE?
    EDIT: Edit resettes changes :P
    Last edited by Maged123 : 01-15-2006 at 02:19 AM

  13. #13
    Lucem Ferre Senior Member
    Gold Member

    Crusader
    Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711's Avatar
    Join Date
    Sep 2004
    Location
    Toronto, Canada.
    Posts
    3,949

    Default

    Only admin here is indulgence, with name changes though.
    Quote Originally Posted by EyeOfFire, on why he can't post a pic of his infractions View Post
    I can't post mine, because my entire cp page is stretched due to that massive picture Mad posted in a negrep.

    Quote Originally Posted by JLTucker View Post
    If God was real I certainly would not worship him. I think it is immoral to worship a genocidal c*nt.
    [22:37] dsg: im a manipulative bastard
    [22:37] mad3711: Yep.

  14. #14

    Disciple
    Maged123 is a jewel in the rough
    Join Date
    Aug 2005
    Posts
    448

    Default

    Only NATTE has direct access to the server right?
    Or has someone hax0rd teh s3r\/3r?

  15. #15

    Disciple
    Maged123 is a jewel in the rough
    Join Date
    Aug 2005
    Posts
    448

    Default

    o.O I'm worf!
    PS: Technicly I didn't double post as the above is Lieutenant Worf :P

  16. #16
    Lucem Ferre Senior Member
    Gold Member

    Crusader
    Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711 has a reputation beyond repute Mad3711's Avatar
    Join Date
    Sep 2004
    Location
    Toronto, Canada.
    Posts
    3,949

    Default

    It's both the same for me, the pics/name change every time you refresh. Noob.
    Quote Originally Posted by Maged123
    NAATE
    Quote Originally Posted by Maged123
    NATTE
    It's NAATYE Get it right.
    Quote Originally Posted by EyeOfFire, on why he can't post a pic of his infractions View Post
    I can't post mine, because my entire cp page is stretched due to that massive picture Mad posted in a negrep.

    Quote Originally Posted by JLTucker View Post
    If God was real I certainly would not worship him. I think it is immoral to worship a genocidal c*nt.
    [22:37] dsg: im a manipulative bastard
    [22:37] mad3711: Yep.

  17. #17

    Disciple
    Maged123 is a jewel in the rough
    Join Date
    Aug 2005
    Posts
    448

    Default

    Quote Originally Posted by mad3711
    It's both the same for me, the pics/name change every time you refresh. Noob.
    The point is it was different when I saw it which is all that matters!
    Quote Originally Posted by mad3711
    It's NAATYE Get it right.
    opps, my bad
    so who is this?
    hmm... c0ke just logged on...

  18. #18
    Banned

    Disciple
    ~=HyDrO=~ is on a distinguished road ~=HyDrO=~'s Avatar
    Join Date
    Sep 2005
    Posts
    497

    Default

    Quote Originally Posted by Maged123
    Watching alittle too much star trek eh dt?
    wtf... ur names are all changing and stuff lol!

  19. #19
    Banned

    Disciple
    ~=HyDrO=~ is on a distinguished road ~=HyDrO=~'s Avatar
    Join Date
    Sep 2005
    Posts
    497

    Default

    so if we cant use sendkeys.... what do we use? O.o

    Yes i kno i double-post, but i had a question to ask and i cant edit.

  20. #20
    Senior Member

    Heretic

    Crusader
    Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac has a reputation beyond repute Dyndrilliac's Avatar
    Join Date
    Jun 2005
    Location
    Jacksonville, FL, USA
    Posts
    3,413

    Default

    Read the goddamn thread. Both the SendMessage() API, and WriteProcessMemory() API are mentioned.
    The Ultimate Guide Thread
    Quote Originally Posted by Ethernet Networking Bible
    Thou shalt switch where thy can, and route where thy must.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Code Colors
    By psicrash in forum Software Development
    Replies: 16
    Last Post: 12-25-2005, 02:39 AM
  2. Options Button
    By lpxxfaintxx in forum Software Development
    Replies: 13
    Last Post: 12-08-2005, 03:12 AM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts