I want to make a counter program that i cna run in the background
When i press i button i want the counter to go up by one. I already have this code but i need it to run when i'm not on the selected window. Say i'm in chrome or another window. Thank you
Just in case you want the counter code here it is:
Public Class Form1
Dim Counter As Integer
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.ControlKey
Counter += 1
Case Keys.R
Counter = 0
Label2.Text = ""
TextBox1.Enabled = True
Button1.Enabled = True
TextBox1.Show()
Button1.Show()
End Select
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = Counter
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label2.Text = TextBox1.Text
TextBox1.Enabled = False
Button1.Enabled = False
TextBox1.Hide()
Button1.Hide()
End Sub
End Class
Re: I want to make a counter program that i cna run in the background
For future reference, please use formatting tags when posting code snippets for readability.
vb.net Code:
Public Class Form1
Dim Counter As Integer
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.ControlKey
Counter += 1
Case Keys.R
Counter = 0
Label2.Text = ""
TextBox1.Enabled = True
Button1.Enabled = True
TextBox1.Show()
Button1.Show()
End Select
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = Counter
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label2.Text = TextBox1.Text
TextBox1.Enabled = False
Button1.Enabled = False
TextBox1.Hide()
Button1.Hide()
End Sub
End Class
Re: I want to make a counter program that i cna run in the background
Hi!
Should this app work as a key logger?
Re: I want to make a counter program that i cna run in the background
no just a simple counter so say if i press control the counter goes up by 1
Re: I want to make a counter program that i cna run in the background
Quote:
When i press i button i want the counter to go up by one. I already have this code but i need it to run when i'm not on the selected window. Say i'm in chrome or another window. Thank you
As I figured out from this text, you wish does your app should run in the background until you are in another app.
But, if you press lets say the "T" button or whatever else your app in the background should increase a counter.
Actually that is something like a keyloger.
The keyloger is in the background of your app in which you are working and collects data.
Now, what the keyloger a does it is up to you...
Here is a simple code what I already tested and is working:
use a Timer enabled and the interval should be 100
Whenever you press the "w" the value in the labelbox increases.
Whenever you press the "s" the value in the labelbox decreases.
No matter in which app are you.
Code:
Public Class Form1
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim MyKey1 As Boolean
Dim MyKey2 As Boolean
Dim a As Integer = 0
MyKey1 = GetAsyncKeyState(Keys.W)
MyKey2 = GetAsyncKeyState(Keys.S)
If MyKey1 = True Then
a = Label1.Text + 1
Label1.Text = a
End If
If MyKey2 = True Then
a = Label1.Text - 1
Label1.Text = a
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = 0
End Sub
End Class
I hope this snippet of code will help you go forward.
But don't forget to give a reputation if I helped in anyway.
My best regards.
Re: I want to make a counter program that i cna run in the background
Thank you my dude. Much Appreciated