Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Okay so this is my code.

VB
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
              Static nVal1 As Boolean
          If GetAsyncKeyState(Keys.A) = 0 Then
               If nVal1 Then
                   SendKeys.Send(GrpTxt1.Text)
                   SendKeys.Send("{Enter}")
                nVal1 = CBool(GetAsyncKeyState(Keys.A))
     End If
   End Sub

The problem is whenever it sends the text to another forum using the hotkey it works fine, But if the GrpTxt1 text contains the hotkey name it spams it it because the key is sending over and over again because it contains "A" the hotkey in the text. Please help ):
Posted

I can't help feeling that there is something very, very wrong with your whole approach here. I don't know what it is you are trying to achieve, but I am fairly sure that this is not a good way to do it.

The problem is that you are reading text from a text box and send it to the active application as if it was typed by the keyboard, and if seems that you are starting off with a timer in your application which detects that the user has pressed "A" key. This is seriously not a good idea: Firstly, because you have no control at all over where the data is going, and hence what it is doing. Secondly, because it will repeat if the user doesn't let go on the key in time. Thirdly because as you have noticed including the "start transfer" key in the text stream is likely to cause it to repeat again and again anyway.

What are you actually trying to do, that you think this is the best solution? There may be a better, more robust way of doing it - this way is what I call "BFI" - "Brute Force and Ignorance".
 
Share this answer
 
Ok so i did research research and more research on the best way to do this and this is all i could find, Converted it to my own code, And the reason it doesn't repeat itself is because it reads the keyup event instead of keydown. If there was a way to do it without a timer i would love that, But as i've found there's no other way to do it, This application is for games to send quick commands with a keypress, And i just want to figure out how to fix this or even improve my application. Thanks

- Justin
 
Share this answer
 
v2
*Bump*

I'm sorry but you guys are the smartest coders on the web and you're my last hope to help me out. Please help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900