问题描述
好我有 有问题 在我的项目中
最近 我要开始 这种语言
1. 停止 botton 不起作用 我有给予 几个
时间 工作 会是什么 问题
两个 . 也 认为缺少 任何 声明
我认为 对我来说 工作100 %
添加 删除或 替换一些
pd :对不起 我不会说 或写 英文 翻译
goodI have a problem in my project
recently I'm starting this language
1. stop botton does not work I haveto give several
times to work what would be the problem
Two. also think it lacks any statement
I think for me to work 100%
add removeor replace some
pd: sorry I do not speak or write English a translator
[HIGHLIGHT = vb]
[HIGHLIGHT=vb]
Imports System.Runtime.InteropServices
Imports System.Threading
Public Class Form1
Private Const VK_K As Byte = 75
Private Const VK_O As Byte = 79
Private Const KEYEVENTF_KEYUP As Byte = 2
Private Const VK_CONTROL As Byte = 17
Private Const Pressiona_A_Tecla As Byte = 2 'pressiona a tecla A
Private Const Solta_A_Tecla As Byte = 2
Private MeChupaVadia As Integer
<DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, _
CharSet:=CharSet.Unicode, EntryPoint:="keybd_event", _
ExactSpelling:=True, SetLastError:=True)> _
Public Shared Sub keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
End Sub
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.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Form1.keybd_event(79, 0, 0, 0)
Thread.Sleep(MeChupaVadia)
Form1.keybd_event(79, 0, 2, 0)
Form1.keybd_event(75, 0, 0, 0)
Thread.Sleep(MeChupaVadia)
Form1.keybd_event(75, 0, 2, 0)
End Sub
End Class
[/HIGHLIGHT]
[/HIGHLIGHT]
推荐答案
还将您的thread.sleep设置为0,这是整数变量的默认值,如果在创建时未为其提供值,则该默认值.我相信您的button.click事件可以启动和停止计时器.尽管您可以通过单个按钮进行更改 其文本和背景色代表计时器状态.
Also your thread.sleep is set to 0, the default value for an integer variable when it is not given a value when created. I believe your button.click events are starting and stopping the timer fine. Although you can do that with a single button and change its text and backcolor to represent the timers state.
此外,如果您提供了解释,请提供所有有关您要发生的事情的信息,因为您在程序中的表单上检测到了击键.
Also if you provide an explanation please provide all information on what you want to happen because you detected a keystroke on the form in your program.
这篇关于阻止我的项目出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!