Ⅰ VB中如何設置熱鍵和快捷鍵
希望某一字元成為訪問鍵,也可以在該字元前面加上一個 (&) 字元。
可以通過在 Caption 屬性設置中使用 & 字元來為命令、菜單、和控制項指定訪問鍵。
要對菜單項賦值快捷鍵,請按照以下步驟執行:
1.打開「菜單編輯器」。
2.選取該菜單項。
3.在「快捷鍵」組合框中選取功能鍵或者鍵的組合。
要刪除快捷鍵賦值,應選取列表頂部的"(none)"。
Ⅱ 如何給VB程序設置快捷鍵
1,在程序里,可以通過給按鈕設置 &A 之類的標題,將快捷方式設置為ALT+A。
2,或者用API,攔截按鈕,判斷是否為自己程序的快捷鍵,如果是,執行對應的程序。
Ⅲ vb如何創建快捷方式到啟動項
Private Declare Function fCreateShellLink Lib "STKIT432.DLL"(ByVal lpstrFolderName As String ,ByVal lpstrLinkName As String ,ByVal lpstrLinkPath As String,ByVal lpstrLinkArgs As String) as Long
sub Command1Click()
Dim lReturn As Long
'添加到程序組
lReturn=fCreateShellLink("\Startup","Shortcut to Calculator","c:\windows\calc.exe","")
End Sub
Ⅳ vb怎麼為其他軟體創建快捷方式
Windows下程序的快捷方式文件,後綴名一般為.lnk。快捷方式其實就是一個目標主程序的一個路徑索引,對快捷方式右擊查看屬性可以看到主啟動程序的位置。
創建快捷方式的一般方式有:
選中主程序啟動文件,右擊選擇發送到>桌面快捷方式,或者對主文件復制,在目標路徑下右擊,選擇粘貼快捷方式。即可創建快捷方式。
VB是一個編程工具,創建快捷方式的方法很多,常見的就是調用Shell函數,或調用批處理文件等均可實現。
Ⅳ 在vb中怎麼在快速啟動欄創建快捷方式呢,求代碼
Private Sub Command1_Click()
Dim WshShell As Variant, oMyShortcut As Variant
Dim myShortcutFilePath As String '快速啟動欄路徑
Dim myExeFilePath As String 'Exe文件路徑
myShortcutFilePath = "C:\Documents and Settings\用戶\Application Data\Microsoft\Internet Explorer\Quick Launch\" 'WinXP與Win7不同,在該文件夾創建快捷方式,就可以添加到快速訪問欄
myExeFilePath = "D:\"
Set WshShell = CreateObject("Wscript.shell")
Set oMyShortcut = WshShell.CreateShortcut(myShortcutFilePath & "aa.lnk") '此處為快捷名稱
'oMyShortcut.IconLocation = "" '此處為快捷圖標
oMyShortcut.TargetPath = myExeFilePath & "aa.exe" '此處為目標文件
'oMyShortcut.Hotkey = "ALT+CTRL+C" ''此處為快捷熱鍵
oMyShortcut.Save
MsgBox "OK"
End Sub
Ⅵ VB中如何設置開機啟動
最簡單的方法方法,把you.exe創建一個快捷方式,然後在vb中把快捷方式復制到「開始-所有程序-啟動 」里 如果exe沒有引用自己編的dll或其他外部文件,也可直接把exe復制到啟動里
Ⅶ 安裝過VB後,只能在程序中打開,太麻煩了,怎樣在桌面上創建一個快捷方式打開
在程序菜單右擊VB圖標,發送到桌面快捷方式,或者拖動到快速啟動那個地方,都可以的(拖動時按著ctrl鍵是復制快捷方式,否者就是移動,這樣程序那裡的圖標就會被移走)
Ⅷ VB 如何設置啟動項
Sub RegRun()
On Error Resume Next
Dim wsh As Object
Set wsh=CreateObject("Wscript.Shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & App.Exename, App.Path & Iif(Len(App.Path)=3, "", "\") & App.Exename & ".exe","REG_SZ"
End Sub
sub RegRun()
on error resume next
dim wsh
set wsh=createobject("wscript.shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & app.exename,app.path & "\" & app.exename & ".exe",REG_SZ"
end sub
只要執行regrun這個過程,就會把自己寫入啟動項
wsh.regwrite 三部分意義:
wsh.regwrite 寫入的位置,寫入的值,寫入的類型
HKLM\Software\Microsoft\Windows\Currentversion\Run\
是啟動項的位置也叫鍵名,值的名稱任意,值的內容為要啟動的程序的路徑
比如你要把IE寫入啟動項,就這樣寫
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\IE","C:\Program Files\Internet Explorer\IExplorer.exe","REG_SZ"
前面那段代碼就是把程序自身寫入啟動項的
'隨系統啟動而運行
Dim hKey As Long, SubKey As String, Exe As String
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run"
Exe = MyPath & "ComputerManul.exe" '要啟動的程序
RegCreateKey HKEY_CURRENT_USER, SubKey, hKey
RegSetValueEx hKey, "計算機維護程序V1.1", 0, REG_SZ, ByVal Exe, _
LenB(StrConv(Exe, vbFromUnicode)) + 1
RegCloseKey hKey
Ⅸ VB中如何為程序設置快捷鍵
用全局熱鍵
運行後程序自動隱藏,按快捷鍵自動出現
'第一步:
'新建一個窗口,將以下代碼復制進去
注冊熱鍵為:'Ctrl+Alt+P
Private
Sub
Form_Load()
form1.hide
Dim
ret
As
Long
preWinProc
=
GetWindowLong(Me.hwnd,
GWL_WNDPROC)
ret
=
SetWindowLong(Me.hwnd,
GWL_WNDPROC,
AddressOf
Wndproc)
idHotKey
=
1
Modifiers
=
MOD_Alt
+
MOD_Ctrl
uVirtKey
=
vbKeyP
ret
=
RegisterHotKey(Me.hwnd,
idHotKey,
Modifiers,
uVirtKey)
End
Sub
Private
Sub
Form_Unload(Cancel
As
Integer)
Dim
ret
As
Long
ret
=
SetWindowLong(Me.hwnd,
GWL_WNDPROC,
preWinProc)
Call
UnregisterHotKey(Me.hwnd,
uVirtKey)
End
Sub
'第二步
'新建立一個模塊,然後將以下內容復制到模塊中
Option
Explicit
Declare
Function
SetWindowLong
Lib
"User32"
Alias
"SetWindowLongA"
(ByVal
hwnd
As
Long,
ByVal
nIndex
As
Long,
ByVal
dwNewLong
As
Long)
As
Long
Declare
Function
GetWindowLong
Lib
"User32"
Alias
"GetWindowLongA"
(ByVal
hwnd
As
Long,
ByVal
nIndex
As
Long)
As
Long
Declare
Function
CallWindowProc
Lib
"User32"
Alias
"CallWindowProcA"
(ByVal
lpPrevWndFunc
As
Long,
ByVal
hwnd
As
Long,
ByVal
Msg
As
Long,
ByVal
wParam
As
Long,
ByVal
lParam
As
Long)
As
Long
Declare
Function
RegisterHotKey
Lib
"User32"
(ByVal
hwnd
As
Long,
ByVal
id
As
Long,
ByVal
fsModifiers
As
Long,
ByVal
vk
As
Long)
As
Long
Declare
Function
UnregisterHotKey
Lib
"User32"
(ByVal
hwnd
As
Long,
ByVal
id
As
Long)
As
Long
Public
Const
WM_HOTKEY
=
&H312
Public
Const
MOD_Alt
=
&H1
Public
Const
MOD_Ctrl
=
&H2
Public
Const
MOD_Shift
=
&H4
Public
Const
GWL_WNDPROC
=
(-4)
Public
preWinProc
As
Long
Public
Modifiers
As
Long,
uVirtKey
As
Long,
idHotKey
As
Long
Private
Type
taLong
ll
As
Long
End
Type
Private
Type
t2Int
lWord
As
Integer
hWord
As
Integer
End
Type
Public
Function
Wndproc(ByVal
hwnd
As
Long,
ByVal
Msg
As
Long,
ByVal
wParam
As
Long,
ByVal
lParam
As
Long)
As
Long
If
Msg
=
WM_HOTKEY
Then
If
wParam
=
idHotKey
Then
Dim
lp
As
taLong,
i2
As
t2Int
lp.ll
=
lParam
LSet
i2
=
lp
If
(i2.lWord
=
Modifiers)
And
i2.hWord
=
uVirtKey
Then
form1.show
End
If
End
If
End
If
Wndproc
=
CallWindowProc(preWinProc,
hwnd,
Msg,
wParam,
lParam)
End
Function