VB.net 怎么制作按键连发功能用API函数,以下代码Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMosT = -1
Private Const SWP_NOMOVE = H2
Private Const SWP_NosIZE = H1
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_KEYDOWN = H100
Const WM_KEYUP = H101
Const WM_CHAR = H102
Const VK_F1 = H70
Private Sub SendF1(hwnd)'调用这个过程即可对目标窗体发送F1键
Call PostMessage(hwnd, WM_KEYDOWN, VK_F1, 0)
Call PostMessage(hwnd, WM_KEYUP, VK_F1, 0)
End Sub这里是发送F1的实例,各个按键对应的虚拟键码,要到网上查
vb.net timer控件触发按钮的click事件Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
m = m1
n = m.tostring
TextBox1.Text = n
End Sub
m=m 1
n = m.tostring
textbox1.text = n
把这几句原来在button2 click事件里面的代码,直接写在 timer事件里面,把timer的Enabled属性设置为True, Interval属性设置为1000,就可以了 。
vb.net如何触发excel内的一个按钮的单击事件一定要先在VB中添加excel引用 。
在工程中引用Microsoft Excel类型库: 从"工程"菜单中选择"引用"栏;选择Microsoft Excel 11.0 Object Library(EXCEL2003) , 然后选择"确定" 。表示在工程中要引用EXCEL类型库 。
调用excel的工作表中的命令按钮,代码如下:
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.WorkBook
Dim xlSheet As Excel.Worksheet
Dim FileName, SheetName As String
FileName = "e:\data.xls" '打开的工作簿路径名称
SheetName = "sheet1" '命令按钮所在的工作表名
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(FileName) '打开已经存在的EXCEL工件簿文件
……
xlBook.Close (True) '保存并关闭工作簿
xlApp.Quit '结束EXCEL对象
Set xlApp = Nothing '释放xlApp对象
end sub
vb.net中,如何通过键盘上的按键触发button _click事件1、将窗口vb.net按键触发的KeyPreview属性设置为True
Me.KeyPreview = True
2、处理窗口vb.net按键触发的KeyDown事件
Sub MainFormKeyDown(sender As Object, e As KeyEventArgs)
Select Case e.KeyCode
Case Keys.Escape
Me.button1.PerformClick
【vb.net按键触发 vba按钮触发】Case Keys.Enter
Me.button2.PerformClick
End Select
End Sub
vb.net的,按键连续触发事件,比如 , 按着键不放,音量增大 。1.定义变量记录键是否被按下,按下的累计时间
Dim 按下A键As Boolean
Dim 按下A键时间 As Integer
2.添加一个TextBox1用于接收键盘事件 , 或者直接用窗体的键盘事件(确保KeyPreview为True)
在KeyDown事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = True
在KeyUp事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = False
3.添加一个Timer1控件,调整Timer1的Interval来决定按键频率,记得要把Timer1.Enable开启
在Tick事件中添加如下代码:
If 按下A键 = True
按下A键时间 =1
Call 音量设置(按下A键时间 * 10)
End If
PS: 按下的秒数 = 按下A键时间*Timer1.Interval / 1000
关于vb.net按键触发和vba按钮触发的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 微信直播间一个热度多少钱,微信直播热度怎么换算钱
- 新乡今日头条小程序开发,头条新闻今日头条小程序
- 公众号怎么创建游戏小程序,微信公众号添加小游戏
- 贰佰直播录屏,贰佰没有五微博
- c语言函数中变量的输出 c语言函数中变量的输出怎么写
- 电脑硬盘容量怎么找回,硬盘容量怎么恢复
- 关于flutter自定义RenderBox的信息
- go语言控制ffmpeg go语言控制并发
- sqlserver使用报告,SQLserver使用