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

TOP

本帖最后由 fastslz 于 2011-5-10 15:01 编辑
  1. Dim tangshui,gansu,touxi,wshshell,aStrs,bStrs,cStrs
  2. Set WshShell = CreateObject ("Wscript.Shell")
  3. input=InputBox("糖水瓶数")
  4. aSelect(input)
  5. input=InputBox("肝素支数")
  6. bSelect(input)
  7. input=InputBox("透析器次数")
  8. cSelect(input)
  9. If Not  aStrs = "" Then
  10.    KeysNames = Split(aStrs, ",")
  11.    For i = 0 to UBound(KeysNames)
  12.        Wshshell.SendKeys KeysNames(i)
  13.    Next
  14. End If
  15. If Not  bStrs = "" Then
  16.    KeysNames = Split(bStrs, ",")
  17.    For i = 0 to UBound(KeysNames)
  18.        Wshshell.SendKeys KeysNames(i)
  19.    Next
  20. End If
  21. Wshshell.SendKeys "xytx"
  22. Wscript.sleep 20 '若想连续模拟按键稳定性,每个模拟按键延时20毫秒,延时多少取决于你的计算机性能
  23. Wshshell.SendKeys "{ENTER}"
  24. Wscript.sleep 20
  25. Wshshell.SendKeys "{ENTER}"
  26. Wscript.sleep 20
  27. Wshshell.SendKeys "{ENTER}"
  28. Wscript.sleep 20
  29. Wshshell.SendKeys "{ENTER}"
  30. Wscript.sleep 20
  31. Wshshell.SendKeys "{ENTER}"
  32. Wshshell.SendKeys "xtjc"
  33. Wscript.sleep 20
  34. Wshshell.SendKeys "{ENTER}"
  35. Wscript.sleep 20
  36. Wshshell.SendKeys "{ENTER}"
  37. Wscript.sleep 20
  38. Wshshell.SendKeys "{ENTER}"
  39. Wscript.sleep 20
  40. Wshshell.SendKeys "{ENTER}"
  41. Wscript.sleep 20
  42. Wshshell.SendKeys "{ENTER}"
  43. Wshshell.SendKeys "ycxg"
  44. Wscript.sleep 20
  45. Wshshell.SendKeys "{ENTER}"
  46. Wscript.sleep 20
  47. Wshshell.SendKeys "{ENTER}"
  48. Wscript.sleep 20
  49. Wshshell.SendKeys "{ENTER}"
  50. Wscript.sleep 20
  51. Wshshell.SendKeys "{ENTER}"
  52. If Not  cStrs = "" Then
  53.    KeysNames = Split(cStrs, ",")
  54.    For i = 0 to UBound(KeysNames)
  55.        Wshshell.SendKeys KeysNames(i)
  56.    Next
  57. End If
  58. Function aSelect(N)
  59.     Select Case N
  60.         Case 0
  61.         aStrs = ""
  62.              Exit Function
  63.         Case Else
  64.              aStrs = "lhn,{ENTER},{ENTER}," & N & ",{ENTER},{ENTER},{ENTER}"
  65.     End Select
  66. End Function
  67. Function bSelect(B)
  68.     Select Case B
  69.         Case 0
  70.         bStrs = ""
  71.              Exit Function
  72.         Case Else
  73.              bStrs = "gsz,{ENTER},{ENTER}," & B & ",{ENTER},{ENTER},{ENTER}"
  74.     End Select
  75. End Function
  76. Function cSelect(c)
  77.     Select Case c
  78.         Case 0
  79.         cStrs = ""
  80.              Exit Function
  81.         Case Else
  82.              cStrs = "txq,{ENTER},{ENTER},{ENTER},{ENTER}"
  83.     End Select
  84. End Function
