[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 1# dawei124578


    嗯,先提供个思路:
不用检测是否为6:00,用 at命令计划任务,然后用VBS运行程序和模拟按键。现在不在电脑旁边,晚上我回去再看看
---学无止境---

TOP

记住最后那部分发送模拟按键的,根据你的需要自己修改可以了,其他功能都OK了
  1. @rem 保存我为 AutoWork.bat
  2. @echo off
  3. if not exist Work.vbs more +6 "%~f0">Work.vbs
  4. at 6:00 /interactive "Work.vbs"
  5. exit
  6. Dim wsh,strPath,fso
  7. Set fso = CreateObject("Scripting.FileSystemObject")
  8. Rem 下面是程序的路径
  9. strPath = "C:\Dos.exe"
  10. set wsh = CreateObject("WScript.Shell")
  11. fso.CreateFolder wsh.SpecialFolders("Desktop") & "\" _
  12. & DatePart("yyyy",Date) & "-" _
  13. & DatePart("m",Date) & "-" _
  14. & DatePart("d",Date)
  15. wsh.Run strPath
  16. WScript.Sleep 3000 '延时3秒
  17. wsh.SendKeys "test"
  18. WScript.Sleep 500
  19. wsh.SendKeys "{enter}"
  20. WScript.Sleep 500
  21. wsh.SendKeys "test"
  22. WScript.Sleep 500
  23. wsh.SendKeys "{enter}"
  24. Rem 重复用上面的步骤直到输入完你要输入的值
复制代码
---学无止境---

TOP

本帖最后由 broly 于 2011-8-28 12:59 编辑

回复 4# dawei124578


    嗯,是的,现在你目前的操作都是对的。还有,那个VBS不用你手动去打开,我用批处理加了计划任务,到6:00会自己打开的了(当然,前提是你开机了)。你只是下班前打开批处理文件就可以了

还有你的代码有点错误,就是  delete 键。这些特殊键要加个括号  {delete}

参考:http://baike.baidu.com/view/1133305.htm
  1. @rem 保存我为 AutoWork.bat
  2. @echo off
  3. more +6 "%~f0">Work.vbs
  4. at 6:00 /interactive "Work.vbs"
  5. exit
  6. Dim wsh,strPath,fso
  7. Set fso = CreateObject("Scripting.FileSystemObject")
  8. Rem 下面是程序的路径
  9. strPath = "C:\PROGRA~1\Dos\Dos.exe 212.1.30.45"
  10. set wsh = CreateObject("WScript.Shell")
  11. fso.CreateFolder wsh.SpecialFolders("Desktop") & "\" _
  12.         & DatePart("yyyy",Date) & "-" _
  13.         & DatePart("m",Date) & "-" _
  14.         & DatePart("d",Date)
  15. wsh.Run strPath
  16. WScript.Sleep 3000 '延时3秒
  17. wsh.SendKeys "qwe2100"
  18. WScript.Sleep 500
  19. wsh.SendKeys "{enter}"
  20. WScript.Sleep 500
  21. wsh.SendKeys "qqq111"
  22. WScript.Sleep 500
  23. wsh.SendKeys "{enter}"
  24. WScript.Sleep 500
  25. wsh.SendKeys "{DELETE}"
  26. WScript.Sleep 500
  27. wsh.SendKeys "sh bbw.sh"
  28. WScript.Sleep 500
  29. wsh.SendKeys "{enter}"
  30. WScript.Sleep 500
  31. wsh.SendKeys "qqq11100"
  32. WScript.Sleep 500
  33. wsh.SendKeys "{enter}"
  34. WScript.Sleep 500
  35. wsh.SendKeys "20100101"
  36. WScript.Sleep 500
  37. wsh.SendKeys "{enter}"
  38. WScript.Sleep 500
  39. wsh.SendKeys "20100228"
  40. WScript.Sleep 500
  41. wsh.SendKeys "{enter}"
  42. Rem 重复用上面的步骤直到输入完你要输入的值
复制代码
---学无止境---

TOP

你什么时候按的?你指的6:00是早上的吗?
---学无止境---

TOP

回复 8# dawei124578


    你现在运行一次批处理,然后在命令提示符下输入 at ,然后回车,看看里面的内容是什么
---学无止境---

TOP

回复 10# dawei124578


    呵呵,我说呢,原来你的  at 服务都还没开通。解决方法:控制面板->管理工具->服务->开启Task Scheduler服务
黑框闪一下就没了是正常的,因为运行完了就退出了。
---学无止境---

TOP

回复 12# dawei124578


    你重复9楼的步骤看看成功了没
---学无止境---

TOP

呵呵,sorry,有个地方弄错了,现在你试试下面的代码
  1. @rem 保存我为 AutoWork.bat
  2. @echo off
  3. more +6 "%~f0">Work.vbs
  4. at 6:00 /interactive "%~dp0Work.vbs"
  5. exit
  6. Dim wsh,strPath,fso
  7. Set fso = CreateObject("Scripting.FileSystemObject")
  8. Rem 下面是程序的路径
  9. strPath = "C:\112.txt"
  10. set wsh = CreateObject("WScript.Shell")
  11. fso.CreateFolder wsh.SpecialFolders("Desktop") & "\" _
  12.         & DatePart("yyyy",Date) & "-" _
  13.         & DatePart("m",Date) & "-" _
  14.         & DatePart("d",Date)
  15. wsh.Run strPath
  16. WScript.Sleep 3000 '延时3秒
  17. wsh.SendKeys "qwe2100"
  18. WScript.Sleep 500
  19. wsh.SendKeys "{enter}"
  20. WScript.Sleep 500
  21. wsh.SendKeys "qqq111"
  22. WScript.Sleep 500
  23. wsh.SendKeys "{enter}"
  24. WScript.Sleep 500
  25. wsh.SendKeys "{DELETE}"
  26. WScript.Sleep 500
  27. wsh.SendKeys "sh bbw.sh"
  28. WScript.Sleep 500
  29. wsh.SendKeys "{enter}"
  30. WScript.Sleep 500
  31. wsh.SendKeys "qqq11100"
  32. WScript.Sleep 500
  33. wsh.SendKeys "{enter}"
  34. WScript.Sleep 500
  35. wsh.SendKeys "20100101"
  36. WScript.Sleep 500
  37. wsh.SendKeys "{enter}"
  38. WScript.Sleep 500
  39. wsh.SendKeys "20100228"
  40. WScript.Sleep 500
  41. wsh.SendKeys "{enter}"
  42. Rem 重复用上面的步骤直到输入完你要输入的值
复制代码
2

评分人数

---学无止境---

TOP

回复 16# dawei124578


    嗯,没事,不用客气
---学无止境---

TOP

返回列表