[Help Request]Keysend[Solved]

Posts 1–14 of 14 · Page 1 of 1
[Help Request]Keysend[Solved]
Hi everyone, how can I send several keys at the same time, per example "ctrll+tab" so I can change the tab in firefox or "ctrl+w"?
I'd appreciate your help,

Thanks in advance,
Omanel
On the top of ur form, add this:
Private Declare Function key Lib "User32" Alias "GetAsyncKeyState" (ByVal Key As Keys) As Keys
And in a timer, add this:
If key(Keys.ControlKey) And Keys.W Then

End If
He wants to send them, not check if they are pressed, I guess.
Quote Originally Posted by Blubb1337 View Post
He wants to send them, not check if they are pressed, I guess.
I already know how to do it, found it on msdn

If someone's Intrested:
http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx

(I think there's no problem in posting that link since it's a neutral and safe website)
Okay add these declarations and constants (just under "Public Class Form1"):

[php]
Public Declare Function keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Long

Const KEYEVENTF_KEYUP = &H2
[/php]

Then add this sub procedure:

[php]
Private Sub press(ByVal mykey1 As Keys, ByVal mykey2 As Keys)

keybd_event(mykey1, 0, 0, 0)
keybd_event(mykey2, 0, 0, 0)
keybd_event(mykey1, 0, KEYEVENTF_KEYUP, 0)
keybd_event(mykey2, 0, KEYEVENTF_KEYUP, 0)

End Sub
[/php]

Then to utilize this,

[php]

Press(Keys.ControlKey, Keys.W) 'this will press Ctrl + W)

[/php]

FLAMESABER originally gave me a similar snippet, I just modified it to press two keys.

Not sure it works though :P Don't have VB right nao. It should though.

J-Deezy
if your just using firefox as an example, and your really planning on using this for a game it wont work there different add me on msn if your doing this for a game and ill help you get it to work
Quote Originally Posted by CodeHPro View Post
if your just using firefox as an example, and your really planning on using this for a game it wont work there different add me on msn if your doing this for a game and ill help you get it to work
It will work anywhere.

@Deezy: Slight modification to your code.


Code:
Private Sub press(ByVal mykey1 As Keys, ByVal mykey2 As Keys)

        keybd_event(mykey1, 0, 0, 0)
        keybd_event(mykey2, 0, 0, 0)
        System.Threading.Thread.Sleep(500)
        keybd_event(mykey1, 0, KEYEVENTF_KEYUP, 0)
        keybd_event(mykey2, 0, KEYEVENTF_KEYUP, 0)

   End Sub
^^ This will work better !!
Hmm I see But If you hold the keys down for half a second, multiple tabs will be opened etc.

Maybe reduce it to 100 instead of 500
Quote Originally Posted by Jason View Post
Hmm I see But If you hold the keys down for half a second, multiple tabs will be opened etc.

Maybe reduce it to 100 instead of 500
Ya, I just entered an example. It can be changed according to needs.
Quote Originally Posted by CodeHPro View Post
if your just using firefox as an example, and your really planning on using this for a game it wont work there different add me on msn if your doing this for a game and ill help you get it to work
Actually am doing it for a game, but it's a browser game that's why I said firefox

Altough I found out how to do it in a simplest way Thnks to FLAMESABER and J-deezy anyways!
Quote Originally Posted by omanel View Post
Actually am doing it for a game, but it's a browser game that's why I said firefox

Altough I found out how to do it in a simplest way Thnks to FLAMESABER and J-deezy anyways!
Glad to know prob is solved, but it will be good if you can share that simplest solution with us !!
Quote Originally Posted by Hassan View Post
Glad to know prob is solved, but it will be good if you can share that simplest solution with us !!
I believe he did with the MSDNⓘ link he posted earlier.
Quote Originally Posted by Hassan View Post
Glad to know prob is solved, but it will be good if you can share that simplest solution with us !!
Here's a source code of a application w/ 2 buttons and 1 timer that changes per example your tab in firefox etc.
[html]Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
SendKeys.Send("^({tab})")
End Sub
End Class[/html]

[html]SendKeys.Send("^({tab})")[/html]
That equals "ctrl+tab"

@lolland, ok, just awnsering FLAMESABER.
Marking solved.
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us