Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Key press problem with VB trainer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Ashwin
How do I cheat?
Reputation: 0

Joined: 20 Mar 2012
Posts: 5
Location: Meerut, UP, INDIA, ASIA,...

PostPosted: Wed May 29, 2013 11:11 pm    Post subject: Key press problem with VB trainer Reply with quote

I want to make a Trainer with VB 2010,

All i want to know is,
How will my trainer get that player is Pressing F12 in The Game,
Bcuz Keypress, Down, etc events work only when Our Form is in Focus.

Waiting for your Help.

_________________
I am a GTA VC Modder,
Back to top
View user's profile Send private message
Screitor
Cheater
Reputation: 1

Joined: 26 Nov 2012
Posts: 33
Location: Venezuela

PostPosted: Thu May 30, 2013 11:17 am    Post subject: Reply with quote

You need to set a keyboard hook.
_________________
Everybody lies.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu May 30, 2013 2:48 pm    Post subject: Reply with quote

Register a global hot key, monitor for global key presses (GetAsyncKeyState) or use a system wide low level keyboard hook.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Fri May 31, 2013 4:03 am    Post subject: Reply with quote

Heres how i do it sometimes. I did it so the code executes once if you hold the key down.

Code:
#Region "Keys"

    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Keys) As Short
    Dim hKeys As New Dictionary(Of Keys, Boolean)

    Public Function Keystate(ByVal key As Keys) As Boolean
        If GetAsyncKeyState(key) <> 0 Then
            If Not hKeys.ContainsKey(key) Then hKeys.Add(key, False)
            If Not hKeys(key) Then
                hKeys(key) = True
                Return True
            End If
        Else
            hKeys(key) = False
            Return False
        End If
        Return False
    End Function

#End Region


Create a timer with low intervals, something like 50 milliseconds.
Then just use it like this in the timer
Code:
        If Keystate(Keys.Insert) Then
            'Do something when Insert is pressed
        End If
        If Keystate(Keys.F1) Then
            'Do something when F1 is pressed
        End If

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites