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 


[VB2008] Hotkey's F1-F12 [SOLVED]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
majidemo
Cheater
Reputation: 0

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 5:29 am    Post subject: [VB2008] Hotkey's F1-F12 [SOLVED] Reply with quote

I have a little Problem..

This code works well.

i also have the GetAsyncKeyState code but im using this one for now..

all those codes work fine.. but i want something else..

when i press F9 it will enable the checkbox, but i also want that if i click F9 again the checkbox will be unchecked again.. like will be a toggle style..

clicking F9 , CheckBox CHECKED,

and if CheckBox CHECKED then i Click F9 CheckBox will be UnCheck Again..

i hope it was clear.. i have very bad english.. thanks ahead for all the help..

users in this forum has helped me alot... i know this is basic but im a newbie..^_^ i hope to learn from posting and reading posts here..^_^


Code:
 Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.F9 Then
            CheckBox2.Checked = True
        End If
        If e.KeyCode = Keys.F10 Then
            CheckBox2.Checked = False
        End If
        If e.KeyCode = Keys.F11 Then
            CheckBox3.Checked = True
        End If
        If e.KeyCode = Keys.F12 Then
            CheckBox3.Checked = False
        End If
        If e.KeyCode = Keys.F5 Then
            Button1.Enabled = False
            Button3.Enabled = True
            sendspam1.Start()
        End If
        If e.KeyCode = Keys.F6 Then
            Button1.Enabled = True
            Button3.Enabled = False
            sendspam1.Stop()
        End If
    End Sub
    Private Sub form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        KeyPreview = True

  End Sub


Last edited by majidemo on Sat Jun 06, 2009 9:48 am; edited 1 time in total
Back to top
View user's profile Send private message
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Thu Jun 04, 2009 5:34 am    Post subject: Reply with quote

Code:
CheckBox2.Checked = Not CheckBox2.Checked
Back to top
View user's profile Send private message
majidemo
Cheater
Reputation: 0

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 5:43 am    Post subject: Reply with quote

I have another Question Sir..
--------------------------------------------------------
1st is..

how do i make my hotkey work even if my program is not in focus?

like if im playing a game and want to use the hotkey w/o putting the focus back to my program?


--------------------------------------------------------
and 2nd is..

Now its not a Checkbox..

What if it is a Button? how do i do this w/ a Button?

thanks ahead.



--------------------------------------------------------
Quote:
THANKS ALOT..^_^

to those who also have the same question as i..

heres the right code..

THANKS ^_^

Code:
        If e.KeyCode = Keys.F9 Then
            CheckBox2.Checked = Not CheckBox2.Checked
        End If


--------------------------------------------------------


uhmmm how do i code this right?
Code:
       
If e.KeyCode = Keys.F5 Then
            sendspam1.Start = Not sendspam1.Stop()
        End If


it seems to be wrong..! haha..
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Thu Jun 04, 2009 6:51 am    Post subject: Reply with quote

Code:
If e.KeyCode = Keys.F5 Then
            sendspam1.Start = Not sendspam1.Stop()
        End If


what is sendspam1? timer?

Quote:
Now its not a Checkbox..

What if it is a Button? how do i do this w/ a Button?

thanks ahead.

what are you doing with the button?

_________________
Back to top
View user's profile Send private message
iTz SWAT
I post too much
Reputation: 1

Joined: 20 Dec 2007
Posts: 2227
Location: Me.Location;

PostPosted: Thu Jun 04, 2009 7:06 am    Post subject: Reply with quote

1. If your using GetAsyncKeyState then
Code:
If CBool(GetAsyncKeyState(Keys.ControlKey)) And CBool(GetAsyncKeyState(Keys.Z)) Then
            'What ever you want the global hotkey to do...
End If


2.
Code:
If CBool(GetAsyncKeyState(Keys.ControlKey)) And CBool(GetAsyncKeyState(Keys.X)) Then
            If spam1.enabled = false then
                  Button1.performclick
            ElseIf spam1.enabled = true then
                  Button2.performclick
End If

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

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 8:31 am    Post subject: Reply with quote

thanks^_^,..

these are really helpfull


but sir can you give me the full code?
cuz i have errors..

i have this declaration

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer

this quoted because im not currently using the GetAsynchKeyState.

Code:
    ' Private Sub hotkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hotkey.Tick
    'Dim hotkey As Boolean
    '   hotkey = GetAsyncKeyState(Keys.F11)
    '   If hotkey = True Then

    '    End If
    ' End Sub

and my old code is


Code:
If CBool(GetAsyncKeyState(Keys.ControlKey)) And CBool(GetAsyncKeyState(Keys.X)) Then
            If spam1.enabled = false then
                  Button1.performclick
            ElseIf spam1.enabled = true then
                  Button2.performclick
End If



anyways this is what im trying to do w/ the button.

Code:
        If e.KeyCode = Keys.F5 Then
            Button1.Enabled = False
            Button3.Enabled = True
            sendspam1.Start()
        End If
        If e.KeyCode = Keys.F6 Then
            Button1.Enabled = True
            Button3.Enabled = False
            sendspam1.Stop()
        End If


but i just want it to be F5 to start and stop it.. so ill only use 1 hotkey...
Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Thu Jun 04, 2009 10:21 am    Post subject: Reply with quote

