Trans_Am77

Okay, I'll be quick. What I'm trying to do is use SendKeys( My.Computer.Keyboard.SendKeys(String, Boolean)) to sent text to one of my online games so I can play and not type all the time. Here is what I am doing:

Declare Auto Function FindWindow Lib "USER32.DLL" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean

Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
Dim BWarHandle As IntPtr = FindWindow(Nothing, "Brood War")
If BWarHandle = IntPtr.Zero Then
MsgBox("Brood War is not running!", MsgBoxStyle.Critical, "Zeppelin - Error 1")
Return
End If
SetForegroundWindow(BWarHandle)
My.Computer.Keyboard.SendKeys("{ENTER}", False)
My.Computer.Keyboard.SendKeys("Operation Cwal", False)
My.Computer.Keyboard.SendKeys("{ENTER}", False)
End Sub

It will send it one time then after that I have to restart the game to use it. Any ideas

Thanks



Re: Visual Basic Express Edition SendKeys Only Sending Once...

HuyN_MS

Hi,

I tried this with a Notepad window and it worked fine multiple times

AppActivate("Notepad")
My.Computer.Keyboard.SendKeys("Hello world", False)
My.Computer.Keyboard.SendKeys("{ENTER}", False)

It's likely to be an issue with the online game. You can try AppActivate or the default SendKeys which will wait for key strokes to be processed.

Best regards,






Re: Visual Basic Express Edition SendKeys Only Sending Once...

Bhanu Prakash Nunna - MSFT

FYI: If you think your post is answered then please mark it as Answer by clickin on button "Mark it as Answer".

Thank you,
Bhanu.






Re: Visual Basic Express Edition SendKeys Only Sending Once...

Trans_Am77

opps, sorry about that. Thanks for your guy's help!





Re: Visual Basic Express Edition SendKeys Only Sending Once...

Mohanraj_k

Hi,

I have similar query.

I am having one application in which ,

I Need to make on the scrolllock key.

Actually a third party application runs parallely which recognizes it and convert the key strokes if the scrolllock is on ( Font character conversion. transliteration).( in that, an option like other windows application is present which is disabled)

When Physically i hit the scrolllock key it works.

when I use it programmatically

sendkeys.sendwait(skeys). the application just hangs.

but the normal tab is working programmatically.

some where It has been caught.

Please Reply.

Mohan Raj






Re: Visual Basic Express Edition SendKeys Only Sending Once...

JAM0

I've had the same problems.

Try doing

Code Snippet
My.Computer.Keyboard.SendKeys("{ENTER}", False)
System.Threading.Thread.Sleep(500)
My.Computer.Keyboard.SendKeys("Operation Cwal", False)
System.Threading.Thread.Sleep(500)
My.Computer.Keyboard.SendKeys("{ENTER}", False)

I think the problem with your origonal code is the keys are beeing pressed too rapidly for the computer to think about.