Something like that? The red shows what will be changed. And if that is right, will you explain why?Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Trying to learn as I go... Would be stupid to get the solution and not understand why it was wrong in the first place.
Last edited by Alroundeath; 04-22-2010 at 03:10 PM.
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
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:
That's what I have, I get no errors, BUT the hotkey doesn't work.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
If you have time and you're willing to, you can get on TeamViewer.
Last edited by Alroundeath; 04-22-2010 at 03:16 PM.
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:
Working on x32/x64 bit:Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
I will leave the further talking to nextgen, cuz I'm just a little noob and he's the expertCode:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16
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
I thought it's:
for a x64 bit system. Or doesn't it matter?Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Int32) As Int16
Did you enable your timer?
I think we all need to take a step back, post your Full Code as it is right now.
<--Form1.vbCode: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
<--ModuleCode: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
I'd rather use
instead ofCode:Timer1.Interval = Val(Textbox1.Text)
// do not enable any of the timers.Code:Timer1.Interval = Convert.ToInt32(TextBox2.Text)
--------------------------------------------------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
Delete button3/button4.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 your module.
Last edited by Blubb1337; 04-22-2010 at 03:55 PM.