Free Games Forum
Free Games Games Forums Music Forums TV Forums

  Free Games Forum Home FORUM
HOME
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN
Rules & FAQ RULES / FAQ
REPORT SPAM

Free Games Forum: Game Technology: Visual Basic / VB:
Type on KeyPress

 

 


compwiz3000
Newbie

May 15, 2006, 2:08 AM

Post #1 of 8 (639 views)
Shortcut
Type on KeyPress Can't Post

How do I make a function in VB .NET (2005) so that upon a keypress (like F2), an autotyper starts? Like, the autotyper starts typing? I want to use a keypress instead of pressing a "start" button with the mouse button.



Jaymzanator
Enthusiast


May 16, 2006, 1:06 AM

Post #2 of 8 (630 views)
Shortcut
Re: [compwiz3000] Type on KeyPress [In reply to] Can't Post


Code
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDownOn Error GoTo errorhandler 'this links it to an error handler - if you dont have one try "on error resume next" 
If keycode = keys.F12 Then
button1_click 'where button1 is your start button
else:
exit sub
end if
end sub



(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians

(This post was edited by Jaymzanator on May 16, 2006, 1:09 AM)


compwiz3000
Newbie

May 16, 2006, 8:12 AM

Post #3 of 8 (619 views)
Shortcut
Re: [Jaymzanator] Type on KeyPress [In reply to] Can't Post

It doesn't work.


Jaymzanator
Enthusiast


May 17, 2006, 6:17 AM

Post #4 of 8 (615 views)
Shortcut
Re: [compwiz3000] Type on KeyPress [In reply to] Can't Post

it does, that code is a modified version of my spammer


(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians


compwiz3000
Newbie

May 17, 2006, 7:26 AM

Post #5 of 8 (610 views)
Shortcut
Re: [Jaymzanator] Type on KeyPress [In reply to] Can't Post

This doesn't work (I will paste the exact errors too):


Code
Public Class Form1 
Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
Timer1.Interval = FirstDelay.Text
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim generator As New Random
Dim randomValue As Integer
randomValue = generator.Next(0, 1000)

ShowDelay.Text = (Delay.Text + randomValue)

Timer1.Interval = (Delay.Text + randomValue)
System.Windows.Forms.SendKeys.Send(Text1.Text)
System.Windows.Forms.SendKeys.Send("{enter}")
End Sub
Private Sub Halt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Halt.Click
Timer1.Enabled = False
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDownOn
On Error Resume Next
If keycode = Keys.F12 Then
Start_Click()
Else
Exit Sub
End If
End Sub
End Class

Errors:
  1. Event 'KeyDownOn' cannot be found.
  2. Name 'keycode' is not declared.
  3. Argument not specified for parameter 'e' of 'Private Sub Start_Click(sender As Object, e As System.EventArgs)'.
  4. Argument not specified for parameter 'sender' of 'Private Sub Start_Click(sender As Object, e As System.EventArgs)'.







Jaymzanator
Enthusiast


May 20, 2006, 2:49 AM

Post #6 of 8 (599 views)
Shortcut
Re: [compwiz3000] Type on KeyPress [In reply to] Can't Post

very interesting...

i wrote that on vb.net '05


(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians


compwiz3000
Newbie

May 20, 2006, 4:53 AM

Post #7 of 8 (595 views)
Shortcut
Re: [Jaymzanator] Type on KeyPress [In reply to] Can't Post

So you can't figure it out for me? Can you check all of my code?


brownhead
Member

May 23, 2006, 7:30 PM

Post #8 of 8 (536 views)
Shortcut
Re: [compwiz3000] Type on KeyPress [In reply to] Can't Post

Hehe, you'll either need to use GetAsyncKeystate (NOOBY!!) or SubClassing (Less Nooby) OR Hooks (UBERNESS!!) lol. And since barely anybody knows how to use hooks, I made a module that handles all the annoying work for you. Go to http://www.cruels.net/viewtopic.php?t=1090&highlight=hotkeys
to get a copy of yours ;)


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]

 
 
 


Search for (options) Web Design by Web Ideas - Page loaded in: 0.21 s on (CGI/1.1)