Ⅰ 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