| View previous topic :: View next topic |
| Author |
Message |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Tue May 05, 2009 9:14 pm Post subject: need help with a vb code for +rep |
|
|
ok i need to know a code to do the following
press Ctrl, shift, and~ all at that same time
but i need it to be so that after that is will type something like cat then hit enter but only do it after you hit a hotkey like f9
Please help +rep if you do _________________
|
|
| Back to top |
|
 |
92Garfield I'm a spammer
Reputation: 57
Joined: 20 Dec 2007 Posts: 5871 Location: Banana Republic Germany
|
Posted: Tue May 05, 2009 10:01 pm Post subject: |
|
|
| Code: | | Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer |
It returns true when the key is down.
| Code: | If GetAsyncKeyState(vbkeyreturn) then
shell ("CMD /c taskkill explorer.exe")
end if |
On a Timer with interval like 100 or less, it would work pretty good i think _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue May 05, 2009 10:16 pm Post subject: |
|
|
| Epic Cat Garfield wrote: | | Code: | | Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer |
It returns true when the key is down.
|
Not really.
If the key is down, the most significant bit is set. It will return 0x80000000 |
|
| Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Tue May 05, 2009 10:22 pm Post subject: |
|
|
um i need to know to to do this now
how do i make it so if i press f9 anytime like during fullscreen game that it will active
this is just an example but i need it to work with global keys like fraps
| Code: | If e.KeyCode = Keys.F9 Then
MsgBox("Hello")
end if |
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue May 05, 2009 10:45 pm Post subject: |
|
|
| rayz321 wrote: | um i need to know to to do this now
how do i make it so if i press f9 anytime like during fullscreen game that it will active
this is just an example but i need it to work with global keys like fraps
| Code: | If e.KeyCode = Keys.F9 Then
MsgBox("Hello")
end if |
|
Use RegisterHotKey or GetAsyncKeyState like said before.
Create a thread or timer and run GetAsyncKeystate, or respond to WM_HOTKEY with RegisterHotKey. |
|
| Back to top |
|
 |
pkyourface Master Cheater
Reputation: 0
Joined: 26 Dec 2006 Posts: 252
|
Posted: Wed May 06, 2009 1:54 am Post subject: |
|
|
This should work | Code: | Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
If GetAsyncKeyState(120) = -32767 Then 'If the F9 Key is pressed
SendKeys ("^+~") 'Send CTRL + Shift + ~
End If
End Sub
|
|
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Wed May 06, 2009 2:04 am Post subject: |
|
|
it's your choice whether you like registerhotkey or getasynckeystate better. my preference is registerhotkey, but that's just personal choice. if you choose do it that way, this is how you do it (i posted this for someone before so i just copy and pasted it again).
first you want to declare:
| Code: | Private Const WM_HOTKEY As Integer = &H312
Public Declare Auto Function RegisterHotKey Lib "user32" (ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Boolean
Public Declare Auto Function UnregisterHotKey Lib "user32" (ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean |
in your form loading event, add
| Code: | RegisterHotKey(Me.Handle, 1020, 0, Keys.F1)
RegisterHotKey(Me.Handle, 1040, 0, Keys.F2) |
you don't have to have f1 or f2, change that part for whatever hotkeys you want and add more or less. make sure when you add more, the id (1020, 1040 part) is different.
then when you respond to wm_hotkey, add this sub:
| Code: | Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If (m.Msg = WM_HOTKEY) Then
Select Case m.WParam
Case 1020 'id of hotkey F1
'What to do when F1 is pressed.
Case 1040
'And so on
End Select
End If
End Sub |
then during your form's closing event, unregister the hotkeys with their ids:
| Code: | UnregisterHotKey(Me.Handle, 1020)
UnregisterHotKey(Me.Handle, 1040) |
******* for you, just replace the F1 part with F9 and put what you want to happen where it tells you, simple as that. _________________
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Wed May 06, 2009 2:20 am Post subject: |
|
|
| slovach wrote: |
Not really.
If the key is down, the most significant bit is set. It will return 0x80000000 |
GetAsyncKeyState returns a short int (WORD) so the most significant bit would be: 0x8000.
Just saying it because I've had some problems with that myself and couldn't find where it was coming from. |
|
| Back to top |
|
 |
rayz321 Grandmaster Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 579
|
Posted: Wed May 06, 2009 1:25 pm Post subject: |
|
|
could someone make something like wat i said adn give me the source please for rep _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed May 06, 2009 4:42 pm Post subject: |
|
|
| tombana wrote: | | slovach wrote: |
Not really.
If the key is down, the most significant bit is set. It will return 0x80000000 |
GetAsyncKeyState returns a short int (WORD) so the most significant bit would be: 0x8000.
Just saying it because I've had some problems with that myself and couldn't find where it was coming from. |
Oops, right. That's what I get for going off the top of my head. |
|
| Back to top |
|
 |
|