VB.net Frage zu "user32" und "GetAsyncKeystate"

11/27/2010 15:44 green.green#1
Hi Community,
ich habe einen Spamer gebstelt und wollte ihn mit Hotkeys verschönern, doch ich bekomm nun beim Debuggen einen Fehler.
Hier der Code:
PHP Code:
Public Class Form1

    
Private Sub Timer1_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer1.Tick
        Timer1
.Interval TextBox2.Text
        My
.Computer.Keyboard.SendKeys(TextBox1.Text)
        
My.Computer.Keyboard.SendKeys("{Enter}")
    
End Sub

    
    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        Timer1
.Enabled True
    End Sub

    
Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click
        Timer1
.Enabled False
    End Sub

    
Private Sub Timer2_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer2.Tick
        Dim starthotkey 
As Boolean
        Dim stophotkey 
As Boolean
        starthotkey 
GetAsyncKeystate(Keys.F4)
        
stophotkey GetAsyncKeystate(Keys.F5)
        If 
starthotkey True Then
            
'start
            Timer1.Enabled = True
        End If
        If stophotkey = True Then
            '
stop
            Timer1
.Enabled False

        End 
If
    
End Sub
    
Private Declare Function GetAsyncKeystate Lib "user32" (ByVal vkey As Long) As Integer
    
Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load

    End Sub


End 
Class 
Bitte um Hilfe, da ich bin noch nicht so lange im Coding-bereich.( 1-2Wochen, dafür 2 Jahre Webdesign)
11/27/2010 15:49 Al Kappaccino#2
Ja und welcher Fehler kommt nun?
11/27/2010 16:04 green.green#3
Quote:
Originally Posted by JakeFrost77 View Post
Ja und welcher Fehler kommt nun?
Sorry hab den Rest vergessen:
"Der Einstiegspunkt "GetAsyncKeystate" wurde nicht in der DLL "user32" gefunden."
11/27/2010 16:27 rEdoX#4
GetAsyncKeystate <> GetAsyncKeyState
11/27/2010 16:36 green.green#5
Quote:
Originally Posted by rEdoX View Post
GetAsyncKeystate <> GetAsyncKeyState
Denkst du es liegt an der Gross/Kleinschreibung? Ich denke nicht, da wenn ich es gross Schreibe, also so GetAsyncKeyState wir es wieder klein also so: GetAsyncKeystate

EDIT: Was du mit den "<>" meinst, weiss ich nicht.
11/27/2010 16:44 Al Kappaccino#6
PHP Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short 
Schreib es mal so am Besten direkt unter Class..

Quote:
EDIT: Was du mit den "<>" meinst, weiss ich nicht.
Grundlagen^^
11/27/2010 16:50 green.green#7
Quote:
Originally Posted by JakeFrost77 View Post
PHP Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short 
Schreib es mal so am Besten direkt unter Class..


Grundlagen^^
Ups, da fällt mir nur ein: Ui ähm ou ööö äähm ja uu öö, ach ja die Grundlagen.

Ich geh die gleich noch ein mal durch.



Edit: Hab den Code eingefügt und das Ganze sieht jetzt so aus:
PHP Code:
Public Class Form1
    
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
    
Private Sub Timer1_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer1.Tick
        Timer1
.Interval TextBox2.Text
        My
.Computer.Keyboard.SendKeys(TextBox1.Text)
        
My.Computer.Keyboard.SendKeys("{Enter}")
    
End Sub

    
    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        Timer1
.Enabled True
    End Sub

    
Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click
        Timer1
.Enabled False
    End Sub

    
Private Sub Timer2_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer2.Tick
        Dim starthotkey 
As Boolean
        Dim stophotkey 
As Boolean
        starthotkey 
GetAsyncKeystate(Keys.F4)
        
stophotkey GetAsyncKeystate(Keys.F5)
        If 
starthotkey True Then
            
'start
            Timer1.Enabled = True
        End If
        If stophotkey = True Then
            '
stop
            Timer1
.Enabled False

        End 
If
    
End Sub
    
Private Declare Function GetAsyncKeystate Lib "user32" (ByVal vkey As Long) As Integer
    
Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load

    End Sub


End 
Class 
Ich bekomm diesen Fehler beim drücken von F4/F5 "Ungültige Konvertierung von der Zeichenfolge in Typ Integer."
11/27/2010 16:56 Al Kappaccino#8
Quote:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
..
starthotkey = GetAsyncKeystate(Keys.F4)
stophotkey = GetAsyncKeystate(Keys.F5)
...
Private Declare Function GetAsyncKeystate Lib "user32" (ByVal vkey As Long) As Integer
Du hast im Prinzip nichts geändert...
11/27/2010 17:05 green.green#9
Und die Lösung fürs Problem wäre?xD
Ich habe ein Teil des Codes aus einem Tut, nciht alles aus meinem Kopf. Ich komm da grad wirklich net mehr weiter.
11/27/2010 17:14 Al Kappaccino#10
Du hast neben deiner alten falschen/falschgeschrieben einfach die neue richtige/richtig geschriebene Funktion reinkopiert und nicht einmal den Funktionsaufruf angepasst.
Das hat was mit Logik zu tun...Wenn du immernoch die falsche Funktion verwendest brauchste dich srsly nicht wundern wenn es nicht geht...Die Richtige Zaubert wohl kaum ;o

Edit:

Wenn du es immer noch nicht verstehst =>
Quote:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
..
starthotkey = GetAsyncKeystate(Keys.F4) => GetAsyncKeyState(Keys.F4)
stophotkey = GetAsyncKeystate(Keys.F5) => GetAsyncKeyState(Keys.F5)
...
Private Declare Function GetAsyncKeystate Lib "user32" (ByVal vkey As Long) As Integer <= Löschen!
Edit²:

Du kannst das hier auch anders schreiben:
PHP Code:
Dim starthotkey As Boolean GetAsyncKeyState(Keys.F4
Dim stophotkey As Boolean GetAsyncKeyState(Keys.F5
11/27/2010 17:35 green.green#11
Es funktioniert, danke! Hast grad en paar "Thanks" mehr.
11/27/2010 18:16 .BritainAndy#12
<> = ungleich