What Is SendKeys In VB.NET And How To Use It

just thought to write something what will make alot sense so i am gonna explain what is sendkeys() and how to use it
you can use SendKeys() to type words like they are typed from your keyboard

for instance :

add this code to a button click event or any other click events

process.start("notepad")

Sendkeys.Send("Testing 123 123 123)")

what this actually do is , when you click on the button notepad.exe(windows notepad) will open and automatically Testing 123 123 123 will be typed in the notepad

some people use sendkeys() to make bots

for instance :
you have a game and for example lets take mario and you need to press spacebar to jump so you can use this on a timer and it will do it automatically

sendkeys.sendwait("^{ }")

by the way sendkeys() are super fast than we type

you can also use sendkeys() to automatically type in a messenger or a chat box (skype,yahoo messenger,oovoo,msn,etc)

for instance :

add a textbox and add a button and add this code to click event , you should add this namespace imports system.windows.forms

Randomize()
Dim rand As Random
 Dim sendkey As String = "(" + rand.Next(1, 999).ToString + ")" + TextBox1.Text
 SendKeys.Send(sendkey)

type something in the textbox1 and click on the button and see whats happening 

NOTE: do it on your own risk 

you can also use sendkeys() to close programs

to send ASCII value(like pressing alt+045)

Send("{ASC 045}")

to send unicode characters , enter the character code 

for instance :

sending a chinese character

Send("{ASC 2709}")

here is a list from microsoft 

NOTE : put the one you'd like to use in " " because it needs to be a string

BackSpace - {BACKSPACE}, {BS}, or {BKSP}

Break Key - {BREAK}

Caps Lock - {CAPSLOCK}

Delete Key - {DELETE} or {DEL}

Down Arrow - {DOWN}

Right Arrow - {RIGHT}

Up Arrow - {UP}

Left Arrow - {LEFT}

Shift Key - +

Ctrl Key - ^

Alt Key - %

End Key {END}

Enter Key {ENTER} or ~

Escape Key {ESC}

Help Key {HELP}

Home Key {HOME}

Insert Key {INSERT} or {INS}

Num Lock {NUMLOCK}

Page Down Key {PGDN}

Page Up Key{PGUP}

Print Screen Key{PRTSC}

Scroll Lock {SCROLLLOCK}

Tab Key {TAB}

F1 Key - {F1}

F2 Key - {F2}

F3 Key - {F3}

F4 Key - {F4}

F5 Key - {F5}

F6 Key - {F6}

F7 Key - {F7}

F8 Key - {F8}

F9 Key - {F9}

F10 Key {F10}

F11 Key {F11}

F12 Key {F12}

F13 Key {F13}

F14 Key {F14}

F15 Key {F15}

F16 Key {F16}
they can be used in combinations as well :)

Post a Comment

Note: Only a member of this blog may post a comment.