VB.NET Keybinder问题.请帮忙! [英] VB.NET Keybinder issue. PLEASE HELP!

查看:67
本文介绍了VB.NET Keybinder问题.请帮忙!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这就是我的代码.

Okay so this is my code.

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


问题是每当它使用热键将文本发送到另一个论坛时,它都可以正常工作,但是,如果GrpTxt1文本包含热键名称,则它会对其进行垃圾邮件处理,因为该键反复发送,因为该键中包含"A"热键.文本.请帮助):


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 ):

推荐答案

我不禁觉得这里的整个方法存在非常非常错误的地方.我不知道您要达到什么目的,但是我很确定这不是一个好方法.

问题是您正在从文本框中读取文本,然后将其发送到活动应用程序中,就好像它是由键盘键入的一样,并且似乎您正在从应用程序中的计时器开始,该计时器检测到用户已按下关键.这绝对不是一个好主意:首先,因为您根本无法控制数据的去向以及数据的运行.其次,因为如果用户不及时松开键,它将重复一次.第三,因为您已经注意到,在文本流中包含开始传输"键很可能会导致其一遍又一遍地重复.

您实际上想做什么,您认为这是最好的解决方案?可能有一种更好,更强大的方法-这种方式被我称为"BFI"-暴力与无知".
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".


好,所以我进行了研究研究并进行了更多研究在最好的方法上,这就是我所能找到的全部内容,将其转换为我自己的代码,并且不重复自身的原因是因为它读取keyup事件而不是keydown事件.如果有没有计时器的方法,我会喜欢的,但是正如我发现没有其他方法那样,此应用程序是供游戏通过按键发送快速命令的,而我只是想要弄清楚如何解决此问题,甚至改善我的应用程序.谢谢

-贾斯汀
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


*凹凸*

抱歉,你们是网络上最聪明的编码员,您是我最后的帮助.请帮忙.
*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.


这篇关于VB.NET Keybinder问题.请帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