VB激活当前窗口所要用到的热键,谁有代码
- 提问者网友:放荡不羁
- 2021-05-24 02:32
- 二级知识专家网友:为你轻狂半世殇
- 2021-05-24 03:59
调用函数
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
' Dim hWnd As Long ' 储存 FindWindow 函数返回的句柄
Dim hWndt As Long ' 储存 FindWindow 函数返回的句柄
hWndt = FindWindow(vbNullString, "regsvr32") ' 取得进程标识符 '发现注册弹出窗口的句柄
If hWndt = hWndt Then
SendKeys "{enter}", True '如果为 False(缺省值),则控件在按键发送出去之后立刻返回到过程。如果为 True,则按键消息必须在控件返回到过程之前加以处理
End If