复制代码
下面的代码更稳定,但必须安装word,例子为循环等待记事本窗体,发现窗体就模拟按键,仅供参考
  1. Dim tangshui,gansu,touxi,wshshell,aStrs,bStrs,cStrs
  2. Set WshShell = CreateObject ("Wscript.Shell")
  3. input=InputBox("糖水瓶数")
  4. aSelect(input)
  5. input=InputBox("肝素支数")
  6. bSelect(input)
  7. input=InputBox("透析器次数")
  8. cSelect(input)
  9. If Not  aStrs = "" Then
  10.    KeysNames = Split(aStrs, ",")
  11.    For i = 0 to UBound(KeysNames)
  12.        aWindow("记事本")
  13.        Wshshell.SendKeys KeysNames(i)
  14.    Next
  15. End If
  16. If Not  bStrs = "" Then
  17.    KeysNames = Split(bStrs, ",")
  18.    For i = 0 to UBound(KeysNames)
  19.        aWindow("记事本")
  20.        Wshshell.SendKeys KeysNames(i)
  21.    Next
  22. End If
  23. aWindow("记事本")
  24. Wshshell.SendKeys "xytx"
  25. Wscript.sleep 20 '若想连续模拟按键稳定性,每个模拟按键延时20毫秒,延时多少取决于你的计算机性能
  26. Wshshell.SendKeys "{ENTER}"
  27. Wscript.sleep 20
  28. Wshshell.SendKeys "{ENTER}"
  29. Wscript.sleep 20
  30. Wshshell.SendKeys "{ENTER}"
  31. Wscript.sleep 20
  32. Wshshell.SendKeys "{ENTER}"
  33. Wscript.sleep 20
  34. Wshshell.SendKeys "{ENTER}"
  35. aWindow("记事本")
  36. Wshshell.SendKeys "xtjc"
  37. Wscript.sleep 20
  38. Wshshell.SendKeys "{ENTER}"
  39. Wscript.sleep 20
  40. Wshshell.SendKeys "{ENTER}"
  41. Wscript.sleep 20
  42. Wshshell.SendKeys "{ENTER}"
  43. Wscript.sleep 20
  44. Wshshell.SendKeys "{ENTER}"
  45. Wscript.sleep 20
  46. Wshshell.SendKeys "{ENTER}"
  47. aWindow("记事本")
  48. Wshshell.SendKeys "ycxg"
  49. Wscript.sleep 20
  50. Wshshell.SendKeys "{ENTER}"
  51. Wscript.sleep 20
  52. Wshshell.SendKeys "{ENTER}"
  53. Wscript.sleep 20
  54. Wshshell.SendKeys "{ENTER}"
  55. Wscript.sleep 20
  56. Wshshell.SendKeys "{ENTER}"
  57. If Not  cStrs = "" Then
  58.    KeysNames = Split(cStrs, ",")
  59.    For i = 0 to UBound(KeysNames)
  60.        aWindow("记事本")
  61.        Wshshell.SendKeys KeysNames(i)
  62.    Next
  63. End If
  64. Function aSelect(N)
  65.     Select Case N
  66.         Case 0
  67.         aStrs = ""
  68.              Exit Function
  69.         Case Else
  70.              aStrs = "lhn,{ENTER},{ENTER}," & N & ",{ENTER},{ENTER},{ENTER}"
  71.     End Select
  72. End Function
  73. Function bSelect(B)
  74.     Select Case B
  75.         Case 0
  76.         bStrs = ""
  77.              Exit Function
  78.         Case Else
  79.              bStrs = "gsz,{ENTER},{ENTER}," & B & ",{ENTER},{ENTER},{ENTER}"
  80.     End Select
  81. End Function
  82. Function cSelect(c)
  83.     Select Case c
  84.         Case 0
  85.         cStrs = ""
  86.              Exit Function
  87.         Case Else
  88.              cStrs = "txq,{ENTER},{ENTER},{ENTER},{ENTER}"
  89.     End Select
  90. End Function
  91. Sub aWindow(WindowT)
  92. Set objWord = CreateObject("Word.Application")
  93. Set colTasks = objWord.Tasks
  94. Do
  95.     If colTasks.Exists(WindowT) Then
  96.        colTasks(WindowT).Activate
  97.        colTasks(WindowT).WindowState = 0
  98.        Exit Do
  99.     End If
  100.     Wscript.sleep 200
  101. Loop
  102. objWord.Quit
  103. End Sub
