| View previous topic :: View next topic |
| Author |
Message |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Mon Oct 29, 2007 9:52 pm Post subject: [Visual Basics 6.0] Hotkeying (Question) |
|
|
Could somebody please give me the code that you enter in the "view code" screen to Hotkey an Auto-Clicker
Thanks +Rep
(If its not possible just say so but i remember theres a Function to do it)
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Oct 30, 2007 12:00 am Post subject: |
|
|
You can also use GetAsyncKeyState() which is used inside a timer:
| Code: | Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF12) Then
MsgBox "F12 was pressed!", vbInformation, "Info"
End If
End Sub |
_________________
- Retired. |
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Tue Oct 30, 2007 4:29 am Post subject: |
|
|
| Wiccaan wrote: | You can also use GetAsyncKeyState() which is used inside a timer:
| Code: | Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyF12) Then
MsgBox "F12 was pressed!", vbInformation, "Info"
End If
End Sub |
|
Doesnt work i dun get a msg saying f12 was pressed
@ the guy above wiccan uhm where do you put in that code the button what u want to press
_________________
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Tue Oct 30, 2007 4:32 am Post subject: |
|
|
| Use VK_F12 instead of vbKeyF12.
|
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Tue Oct 30, 2007 4:37 am Post subject: |
|
|
| rEakW0n wrote: | | Use VK_F12 instead of vbKeyF12. |
o right thanks for the quick reply il test it now
Edit: Still no msg box
could you please give me a full code that works
_________________
|
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Tue Oct 30, 2007 4:50 am Post subject: |
|
|
| Mussy69 wrote: | | rEakW0n wrote: | | Use VK_F12 instead of vbKeyF12. |
o right thanks for the quick reply il test it now
Edit: Still no msg box
could you please give me a full code that works |
Well I don't know any VB.
But delphi, and in delphi it's VK_F12, but try this out:
Instead of VK_F12 or vbKeyF12, just use 123.
and if it still wont work, use this:
| Code: | Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
If Odd(GetAsyncKeyState(VK_F12)) Then
MsgBox "F12 was pressed!", vbInformation, "Info"
End If
End Sub |
and try it out with
VK_F12, vbKeyF12 and 123.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Oct 30, 2007 6:34 am Post subject: |
|
|
| Mussy69 wrote: | | Doesnt work i dun get a msg saying f12 was pressed |
You need to create a timer, and make sure it is enabled and has a valid interval to use my code.
| rEakW0n wrote: | | Use VK_F12 instead of vbKeyF12. |
VB6 does not use 'VK_' keys unless you define them yourself. Instead, for GetAsyncKeyState, you simply use 'vbKey<keyhere>'.
And to use RegisterHotKey, you need to do something like this:
| Code: | Option Explicit
'
' Structures
'
Private Type uMsg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
End Type
'
' Constants
'
Private Const WM_HOTKEY = &H312
Private Const PM_REMOVE = &H1
'
' API Declarations
'
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal bytes As Long)
Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As uMsg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
'
' Used To Exit Loop
'
Private bExiting As Boolean
'
' Handle Hotkey Messages
'
Private Sub HandleHotkeys()
Dim uMessage As uMsg
Do While Not bExiting
WaitMessage
If PeekMessage(uMessage, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then
'
' Check For CTRL+F12
'
If LoWord(uMessage.lParam) = 2 And HiWord(uMessage.lParam) = vbKeyF12 Then
MsgBox "Hotkey: CTRL+F12 was hit!"
End If
End If
DoEvents
Loop
End Sub
'
' Main Program Load
'
Private Sub Form_Load()
'
' Show The Form
' This is important because DoEvents is used!
'
Me.Show
' Register F12
Call RegisterHotKey(Me.hWnd, &H1FF&, 2, vbKeyF12)
Call HandleHotkeys
End Sub
Private Sub Form_Unload(Cancel As Integer)
bExiting = True
Call UnregisterHotKey(Me.hWnd, &H1FF&)
End Sub
'
' HiWord
' Obtain the hiword of a param.
'
Function HiWord(ByVal value As Long) As Integer
CopyMemory HiWord, ByVal VarPtr(value) + 2, 2
End Function
'
' LoWord
' Obtain the loword of a param.
'
Function LoWord(ByVal value As Long) As Integer
CopyMemory LoWord, ByVal VarPtr(value), 2
End Function |
_________________
- Retired. |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Tue Oct 30, 2007 8:28 am Post subject: |
|
|
| Mussy69 wrote: | | rEakW0n wrote: | | Use VK_F12 instead of vbKeyF12. |
o right thanks for the quick reply il test it now
Edit: Still no msg box
could you please give me a full code that works |
Just, add a timer to your form. Double click on it and put in the code. By the way, I suggest RegisterHotKey because GetAsyncKeyState takes up more CPU Usage.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Trow Grandmaster Cheater
Reputation: 2
Joined: 17 Aug 2006 Posts: 957
|
Posted: Tue Oct 30, 2007 4:21 pm Post subject: |
|
|
but if you use a vb timer (which is retarded; you might as well program your own control for a more accurate one) then of course the cpu usage will stay low... with a max of 1000 surveys per second. RegisterHotKey (which i dont know how to use) will at least give you a 100% likelihood of detecting a key press.
not much of an issue, but getasynckeystate in application failed me here and there cos of this.
_________________
Get kidnapped often. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Tue Oct 30, 2007 6:54 pm Post subject: |
|
|
| oib111 wrote: | | Mussy69 wrote: | | rEakW0n wrote: | | Use VK_F12 instead of vbKeyF12. |
o right thanks for the quick reply il test it now
Edit: Still no msg box
could you please give me a full code that works |
Just, add a timer to your form. Double click on it and put in the code. By the way, I suggest RegisterHotKey because GetAsyncKeyState takes up more CPU Usage. |
i had a timer but like wiccan said above u need a valid interval
my interval was jus default (0)
that registerhotkey code is massive
could you please go on MSN or PM me on what part of that script do i edit for instance if i wanted the hotkey "R" my MSN
is "[email protected]" and i dun care if the public no 1 cuz il jus delete them as a contact
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Oct 30, 2007 7:14 pm Post subject: |
|
|
With RegisterHotKey you need to understand that you HAVE to include a modifier. Which means your hotkey must use ALT+ CTRL+ SHIFT+ or WIN+ along side of another key. You can't just define your hotkey to a single button.
That being said..
ALT = &H1
CTRL = &H2
SHIFT = &H4
WIN = &H8
Next, you will need to pick which hotkey you want. Such as CTRL+R, ALT+R, etc. In this case, lets use CTRL+R.
In the Form_Load you will need to add the hotkey define:
| Code: | | Call RegisterHotKey(Me.hWnd, &H200&, 2, vbKeyR) |
Also, before continuing be sure to add your remove hotkey call too, so add this in Form_Unload:
| Code: | | Call UnregisterHotKey(Me.hWnd, &H200&) |
Notice that I used &H200& for this hotkey. It is the ID for the registered hotkey. And these MUST be different for each hotkey you define. Just increment by 1 for each one you want to have.
Next, you need to add the check inside the HandleHotkeys sub. So if you're looking at the old code, locate:
| Code: | '
' Check For CTRL+F12
'
If LoWord(uMessage.lParam) = 2 And HiWord(uMessage.lParam) = vbKeyF12 Then
MsgBox "Hotkey: CTRL+F12 was hit!"
End If |
After, you will want to add the check for CTRL+R:
| Code: | '
' Check For R
'
If LoWord(uMessage.lParam) = 2 And HiWord(uMessage.lParam) = vbKeyR Then
MsgBox "Hotkey: CTRL+R was hit!"
End If |
The HiWord of the lParam passed from the WM_HOTKEY message is the virtual key that was pressed. The loword is the modifier. (ALT, CTRL, SHIFT, WIN)
Hope that helps.
_________________
- Retired. |
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Tue Oct 30, 2007 8:18 pm Post subject: |
|
|
| Wiccaan wrote: | With RegisterHotKey you need to understand that you HAVE to include a modifier. Which means your hotkey must use ALT+ CTRL+ SHIFT+ or WIN+ along side of another key. You can't just define your hotkey to a single button.
That being said..
ALT = &H1
CTRL = &H2
SHIFT = &H4
WIN = &H8
Next, you will need to pick which hotkey you want. Such as CTRL+R, ALT+R, etc. In this case, lets use CTRL+R.
In the Form_Load you will need to add the hotkey define:
| Code: | | Call RegisterHotKey(Me.hWnd, &H200&, 2, vbKeyR) |
Also, before continuing be sure to add your remove hotkey call too, so add this in Form_Unload:
| Code: | | Call UnregisterHotKey(Me.hWnd, &H200&) |
Notice that I used &H200& for this hotkey. It is the ID for the registered hotkey. And these MUST be different for each hotkey you define. Just increment by 1 for each one you want to have.
Next, you need to add the check inside the HandleHotkeys sub. So if you're looking at the old code, locate:
| Code: | '
' Check For CTRL+F12
'
If LoWord(uMessage.lParam) = 2 And HiWord(uMessage.lParam) = vbKeyF12 Then
MsgBox "Hotkey: CTRL+F12 was hit!"
End If |
After, you will want to add the check for CTRL+R:
| Code: | '
' Check For R
'
If LoWord(uMessage.lParam) = 2 And HiWord(uMessage.lParam) = vbKeyR Then
MsgBox "Hotkey: CTRL+R was hit!"
End If |
The HiWord of the lParam passed from the WM_HOTKEY message is the virtual key that was pressed. The loword is the modifier. (ALT, CTRL, SHIFT, WIN)
Hope that helps. |
Ok so then for example
i would put the unload and load code
then i put the other code the 1 with "check for r" but say if i wanted to make an ac such as MzBot when u press F12 AC Starts
instead of MsgBox "Hotkey: CTRL+R was hit!" i would put...?
sorry for all the questions
_________________
|
|
| Back to top |
|
 |
|