本文介绍了如何在Vb.Net中使用Sendkey模拟向下键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我制作了这个vb.net程序,我从列表框中的特定文件夹中加载了所有歌曲。我有两个按钮 - button1用于加载歌曲,button2是我打算用来模拟向下箭头键,这样每当我点击button2,我就会转到下一首歌曲。但问题是,我使用计时器模拟向下箭头键,每当我点击按钮2时,计时器启动,向下箭头键不停地继续前进。这不是我想要的,我的目标是当点击button2时,它应该只走一步而不是继续前进。我尝试使用循环来阻止它但没有任何效果。我知道如何解决这个问题。 继承我的代码 - 私人 Sub Button2_Click(发件人作为 对象 ,e As EventArgs) Handles Button2.Click Timer1 .Enabled = True 结束 Sub 私有 Sub Timer1_Tick(发件人作为 对象,e As EventArgs)句柄 Timer1.Tick SendKeys.Send( {DOWN}) 结束 Sub 解决方案 I made this vb.net program where i loaded all my songs from a particular folder in a listbox. I have two buttons- button1 is for loading the songs and button2 is what i intended for is simulating the down arrow key, so that whenever i click on button2, i go to the next song. But here is the problem, i used a timer to simulate the down arrow key and whenever i click on the button2 , the timer starts and the down arrow key keeps going continuously without stopping. This is not what i want, my goal is that the when the click on button2, it should just go 1 step and not keep going continuously. I tried using loops to stop that but nothing worked. Any idea how i can solve this issue.Heres my code-Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Timer1.Enabled = True End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.TickSendKeys.Send("{DOWN}")End Sub 解决方案 这篇关于如何在Vb.Net中使用Sendkey模拟向下键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 19:16