level 3
wwwylg
楼主
set shell = createobject("WScript.Shell")
Shell.Run "cmd.exe"
Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
For Each Process In Processes
If StrComp(Process.Name, "cmd.exe", vbTextCompare) = 0 Then
'用进程ID激活窗口
With CreateObject("WScript.Shell")
.AppActivate Process.ProcessId
.SendKeys "4"
End With
'找到了进程ID,退出FOR
Exit For
End If
Next
2022年08月01日 11点08分
1
Shell.Run "cmd.exe"
Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
For Each Process In Processes
If StrComp(Process.Name, "cmd.exe", vbTextCompare) = 0 Then
'用进程ID激活窗口
With CreateObject("WScript.Shell")
.AppActivate Process.ProcessId
.SendKeys "4"
End With
'找到了进程ID,退出FOR
Exit For
End If
Next