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 


VB 2008 HotKeys question

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
haxor5354
Master Cheater
Reputation: 0

Joined: 11 Jan 2008
Posts: 306
Location: Toronto

PostPosted: Wed Jun 04, 2008 6:22 am    Post subject: VB 2008 HotKeys question Reply with quote

how do I make hot keys to click button 1 and button 2. it has to work even if it not focused on form1.

+rep if good answer

_________________


My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p
Back to top
View user's profile Send private message MSN Messenger
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Wed Jun 04, 2008 6:49 am    Post subject: Reply with quote

Check out the RegisterHotKey API. It allows you to use it when the form isn't focused. You could make the hotkey run the code instead of the button, or simulate a click with the sub declaration.

For example, when you click button1, it also clicks button2:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click


Notice the Handles Button1.Click, Button2.Click part.
Back to top
View user's profile Send private message
sumnewdude
Expert Cheater
Reputation: 0

Joined: 23 May 2007
Posts: 181
Location: Where you least expect me.

PostPosted: Wed Jun 04, 2008 10:55 am    Post subject: Reply with quote

Well I use this API
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short

Then all you need to do is check to see if it changed but using a If Then, like so
Code:
If GetAsyncKeyState(112) Then
            AdjustToolStripMenuItem.PerformClick()
end if


That is checking if F1 was pressed. Also I think you have to put it on a timer.

_________________

.erutangis ruoy ni siht esu neht ,sdrawkcab siht daer ot hguone trams erew uoy fI
Back to top
View user's profile Send private message
haxor5354
Master Cheater
Reputation: 0

Joined: 11 Jan 2008
Posts: 306
Location: Toronto

PostPosted: Wed Jun 04, 2008 4:22 pm    Post subject: Reply with quote

can you give me an example please?
_________________


My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p
Back to top
View user's profile Send private message MSN Messenger
Typhoon808
Expert Cheater
Reputation: 0

Joined: 27 Mar 2008
Posts: 175
Location: Wales

PostPosted: Wed Jun 04, 2008 4:45 pm    Post subject: Reply with quote

http://www.vbforums.com/showthread.php?t=517849&highlight=registerhotkey

Shows you how to register, unregister and execute code when the hotkey is pressed.
Back to top
View user's profile Send private message
haxor5354
Master Cheater
Reputation: 0

Joined: 11 Jan 2008
Posts: 306
Location: Toronto

PostPosted: Wed Jun 04, 2008 5:21 pm    Post subject: Reply with quote

too complicated >.<

can u make me a sample source code?

_________________


My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Wed Jun 04, 2008 5:30 pm    Post subject: Reply with quote

haxor5354 wrote:
too complicated >.<

can u make me a sample source code?


Stop begging. You aren't going to learn with people just handing you things. Take the time to learn it yourself.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
AndrewMan
Grandmaster Cheater Supreme
Reputation: 0

Joined: 01 Aug 2007
Posts: 1257

PostPosted: Wed Jun 04, 2008 9:32 pm    Post subject: Reply with quote

Wiccaan wrote:
haxor5354 wrote:
too complicated >.<

can u make me a sample source code?


Stop begging. You aren't going to learn with people just handing you things. Take the time to learn it yourself.


This is true. Only ask a question when you are truly stumbled and have tried all your options and nothing works.

_________________
Back to top
View user's profile Send private message
haxor5354
Master Cheater
Reputation: 0

Joined: 11 Jan 2008
Posts: 306
Location: Toronto

PostPosted: Thu Jun 05, 2008 6:24 am    Post subject: Reply with quote

Code:
rivate Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
    Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
    Public Const WM_HOTKEY As Integer = &H312

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RegisterHotKey(Me.Handle.ToInt32, 0, 0, System.Windows.Forms.Keys.F11)'edit this for the hotkey you want
    End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_HOTKEY Then
          'code for if they press hotkey here   
            Else 
            End If
        End If
        MyBase.WndProc(m)
    End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
                   UnregisterHotKey(Me.Handle.ToInt32, 0)
           End Sub


okaaaaaaay. I only got 1 hotkey working but i need 2 hot keys for start and stop what should I do?

_________________


My Rig
MoBo: Asus P5QPL-AM
Cpu: Intel Core 2 Quad Q8200
Ram: Kingston 2x2GB DDR2 800
GFX: Asus ENGTS250 DK
HDD: 500GB WD Caviar Green
Mon: LG Flatron W2243T 1080p
Back to top
View user's profile Send private message MSN Messenger
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