[HELP] Multi-Threading and Recording Keystrokes
Code:
Imports System.Threading
Imports System
Imports System.ComponentModel
Imports System.Windows.Forms
Public Form1 w/e
Dim Loope As Boolean
Private demoThread As Thread = Nothing
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
While Loope = False
If GetAsyncKeyState(&H10) Then
Me.demoThread = New Thread( _
New ThreadStart(AddressOf Me.ThreadProcSafe))
Me.demoThread.Start()
Loope = True
End If
Sleep(100)
End While
End Sub
Private Sub ThreadProcSafe()
Me.SetText("sh")
End Sub
Private Sub SetText(ByVal [text] As String)
' InvokeRequired required compares the thread ID of the
' calling thread to the thread ID of the creating thread.
' If these threads are different, it returns true.
If Me.Label1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.Label1.Text += [text] + " "
End If
End Sub
I'm not sure if I'm doing this right but I think I'm doing a crossover of threads correctly. If there's an easier way, please help me.
Also when i record keystrokes, i want it to record by key down. I'm not really sure what I should use. What I used is use GetASyncState to record the shift key. It writes "(sh)" in a label. If I hold the Shift button, it keeps recording it. How would I make it so then it doesn't record like 1zillion?
Re: [HELP] Multi-Threading and Recording Keystrokes
Your name is hacksign, and you want a keylogger........
............. nah.
Re: [HELP] Multi-Threading and Recording Keystrokes
look he/she, for all you know, it could mean hacking someone's body apart, the tv show, or computer hacking. If I knew how to hack then I would look somewhere else. I'm trying to do something for a school project. It's something to do with a game.
Re: [HELP] Multi-Threading and Recording Keystrokes
Is it a game that you are writing? Or are you trying to send commands to a game? If you are trying to send commands to a game, then I would look at starting the game as a Process from within your program and then redirecting input and output.
Re: [HELP] Multi-Threading and Recording Keystrokes
I'm trying to make it so then when a user click a button, the game moves like one up or shoots. The problem I have is that if i hold it, it keeps going. I want it to be like *hold* - *goes only one up*. Not like *hold* - *go up until stop hold*. Yea
oh btw, is there a way for easier multi-threading or not even using it? I took the multi-thread example on Microsoft's website and edited it a bit.
Re: [HELP] Multi-Threading and Recording Keystrokes
Why not handle the keyPRESSED event in your application and then sendmessage? This will only fire once, when a key is pressed.
Re: [HELP] Multi-Threading and Recording Keystrokes
Quote:
Originally Posted by hacksign23
I'm trying to make it so then when a user click a button, the game moves like one up or shoots. The problem I have is that if i hold it, it keeps going. I want it to be like *hold* - *goes only one up*. Not like *hold* - *go up until stop hold*. Yea
oh btw, is there a way for easier multi-threading or not even using it? I took the multi-thread example on Microsoft's website and edited it a bit.
Try the BackgroundWorker component. If you have any trouble figuring it out, you can have a look at the BackgroundWorker tutorials in jmcilhinney's signature.
Re: [HELP] Multi-Threading and Recording Keystrokes
Quote:
Originally Posted by MaximilianMayrhofer
Your name is hacksign, and you want a keylogger........
............. nah.
Not to go off topic, or anything, but I believe the name is in reference to the popular anime series .Hack//Sign, which is about a gamer getting stuck in the MMO that he plays (Kind of like Tron meets WoW with deadly results.)
http://en.wikipedia.org/wiki/.hack//sign
Re: [HELP] Multi-Threading and Recording Keystrokes
Quote:
Originally Posted by MaximilianMayrhofer
Why not handle the keyPRESSED event in your application and then sendmessage? This will only fire once, when a key is pressed.
Okay thanks that sounds nice.
Quote:
Originally Posted by obi1kenobi
Try the BackgroundWorker component. If you have any trouble figuring it out, you can have a look at the BackgroundWorker tutorials in jmcilhinney's signature.
that's what I'm using x]