如何安排带有UI元素的.vbs脚本? [英] How to schedule a .vbs script with UI elements?

查看:294
本文介绍了如何安排带有UI元素的.vbs脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是vb脚本的新手.我需要安排可以运行vbs文件的Windows任务. 该脚本从其快捷方式打开一个应用程序,输入用户名和密码并执行登录. 换句话说,我需要自动化重启过程. 手动打开时,脚本将按预期运行,但是调度程序无法运行它. 我认为问题出在那些UI元素(用于登录). 请提出如何解决它的建议. 谢谢!

解决方案

如果出于某种原因将窗口最小化,AppActivate不会自行还原窗口.

您可以尝试找到使其最小化的原因(也许与批处理调用vbs调用应用程序有关,我不能真正说出这一点),也可以尝试对vbscript进行如下修改:/p>

在AppActivate之后执行以下操作:

oShell.SendKeys "% r"

这等效于 Alt + SpaceBar r ,因此它将打开最大化",最小化",还原"选项的窗口对话框,然后选择还原" .

请注意,在Windows的英文副本上,该字符可能仅是 r .如果您使用另一种语言,请通过按 Alt + SpaceBar 手动打开该菜单,然后查看系统上实际的热键是什么(在对话框中带下划线).然后,用您的语言使用的任何热键替换脚本中的r.

I am new to vb scripting. I need to schedule a windows task which can run a vbs file. The script opens up a application from its shortcut, feeds username and password and performs login. In other words, I need to automate the restart process. The scripts runs as expected when opened manually but scheduler cannot not run it. I think the problem is with those UI elements(used for login). Please suggest how to get through it. Thank you!

解决方案

AppActivate does not itself restore the window if it is for some reason minimized.

You can try to find the reason why it's minimized (maybe it has something to do with the batch calling the vbs calling the application, I cannot really say) or you can try a little hack in the vbscript like the following:

After the AppActivate do a:

oShell.SendKeys "% r"

This is equivalent of Alt+SpaceBar, r so it opens the windows dialog for Maximize, Minimize, Restore options and choses "Restore".

Note that this might only be r on english copies of windows. If you use another Language manually open that menu by pressing Alt+SpaceBar and looking what the actual hotkey on your system is (it would be underlined in the dialog). Afterwards replace the r in the script with whatever hotkey is used in your language.

这篇关于如何安排带有UI元素的.vbs脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