vb按一个快捷键就写一段文字
在command控件,tooltiptext属性中写入你的提示内容则可。
或在代码中加一行:command1.tooltiptext=" 点击后转到下一题"。
鼠标放在按钮上,就显示文本内容。
使用API函数即可
代码如下:
窗体:
Option Explicit
Sub Form_Load()
Me.Hide
Dim ret As Long
preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf wndproc)
idHotKey = 1 'in the range &h0000 through &hBFFF
Modifiers = MOD_ALT
uVirtKey = vbKeyZ
ret = RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim ret As Long
'取消Message的截取,而使之又只送往原来的Window Procedure
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_CONTROL = &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
经测试成功!Form1窗体代码:
Private Sub Form_Load()
Call InitHotKey '热键启动
End Sub
Private Sub InitHotKey()
OldwndProc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WindowProc)
Call CreateHotkey(1, vbKeyA, 1) 'Ctrl+1 *设置热键 1代表模块中的ID=1,vbKeyA(A的Ascii码),1代表Alt,2代表Ctrl
End Sub
'热键按下后的动作:
Public Sub SendStr()
Dim s As String
s = "准备发送的字符串"
SendKeys s
End Sub
Private Sub CreateHotkey(ID As Long, HK As Long, MK As Long)
Dim ReturnValue As Long
ReturnValue = RegisterHotKey(Me.hwnd, ID, MK, HK)
End Sub
Module1模块代码:
Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const NIM_ADD = &H0
Public Const NIM_Delete = &H2
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const SW_RESTORE = 9
Public Const SW_HIDE = 0
Public nfIconData As NOTIFYICONDATA
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal OldwndProc As Long, ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const GWL_WNDPROC = -4
Public OldwndProc As Long
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal HotKeyID As Long, ByVal fsModifiers As Long, ByVal vKey As Long) As Long
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal HotKeyID As Long) As Long
Public Const WM_HOTKEY = &H312
Public Const WM_NCDESTROY = &H82
Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4
Public Const MOD_WIN = &H8
Public Function WindowProc(ByVal hwnd As Long, ByVal WindowMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case WindowMsg
Case WM_HOTKEY
If wParam = 1 Then '第一个热键ID=1
Call Form1.SendStr '按下热键后启动的窗体中的过程
End If
End Select
WindowProc = CallWindowProc(OldwndProc, hwnd, WindowMsg, wParam, lParam)
End Function
我的键盘莫名其妙的E,D,B,M还有好几个键成快捷键了
因为你的win键粘住了。win键就是ctrl和alt中间那个。win+e是打开资源管理器,win+m是还原窗口。键盘该清理了。可以把背后的螺丝拆开,里面有三张薄片贴在一起的,仔细擦干净,再装上就可以了。暴力一点的方法也可以把键盘拿起来狠狠撞两下墙,不推荐 ...
100个PPT常用快捷键
100个PPT常用快捷键 一. 编辑字体 字符格式 16个 Ctrl+B: 加粗,不用去菜单栏翻找了。 Ctrl+l:斜体。 Ctrl+L: 左对齐。 Ctrl+E:居中对齐。 Ctrl+R:右对齐。 Ctrl+[左中括号: 减小字号。 Ctrl+右中括号]:增大字号。 Ctrl+Shift+F:打开宇体对话框更改字体。 Ctrl + Shift +< 向左尖括号: 增大字号...
有什么快捷键可以直接把小写金额转换成大写金额的
只需按下键盘上的“V”键,即可出现下面的结果:2、在后面输入需要转换的数字,如¥20151227.00 3、然后按下键盘上的“b”键,结果就是需要的大写金额。4、同理,如果需要插入时间或者日期,也可以。输入“v2104.12.27”5、按下键盘上的“b”键,输入:二〇一四年十二月二十七日(星期六)。
cad组合成一个整体的快捷键
4. 确定:完成上述操作后,点击“确定”,选择的多个对象就被组合成了一个整体,也就是一个块。之后,你可以像处理单个对象一样移动或复制这个块。快捷键“Block”或“B”大大简化了在CAD中组合对象的操作过程。这一功能尤其在处理复杂图形时非常实用,能够提高工作效率...
电脑基础按键知识
但在Word中,按下它会快速弹出另存为文件的窗口。注:F1至F12在不同软件中,也有不同作用。请点击输入图片描述 黄色区域:10个数字加26个字母,以及2个CTRL键,2个SHIFT键,11个符号键,一个退格,一个回车,一个空格,2个WIN窗口,一个TAB,一个CAPS LOCK,还一个图案是一张纸加一个箭头的按键...
1、在PowerPoint2010中,常使用的快捷键组合有哪些?
常用、实用快捷键:Ctrl+T:在句子.小写或大写之间更改字符格式 Shift+F3:更改字母大小写 Ctrl+B:应用粗体格式Ctrl+U:应用下划线 Ctrl+l:应用斜体格式 Ctrl+等号:应用下标格式(自动调整间距)Ctrl+Shift+加号:应用上标格式(自动调整间距)Ctrl+空格键:删除手动字符格式,如下标和上标 Ctrl+Shift+C...
按键精灵 一个脚本如何调用另一个脚本?
1、准备要导入的脚本,脚本的后缀名一般是【.Q】结尾。2、打开按键精灵,在界面中的菜单栏上点击【导入】按钮。3、弹出【导入工具向导】,点击【添加脚本】。4、在【打开】窗口中找到要导入的脚本文件,点击打开。5、可以在【要导入的脚本】中看到添加的脚本,可以一次添加多个脚本,这里只导入一个脚本...
EXCEL表中有个快捷键可以按了就重复上一步的表格操作,是那个键?
excel表格中重复操作的快捷键为:Ctrl+Y,或者使用快捷键“F4”,或者可以点击表格工具栏上方的“重复”按钮。使用方法:1、首先在excel表格中进行一个操作,例如进行了合并单元格的操作。\/iknow-pic.cdn.bcebos.com\/a08b87d6277f9e2f16b2d06f1130e924b999f3d6"target="_blank"title="点击查看大图"...
Word快捷键汇总
1.用于设置字符格式和段落格式的快捷键 快捷键 作用 Ctrl+Shift+F改变字体 Ctrl+Shift+P改变字号 Ctrl+Shift+增大字号 Ctrl+Shift+减小字号 Ctrl+]逐磅增大字号 Ctrl+[逐磅减小字号 Ctrl+D改变字符格式("格式"菜单中的"字体"命令) Shift+F3切换字母大小写 Ctrl+Shift+A将所选字母设为大写 Ctrl+B应用加粗格式...
在word中,写出以下快捷键组合的意思: Ctrl+A: Ctrl+B: Ctrl+C: Ctrl+...
Ctrl+C:复制 Ctrl+U:加下划线 Ctrl+D:打开字体属性Ctrl+X: 剪切 Ctrl+E: 居中 Ctrl+F: 查找 Ctrl+G:查找替换 Ctrl+O:打开 Ctrl+P:打印 Ctrl+V:粘贴 Ctrl+S:保存Ctrl+Z:返回上一步 在Winxp中,写出常使用的快捷键组合的意思:Alt+f4:关闭 F5:刷新 F2: 对选定的...
宗政阅同新: 经测试成功!Form1窗体代码:Private Sub Form_Load() Call InitHotKey '热键启动 End Sub Private Sub InitHotKey() OldwndProc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WindowProc) Call CreateHotkey(1, vbKeyA, 1) 'Ctrl+1 ...
南开区18316991483: VB怎么实现单击一个键后自己显示文字? - ?
宗政阅同新: 一、在窗体上添加一个按钮和一个定时器控件 Dim a(1 To 3) Dim s As Integer Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Form_Load() a(1) = "你": a(2) = "好": a(3) = "吗" Timer1.Interval = 3000 '三秒 ...
南开区18316991483: 如何在VB中输写这样的代码:文本框在每按一次按钮时就打出一行字来??
宗政阅同新: Private Sub Command1_Click() Text1.Text = "请输入你要输入的数字" For i = 1 To 9 A = i + 1 Text1.Text = Text1.Text & A Next i End Sub 你改成这个试试 楼上的那位是没有将A转换为字符串,str(a)就好了
南开区18316991483: 编写一个VB代码 就是 点击按钮 在就文本里输出文字来 - ?
宗政阅同新: Private Sub Command1_Click() Text1.Text = "文本已输出" End Sub
南开区18316991483: 谁帮写个VB 鼠标左键双击既自动输入 一段字符 - ?
宗政阅同新: Private Sub Form_DblClick() Dim str As String str = "你好" Print (str) End Sub
南开区18316991483: vb如何点击按钮输入相应文字 - ?
宗政阅同新: 以第一个按钮为例,代码如下: Private Sub Command1_Click() Text1.Text = Text1.Text & Command1.Caption End Sub其中Command1.Caption,即Command按钮上显示的文本,如果是要显示其他内容,可将此部分替换成需要显示的内容.
南开区18316991483: VB 全局快捷键 按 小键盘 1 就 text1.text=“123”?
宗政阅同新: Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 'SendKeys "{vbKeyNumpad1}" If KeyCode = vbKeyNumpad1 Then Text1.Text = "123" End If End Sub
南开区18316991483: vb编写快捷键求教(100) - ?
宗政阅同新: 按键 代码 SHIFT + CTRL ^ ALT % SendKeys "%S"就可以了,不必加"" 可以先把你要发送的字符粘贴到剪切板上,然后发送 Ctrl + V ,代码如下: Clipboard.Clear Clipboard.SetText "字符串" Debug.Print TypeName(Screen.ActiveControl...
南开区18316991483: vb每按一次enter键text就添加一行字符 - ?
宗政阅同新: Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text1 = Text1 & vbCrLf & "abc" End Sub text1设为多行模式
南开区18316991483: 用VB编写程序,按下快捷键时执行操作 - ?
宗政阅同新: 使用API函数即可 代码如下:窗体:Option Explicit Sub Form_Load() Me.Hide Dim ret As Long preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC) ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf wndproc) idHotKey = ...