Code:
        If e.KeyCode = Keys.F5 Then
if Button1.Enabled = true then           
Button1.Enabled = False
Button3.Enabled = True
sendspam1.Start()
else
Button1.Enabled = True
Button3.Enabled = False
sendspam1.Stop()
End If


Should work, sorry for bad layout, don't have VB with me atm
Back to top
View user's profile Send private message
majidemo
Cheater
Reputation: 0

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 10:41 am    Post subject: Reply with quote

Kerelmans wrote:
Code:
        If e.KeyCode = Keys.F5 Then
if Button1.Enabled = true then           
Button1.Enabled = False
Button3.Enabled = True
sendspam1.Start()
else
Button1.Enabled = True
Button3.Enabled = False
sendspam1.Stop()
End If


Should work, sorry for bad layout, don't have VB with me atm


sorry it gives me a error, must have END IF??it says.._^
Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Thu Jun 04, 2009 11:02 am    Post subject: Reply with quote

Indeed, I forgot and End If at the end =)

EDIT:

Code:
If e.KeyCode = Keys.F5 Then
if Button1.Enabled = true then           
Button1.Enabled = False
Button3.Enabled = True
sendspam1.Start()
else
Button1.Enabled = True
Button3.Enabled = False
sendspam1.Stop()
End If
End If


Last edited by Kerelmans on Thu Jun 04, 2009 11:11 am; edited 1 time in total
Back to top
View user's profile Send private message
majidemo
Cheater
Reputation: 0

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 11:10 am    Post subject: Reply with quote

uhhmmm? so what is the correct statement sir? haha^_^

Code:

If e.KeyCode = Keys.F5 Then
if Button1.Enabled = true then           
Button1.Enabled = False
Button3.Enabled = True
sendspam1.Start()
End If '<-----???
else
Button1.Enabled = True
Button3.Enabled = False
sendspam1.Stop()
End If
Back to top
View user's profile Send private message
92Garfield
I'm a spammer
Reputation: 57

Joined: 20 Dec 2007
Posts: 5871
Location: Banana Republic Germany

PostPosted: Thu Jun 04, 2009 11:49 am    Post subject: Reply with quote

end if comes where the fi should end..

omg.. cant you think half a step by urself?

edit: nvm, he edited his post

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

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 8:07 pm    Post subject: Reply with quote

sorry..

im not a programmer.. i just want to learn.. im still in highschool..

im really sorry..

anyways thanks..


sir i cant seem to work this out..

Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer

Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If CBool(GetAsyncKeyState(Keys.ControlKey)) And CBool(GetAsyncKeyState(Keys.F8)) Then
            If Button1.Enabled = True Then
                Button1.PerformClick()
            Else
                Button3.PerformClick()
            End If
        End If

    End Sub


nor this one sir

Code:
    Private Sub hotkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hotkey.Tick
        'Dim hotkey As Boolean
        '   hotkey = GetAsyncKeyState(Keys.F11)
        '   If hotkey = True Then

        '    End If
        ' End Sub
        If CBool(GetAsyncKeyState(Keys.ControlKey)) And CBool(GetAsyncKeyState(Keys.F8)) Then
            If Button1.Enabled = True Then
                Button1.PerformClick()
            Else
                Button3.PerformClick()
            End If
        End If
    End Sub
Back to top
View user's profile Send private message
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Thu Jun 04, 2009 8:26 pm    Post subject: Reply with quote

majidemo wrote:
uhhmmm? so what is the correct statement sir? haha^_^

Code:

If e.KeyCode = Keys.F5 Then
if Button1.Enabled = true then           
Button1.Enabled = False
Button3.Enabled = True
sendspam1.Start()
End If '<-----???
else
Button1.Enabled = True
Button3.Enabled = False
sendspam1.Stop()
End If


I would do it like this:
Code:
If e.KeyCode = Keys.F5 Then
  If Button1.Enabled Then
    sendspam1.Start()
  Else
    sendspam1.Stop()
  End If
  Button3.Enabled = Button1.Enabled
  Button1.Enabled = Not Button1.Enabled
End If

I've not worked with aysncstate before but at a guess you need to do
Code:
hotkey.Enabled = True
to start the timer.. Also, it is better to shortcircuit logical operators where possible, unless you need them all to be evaluated.
Code:
Private Sub hotkey_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hotkey.Tick
        If CBool(GetAsyncKeyState(Keys.ControlKey)) AndAlso CBool(GetAsyncKeyState(Keys.F8)) Then
            If Button1.Enabled = True Then
                Button1.PerformClick()
            Else
                Button3.PerformClick()
            End If
        End If
    End Sub
Back to top
View user's profile Send private message
majidemo
Cheater
Reputation: 0

Joined: 17 Apr 2009
Posts: 28

PostPosted: Thu Jun 04, 2009 10:30 pm    Post subject: Reply with quote

uhmm? i want to ask again?

so.. i want to use the hotkey even though my program is not in focus

how to code that?

like im using another program.. then it is posible to use the hotkey of my program..
Back to top
View user's profile Send private message
92Garfield
I'm a spammer
Reputation: 57

Joined: 20 Dec 2007
Posts: 5871
Location: Banana Republic Germany

PostPosted: Thu Jun 04, 2009 10:59 pm    Post subject: Reply with quote

It should be possible with GetAsyncKeyState
_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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