Board logo

标题: [问题求助] vbs用sendkeys方法登录远程的问题 [打印本页]

作者: saint_Zuo    时间: 2011-12-28 11:13     标题: vbs用sendkeys方法登录远程的问题

我想用sendkeys方法启用mstsc.exe然后登录远程。
登录的过程是先点击“远程登录界面1”的选项按钮,然后在“远程登录界面2”中进行用户名、密码的输入。
可问题是当运行到WshShell.SendKeys " ~"语句时程序并没有执行,也就是并没有模拟回车打开选项按钮,请教这是为什么?
  1. Dim WshShell
  2. set WshShell = CreateObject("wscript.Shell")
  3. WshShell.Run "mstsc.exe"
  4. WScript.Sleep 2000
  5. WshShell.SendKeys "{tab 4}"
  6. WshShell.SendKeys " ~"
  7. WScript.Sleep 2000
  8. WshShell.SendKeys "{tab}"
  9. WshShell.SendKeys "{tab}"
  10. WshShell.SendKeys "10.888.888.8"
  11. WshShell.SendKeys "{tab}"
  12. WshShell.SendKeys "user"
  13. WshShell.SendKeys "{tab}"
  14. WshShell.SendKeys "password"
  15. WshShell.SendKeys "{tab 5}"
  16. WshShell.SendKeys "{enter}"
复制代码

作者: Demon    时间: 2011-12-28 13:02

每次见到SendKeys我就蛋疼。
作者: rat    时间: 2011-12-28 14:42

空格和~都是点击按钮。
空格先把选项展开了,然后~又把它合上了。
所以空格和~只要其一即可!
作者: saint_Zuo    时间: 2011-12-28 15:43

回复 3# rat


    多谢了,但是我为什么用"enter"也不行呢?
作者: rat    时间: 2011-12-29 09:26

回复 4# saint_Zuo


    "{Enter}"
多看看微软的那个脚本帮助
作者: saint_Zuo    时间: 2011-12-29 10:45

本帖最后由 saint_Zuo 于 2011-12-29 10:46 编辑

回复 3# rat


    麻烦再帮忙看看吧,我去了空格变为"~"也不行。谢谢了。我感觉代码就是从第5句之后就不再运行了!
作者: saint_Zuo    时间: 2011-12-29 10:47

回复 5# rat


    有中文的吗?有的话麻烦提供一下,谢谢了。
作者: HAT    时间: 2011-12-29 11:20

回复 7# saint_Zuo


http://www.bathome.net/thread-13298-1-1.html
作者: saint_Zuo    时间: 2011-12-30 11:17

回复 8# HAT


    看了帮助但还是没解决问题.




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2