Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Const WM_KEYUP = &H101‘定义普通按键抬起常量
Private Const WM_CHAR = &H102
Private Const WM_KEYDOWN = &H100‘定义普通按键按下常量
。。。。。。。。。。。
PostMessage& hwd, WM_KEYDOWN, vbKeyReturn, 0 '这是按下enter键
PostMessage hwd, WM_KEYUP, vbKeyReturn, 0 '这是弹起enter按键
这是代码的一部分代码,先声明定义有关按键常量,再向窗口句柄hwd发送。
问题:ALT+N组合键怎么声明按键常量(其中ALT是系统按键)?
会的才回答 不好意思,本人小菜。不要误人子弟
向后台发送组合键ALT+N,要先声明常量,怎么声明?晕倒
VB后台发送按键和鼠标(会的进,不会的免了)
答案:1 悬赏:0 手机版
解决时间 2021-12-16 17:00
- 提问者网友:王者
- 2021-12-15 18:16
最佳答案
- 五星知识达人网友:盏茶作酒
- 2021-12-15 18:34
你的问题是不是只要系统识别你的ALT+N的快捷键?那用下面的代码··我试验过了好用的··
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Const WM_SETHOTKEY = &H32
Const HOTKEYF_ALT = &H4
Private Sub Form_Load()
Dim wHotkey As Integer
wHotkey = (HOTKEYF_ALT) * &H100 + Asc("N")
Call SendMessage(Me.hwnd, WM_SETHOTKEY, wHotkey, 0)
End Sub
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Const WM_SETHOTKEY = &H32
Const HOTKEYF_ALT = &H4
Private Sub Form_Load()
Dim wHotkey As Integer
wHotkey = (HOTKEYF_ALT) * &H100 + Asc("N")
Call SendMessage(Me.hwnd, WM_SETHOTKEY, wHotkey, 0)
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