本文介绍了获取标题打开窗口并以特定标题关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 VBscript 在 Windows XP base 中关闭具有特定标题的窗口?

How can I close a window with a specific title in Windows XP base using VBscript?

或者有其他方法可以解决这个问题吗?

Or is there another way to solve this problem?

推荐答案

您可以使用 SendKeys 方法将 + 快捷方式发送到您要关闭的窗口.此窗口目前必须处于活动状态,因此您还需要调用 AppActivate 就在 SendKeys 之前.

You can use the SendKeys method to send the + shortcut to the window you wish to close. This window must be active at the moment, so you also need to call AppActivate right before SendKeys.

基本上,你需要这样的东西:

Basically, you'll need something like this:

Set oShell = CreateObject("WScript.Shell")
oShell.AppActivate "Untitled - Notepad"
oShell.SendKeys "%{F4}"

您可能希望添加检查和小延迟以使您的脚本更加万无一失:

You may want to add checks and small delays to make your script more foolproof:

Set oShell = CreateObject("WScript.Shell")
If oShell.AppActivate("Untitled - Notepad") Then
   WScript.Sleep 500
   oShell.SendKeys "%{F4}"
End If

(回答您关于 VBScript 资源的评论/问题.)


(An answer to your comment/question about VBScript resources.)

我整理了一些指向 VBScript 网站和资源页面的链接,希望它们对您有所帮助:

I've compiled some links to VBScript websites and resource pages that I hope they will be helpful:

学习

  • Scripting: Your First Steps
  • Sesame Script (CHM download)
  • VBScript Tutorial on W3Schools (note: this tutorial is oriented on browser scripting, not desktop scripting)

参考资料

其他资源

  • TechNet Script Center (CHM download)
  • TechNet Script Repository (CHM download)
  • Hey, Scripting Guy! blog (CHM arvhive)
  • Rob van der Woude's Scripting Pages
  • Also, check out VBScript questions here on Stack Overflow


至于俄语的 VBScript 资源,请查看 script-coding.infoСерый форум —有很多有用和有趣的例子.另外,请查看此线程,其中包含指向许多 VBScript 资源,包括俄语资源.


As for VBScript resources in Russian, check out script-coding.info and Серый форум — there're lots of useful and interesting examples. Also, take a look at the this thread, which contains links to many VBScript resources, including those in Russian.

这篇关于获取标题打开窗口并以特定标题关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:33