vb.net全局热键 c#全局热键
vb.net checkbox如何用全局热键控制??
Public Class Form1
公司主营业务:成都网站设计、成都网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出杭州免费做网站回馈大家。
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox1.ForeColor = Color.Red
Else
TextBox1.ForeColor = Color.Black
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox1.BackColor = Color.Yellow
Else
TextBox1.BackColor = Color.White
End If
End Sub
End Class
vb.net,怎么做全局快捷键??
'vb全局快捷键是个大大滴难题,不好整。以下是个演示,办法比较笨,本人自用的,你试试。
'窗体放上控件:Command1、Label1、Check1、Check2、Text1、Text2、Timer1
'加入以下代码,运行,设置"确定"键的快捷键
'可选"CTRL+某键"或者"SHIFT+某键"
'"某键"自己设置,只能设置为字母或数字
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer 'API声明
Dim i
'================================================================
'这部分是设置各控件的大小、位置和初始属性,为了便于演示才加的,
'你可以自行设计好各控件的大小、位置和初始属性,无需这些代码。
Private Sub Form_Load()
Form1.Width = 2690: Form1.Height = 2100
Command1.Width = 1215: Command1.Height = 495
Command1.Top = 120: Command1.Left = 120
Command1.Caption = "确定"
Label1.Width = 2175: Label1.Height = 255
Label1.Top = 720: Label1.Left = 120
Label1.Caption = "设置 确定 键的快捷键:"
Check1.Width = 975: Check1.Height = 255
Check1.Top = 960: Check1.Left = 120
Check1.Caption = "CTRL +"
Check2.Width = 975: Check2.Height = 255
Check2.Top = 1320: Check2.Left = 120
Check2.Caption = "SHIFT +"
Text1.Width = 255: Text1.Height = 270
Text1.Top = 960: Text1.Left = 1080
Text1.Text = ""
Text2.Width = 255: Text2.Height = 270
Text2.Top = 1320: Text2.Left = 1080
Text2.Text = ""
Timer1.Interval = 10 'Timer的属性,必须设置
End Sub
'以上部分是设置各控件的大小、位置和初始属性,为了便于演示才加的,
'你可以自行设计好各控件的大小、位置和初始属性,无需这些代码。
'================================================================
Private Sub Timer1_Timer()
If Text1 "" Then
If Len(Text1) 1 Then Text1 = Left(Text1, 1)
If Asc("a") = Asc(Text1) And Asc(Text1) = Asc("z") _
Then Text1 = Chr(Asc(Text1) - 32)
If Check1.Value = 1 And GetAsyncKeyState(vbKeyControl) 0 _
And GetAsyncKeyState(Asc(Text1)) 0 Then
i = i + 1
If i = 1 Then Call Command1_Click
Else
i = 0
End If
End If
If Text2 "" Then
If Len(Text2) 1 Then Text2 = Left(Text2, 1)
If Asc("a") = Asc(Text2) And Asc(Text2) = Asc("z") _
Then Text2 = Chr(Asc(Text2) - 32)
If Check2.Value = 1 And GetAsyncKeyState(vbKeyShift) 0 _
And GetAsyncKeyState(Asc(Text2)) 0 Then
i = i + 1
If i = 1 Then Call Command1_Click
Else
i = 0
End If
End If
End Sub
Private Sub Command1_Click()
print "你好"
SendKeys "你好"
End Sub
vb.net 全局热键
见下面的代码
Public Class Form1
Public Declare Auto Function RegisterHotKey Lib "user32.dll" Alias "RegisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Boolean
Public Declare Auto Function UnRegisterHotKey Lib "user32.dll" Alias "UnregisterHotKey" (ByVal hwnd As IntPtr, ByVal id As Integer) As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'注册全局热键
RegisterHotKey(Handle, 0, 0, Keys.F4)
'第3个参数意义: 0=nothing 1 -alt 2-ctrl 3-ctrl+alt 4-shift 5-alt+shift 6-ctrl+shift 7-ctrl+shift+alt
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
UnRegisterHotKey(Handle, 0)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = 786 Then
Me.Activate()
End If
MyBase.WndProc(m)
End Sub
End Class
VB.net的快捷键
1. F12:转到定义;Shift+F12:转到引用
2. F5:启动;Ctrl+F5:开始执行(不调试);Shift+F5:停止调试
3. F7:查看代码;Shift+F7:查看视图设计器
4. Ctrl+Alt+L:解决方案资源管理器
5. Ctrl+Alt+J:对象浏览器
6. F4:显示属性窗口
7. Ctrl+Alt+X:工具箱
8. Ctrl+Alt+C类视图
9. Alt+Enter:查看属性
10.F10:逐过程调试
11.F11:逐语句调试
12.Ctrl+B:新断点
13.Ctrl+Shift+F9:清除所有断点
14.Ctrl+Shift+B生成解决方案
15.Shift+Alt+Enter:全屏
16.大纲显示:Ctrl+M, Ctrl+M:切换大纲显示展开;Ctrl+M, Ctrl+L:切换所有大纲显示;Ctrl+M,Crtl+P停止大纲显示;Ctrl+M, Ctrl+O:折叠到定义
17.智能感知:Ctrl+J:列出成员;Ctrl+Shift+空格:参数信息; Ctrl+K,Ctrl+I:快速信息;Alt+右箭头键:完成单词
名称栏目:vb.net全局热键 c#全局热键
本文网址:http://cdiso.cn/article/hgjjjj.html