'vb全局快捷鍵是個大大滴難題,不好整。以下是個演示,辦法比較笨,本人自用的,你試試。
10年積累的網(wǎng)站設計制作、成都網(wǎng)站設計經(jīng)驗,可以快速應對客戶對網(wǎng)站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡服務。我雖然不認識你,你也不認識我。但先網(wǎng)站設計制作后付款的網(wǎng)站建設流程,更有尼河口免費網(wǎng)站建設讓你可以放心的選擇與我們合作。
'窗體放上控件:Command1、Label1、Check1、Check2、Text1、Text2、Timer1
'加入以下代碼,運行,設置"確定"鍵的快捷鍵
'可選"CTRL+某鍵"或者"SHIFT+某鍵"
'"某鍵"自己設置,只能設置為字母或數(shù)字
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即時窗口用于在設計時調(diào)試和計算表達式、執(zhí)行語句、輸出變量值等
快捷鍵是:CTRL+G 或者按 CTRL+ALT+I
新建一個Form1把Form1的KeyPreview改成True
拖入一個Button1到Form1上面
然后加入以下代碼
Private
Sub
Form1_KeyDown(sender
As
Object,
e
As
KeyEventArgs)
Handles
Me.KeyDown
If
e.KeyData
=
(Keys.Alt
Or
Keys.G)
Then
Button1.PerformClick()
'或者用Button1_Click(Nothing,
New
EventArgs)
'快捷鍵Alt+G觸發(fā)Button1_Click()事件。
End
If
End
Sub
Private
Sub
Button1_Click(sender
As
Object,
e
As
EventArgs)
Handles
Button1.Click
Button1.Size
=
New
Size(180,
23)
Button1.Text
=
"我被局部快捷鍵給召喚了~"
End
Sub
分享文章:vb.net窗體快捷鍵 VB程序運行快捷鍵
網(wǎng)站URL:http://sd-ha.com/article32/hjdgpc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、面包屑導航、App設計、品牌網(wǎng)站建設、做網(wǎng)站、云服務器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)