复制代码

TOP

本帖最后由 fastslz 于 2011-5-10 14:59 编辑

再给你一个方法
  1. Dim tangshui,gansu,touxi,wshshell,aStrs,bStrs,cStrs,dStrs
  2. Set WshShell = CreateObject ("Wscript.Shell")
  3. input=InputBox("糖水瓶数")
  4. aSelect(input)
  5. input=InputBox("肝素支数")
  6. bSelect(input)
  7. input=InputBox("透析器次数")
  8. cSelect(input)
  9. If Not  aStrs = "" Then
  10.    KeysNames = Split(aStrs, ",")
  11.    WshShell.AppActivate "程序窗体名称"           '用于激活你的程序窗体,不至于在其他窗体上乱按
  12.    For i = 0 to UBound(KeysNames)
  13.        Wscript.sleep 20
  14.        Wshshell.SendKeys KeysNames(i)
  15.    Next
  16. End If
  17. If Not  bStrs = "" Then
  18.    KeysNames = Split(bStrs, ",")
  19.    WshShell.AppActivate "程序窗体名称"           '用于激活你的程序窗体,不至于在其他窗体上乱按
  20.    For i = 0 to UBound(KeysNames)
  21.        Wscript.sleep 20
  22.        Wshshell.SendKeys KeysNames(i)
  23.    Next
  24. End If
  25. dStrs = "xytx,{ENTER},{ENTER},{ENTER},{ENTER},{ENTER},xtjc,{ENTER},{ENTER},{ENTER},{ENTER},{ENTER},ycxg,{ENTER},{ENTER},{ENTER},{ENTER}"
  26. If Not  dStrs = "" Then
  27.    KeysNames = Split(dStrs, ",")
  28.    WshShell.AppActivate "程序窗体名称"           '用于激活你的程序窗体,不至于在其他窗体上乱按
  29.    For i = 0 to UBound(KeysNames)
  30.        Wscript.sleep 20
  31.        Wshshell.SendKeys KeysNames(i)
  32.    Next
  33. End If
  34. If Not  cStrs = "" Then
  35.    KeysNames = Split(cStrs, ",")
  36.    WshShell.AppActivate "程序窗体名称"           '用于激活你的程序窗体,不至于在其他窗体上乱按
  37.    For i = 0 to UBound(KeysNames)
  38.        Wscript.sleep 20
  39.        Wshshell.SendKeys KeysNames(i)
  40.    Next
  41. End If
  42. Function aSelect(N)
  43.     Select Case N
  44.         Case 0
  45.         aStrs = ""
  46.              Exit Function
  47.         Case Else
  48.              aStrs = "lhn,{ENTER},{ENTER}," & N & ",{ENTER},{ENTER},{ENTER}"
  49.     End Select
  50. End Function
  51. Function bSelect(B)
  52.     Select Case B
  53.         Case 0
  54.         bStrs = ""
  55.              Exit Function
  56.         Case Else
  57.              bStrs = "gsz,{ENTER},{ENTER}," & B & ",{ENTER},{ENTER},{ENTER}"
  58.     End Select
  59. End Function
  60. Function cSelect(c)
  61.     Select Case c
  62.         Case 0
  63.         cStrs = ""
  64.              Exit Function
  65.         Case Else
  66.              cStrs = "txq,{ENTER},{ENTER},{ENTER},{ENTER}"
  67.     End Select
  68. End Function
复制代码

TOP

17# fastslz
18# fastslz
谢谢,谢谢fastslz 大大给出的完美解决办法,实在是太感谢了!!!!!!

TOP

这个好用,留个记号!!!!

TOP

该脚本我已经使用了大半年,今日想起,心存感激,特来再次感谢

TOP

返回列表