By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Trying to SendKeys when someone presses "F" with VB08

P: 30
I was experimenting around and tried to make it so that if someone presses the F key on their keyboard it also sends the rest of the letters to complete F*** anytime someone presses that letter... I know it's cruel but I just want to mess around with my friend and send it to him, hahaha... I know that the 32 to 128 is wrong, but I dont know what the # for F is.... It's probably more messed up than just that so someone please help me!


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private Declare Function GetKeyState Lib "user32" (ByVal vKey As Integer) As Integer
  3.     Dim Result As Integer
  4.     Dim i As Double
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.         For i = 32 To 128
  7.             Result = GetKeyState(i)
  8.             If Result = -32767 Then
  9.                 SendKeys.Send("UCK")
  10.             End If
  11.         Next i
  12.     End Sub
  13. End Class
Jan 31 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
If you want to know the code for "F", you can either look it up in the doco, or ask VB. Do a KeyDown or KeyPress event procedure, and tell it to display the value. Then run the form, and see what is displayed.

I don't know which value you'd need, because I don't know whether that API call requires an ASCII code or keycode.
Feb 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.