Quantcast

Jump to content

Welcome to GameOn365
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

[VB] SendKeys

- - - - -

  • Please log in to reply
2 replies to this topic

#1
brarei200

brarei200

    Member

  • Members
  • 22 posts
  • :
You can send keyboard keys programming by using "SendKeys", this tutorial is just a quick tutorial since I don't know how to use it that great...

Step 1 - Create a Project
Step 2 - Create a button on your GUI
Step 3 - Double click the button
Step 4 - Type this code below (it opens notepad)

Process.Start("Notepad.exe")

Step 5 - Enter this code below (sends the keys "abcd" to notepad and demostrates how to use non-letter/number keys (like enter, you need to include the brackets {})

SendKeys.Send("abcd")
SendKeys.Send({Enter}) 

Step 6 - Done
Step 7 - This tutorial isn't to useful but there's much more you can do with SendKeys...

#2
SonicXVe Admin

SonicXVe

    Administrator

  • Administrator Admin
  • 19 posts
I would assume SendKeys just sends virtual keystrokes, to no particular application. In this case, on most computers notepad won't open instantly, meaning the sent keystrokes won't be registered by notepad but by the VB application itself or another application. Another issue to consider is if another application takes focus while you're waiting for notepad to open. The best idea here is to send the keystrokes the instant notepad has focus, if possible. I'm more of a C# programmer, but in .NET it should generally all be the same. Just some thoughts for anyone looking to include this in their application!
Gentlemen.

#3
brarei200

brarei200

    Member

  • Members
  • 22 posts
  • :

I would assume SendKeys just sends virtual keystrokes, to no particular application. In this case, on most computers notepad won't open instantly, meaning the sent keystrokes won't be registered by notepad but by the VB application itself or another application. Another issue to consider is if another application takes focus while you're waiting for notepad to open. The best idea here is to send the keystrokes the instant notepad has focus, if possible. I'm more of a C# programmer, but in .NET it should generally all be the same. Just some thoughts for anyone looking to include this in their application!


Yeah, your best bet would be to use timers. One timer to open it, after the timer runs, notepad should be open, then run the next timer and send the keys :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users