vbscript : getting application window text

独自空忆成欢 提交于 2021-02-07 09:07:58

问题


I am automating the application installation using vbs. I have a code which launches the setup exe file and proceed further with sending the keystroks. But now I need to get the text of the installer window. I can get the title of installer window(using objShell.AppActivate ) but didn't found the way to get the text of that window. Is there any way to capture this in vbs?


回答1:


An alternative could be to enumerate process command lines instead of windows:

Dim WshShell
Set WshShell = CreateObject("Wscript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")

For Each objProcess in colProcesses
  If InStr(objProcess.CommandLine,"notepad")>0 Then
    WshShell.AppActivate objProcess.ProcessId  
 End If
Next


来源:https://stackoverflow.com/questions/16502385/vbscript-getting-application-window-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!