[Help]Button1 not declared[Solved]

Posts 16–30 of 32 · Page 2 of 3
Quote Originally Posted by NextGen1 View Post
Long becomes Integer, Integer becomes Short

Cryptic enough for you?

Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Something like that? The red shows what will be changed. And if that is right, will you explain why?
Trying to learn as I go... Would be stupid to get the solution and not understand why it was wrong in the first place.
Quote Originally Posted by Alroundeath View Post
Code:
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Something like that? The red shows what will be changed. And if that is right, will you explain why?
Yes, that is correct. I cannot explain you though =D
Quote Originally Posted by Blubb1337 View Post
Yes, that is correct. I cannot explain you though =D
Is it based on operating system, why this is changed around? Because
I looked at the original guide thread, and I'm guessing, since people
are asking him to make it compatible with different bit CPU's changing the
integers and stuff... Idk, getting confused. But long story short, is it based
from the CPU?

Like x64 and x32 Use different coding 'methods'?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Edit:

Code:
Module Module1
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Short
    Public Sub HotKey(ByVal hotkey As Boolean)
        HotKey = GetAsyncKeyState(Keys.Insert) 'Change to any hotkey
        If hotkey = True Then
            'Do something
            'add your code here when the hotkey is pressed
        End If
    End Sub
End Module
That's what I have, I get no errors, BUT the hotkey doesn't work.

If you have time and you're willing to, you can get on TeamViewer.
Long was 32-bits wide , but in VB.NET Integer is 32-bits wide.

So Make those changes or it also may work

[php]
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Short
[/php]

Let us know if it works
Yes, OS & CPU can play a Factor in the API.

What matters now though is if it works for the OP

More specifically is windows 7

Atleast in this case, yes.

However x64 bit codes(in case of hotkeys) als work on x32 bit systems.


Working on x32 bit only:

Code:
 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Working on x32/x64 bit:

Code:
 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16
I will leave the further talking to nextgen, cuz I'm just a little noob and he's the expert
Unless it's windows 7 64bit

try this

[php]
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
[/php]

See if you get an error and see if the hotkey works
Quote Originally Posted by NextGen1 View Post
Unless it's windows 7 64bit

try this

[php]
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
[/php]

See if you get an error and see if the hotkey works
No error, no response for the hotkeys. =/
I thought it's:

Code:
 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16
for a x64 bit system. Or doesn't it matter?
Did you enable your timer?
Quote Originally Posted by Blubb1337 View Post
Did you enable your timer?
Yes, I've enabled my timer BUT when I get into the program, It's already doing the command per tick. Is it supposed to do that? =/
I think we all need to take a step back, post your Full Code as it is right now.
Quote Originally Posted by NextGen1 View Post
I think we all need to take a step back, post your Full Code as it is right now.
Code:
Public Class Form1



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer2.Enabled = True

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Timer2.Enabled = False
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Convert.ToInt32(TextBox2.Text)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Convert.ToInt32(TextBox1.Text)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        SendKeys.Send(TextBox1.Text)
        SendKeys.Send("{Enter}")
        HotKey(True)
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        SendKeys.Send(TextBox2.Text)
        SendKeys.Send("{Enter}")
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Timer1.Interval = Convert.ToInt32(TextBox2.Text)
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Timer1.Interval = Convert.ToInt32(TextBox1.Text)
    End Sub

    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
<--Form1.vb


Code:
Module Module1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
    Public Sub HotKey(ByVal hotkey As Boolean)
        hotkey = GetAsyncKeyState(Keys.F7) 'Change to any hotkey
        If hotkey = True Then
        End If
    End Sub
End Module
<--Module
I'd rather use

Code:
Timer1.Interval = Val(Textbox1.Text)
instead of

Code:
Timer1.Interval = Convert.ToInt32(TextBox2.Text)
// do not enable any of the timers.

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.enabled = false
Timer2.enabled = false
    End Sub
--------------------------------------------------

Try this

Code:
Public Class Form1


Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer2.Enabled = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer2.Enabled = False
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Val(TextBox2.Text)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Val(TextBox1.Text)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim f7 as boolean
       f7 = getasynckeystate(key.f7)
       if f7 = true then
       if timer2.enabled = false then
       timer2.enabled = true
       else
       timer2.enabled = false
       end if
       end if
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        SendKeys.Send(TextBox2.Text)
        SendKeys.Send("{Enter}")
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Timer1.Interval = Val(TextBox2.Text)
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Timer1.Interval = Val(TextBox1.Text)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.enabled = true
    timer2.enabled = false
    End Sub
End Class
Delete button3/button4.

Delete your module.
Quote Originally Posted by Blubb1337 View Post
I'd rather use

Code:
Timer1.Interval = Val(Textbox1.Text)
instead of

Code:
Timer1.Interval = Convert.ToInt32(TextBox2.Text)
// do not enable any of the timers.

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.enabled = false
Timer2.enabled = false
    End Sub
--------------------------------------------------

Try this

Code:
Public Class Form1


Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer2.Enabled = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer2.Enabled = False
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Val(TextBox2.Text)

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Timer1.Interval = Val(TextBox1.Text)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim f7 as boolean
       f7 = getasynckeystate(key.f7)
       if f7 = true then
       if timer2.enabled = false then
       timer2.enabled = true
       else
       timer2.enabled = false
       end if
       end if
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        SendKeys.Send(TextBox2.Text)
        SendKeys.Send("{Enter}")
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Timer1.Interval = Val(TextBox2.Text)
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Timer1.Interval = Val(TextBox1.Text)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.enabled = true
    timer2.enabled = false
    End Sub
End Class
Delete button3/button4.

Delete your module.
Button 3/4 and textbox 2 are being used ;o

I'll just start from scratch again... =/
Posts 16–30 of 32 · Page 2 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?