本帖最后由 fastslz 于 2011-5-10 15:01 编辑
- Dim tangshui,gansu,touxi,wshshell,aStrs,bStrs,cStrs
- Set WshShell = CreateObject ("Wscript.Shell")
- input=InputBox("糖水瓶数")
- aSelect(input)
- input=InputBox("肝素支数")
- bSelect(input)
- input=InputBox("透析器次数")
- cSelect(input)
-
- If Not aStrs = "" Then
- KeysNames = Split(aStrs, ",")
- For i = 0 to UBound(KeysNames)
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- If Not bStrs = "" Then
- KeysNames = Split(bStrs, ",")
- For i = 0 to UBound(KeysNames)
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- Wshshell.SendKeys "xytx"
- Wscript.sleep 20 '若想连续模拟按键稳定性,每个模拟按键延时20毫秒,延时多少取决于你的计算机性能
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- Wshshell.SendKeys "xtjc"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- Wshshell.SendKeys "ycxg"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- If Not cStrs = "" Then
- KeysNames = Split(cStrs, ",")
- For i = 0 to UBound(KeysNames)
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- Function aSelect(N)
- Select Case N
- Case 0
- aStrs = ""
- Exit Function
- Case Else
- aStrs = "lhn,{ENTER},{ENTER}," & N & ",{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
-
- Function bSelect(B)
- Select Case B
- Case 0
- bStrs = ""
- Exit Function
- Case Else
- bStrs = "gsz,{ENTER},{ENTER}," & B & ",{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
-
- Function cSelect(c)
- Select Case c
- Case 0
- cStrs = ""
- Exit Function
- Case Else
- cStrs = "txq,{ENTER},{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
复制代码 下面的代码更稳定,但必须安装word,例子为循环等待记事本窗体,发现窗体就模拟按键,仅供参考- Dim tangshui,gansu,touxi,wshshell,aStrs,bStrs,cStrs
- Set WshShell = CreateObject ("Wscript.Shell")
- input=InputBox("糖水瓶数")
- aSelect(input)
- input=InputBox("肝素支数")
- bSelect(input)
- input=InputBox("透析器次数")
- cSelect(input)
-
- If Not aStrs = "" Then
- KeysNames = Split(aStrs, ",")
- For i = 0 to UBound(KeysNames)
- aWindow("记事本")
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- If Not bStrs = "" Then
- KeysNames = Split(bStrs, ",")
- For i = 0 to UBound(KeysNames)
- aWindow("记事本")
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- aWindow("记事本")
- Wshshell.SendKeys "xytx"
- Wscript.sleep 20 '若想连续模拟按键稳定性,每个模拟按键延时20毫秒,延时多少取决于你的计算机性能
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- aWindow("记事本")
- Wshshell.SendKeys "xtjc"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- aWindow("记事本")
- Wshshell.SendKeys "ycxg"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
- Wscript.sleep 20
- Wshshell.SendKeys "{ENTER}"
-
- If Not cStrs = "" Then
- KeysNames = Split(cStrs, ",")
- For i = 0 to UBound(KeysNames)
- aWindow("记事本")
- Wshshell.SendKeys KeysNames(i)
- Next
- End If
-
- Function aSelect(N)
- Select Case N
- Case 0
- aStrs = ""
- Exit Function
- Case Else
- aStrs = "lhn,{ENTER},{ENTER}," & N & ",{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
-
- Function bSelect(B)
- Select Case B
- Case 0
- bStrs = ""
- Exit Function
- Case Else
- bStrs = "gsz,{ENTER},{ENTER}," & B & ",{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
-
- Function cSelect(c)
- Select Case c
- Case 0
- cStrs = ""
- Exit Function
- Case Else
- cStrs = "txq,{ENTER},{ENTER},{ENTER},{ENTER}"
- End Select
- End Function
-
- Sub aWindow(WindowT)
- Set objWord = CreateObject("Word.Application")
- Set colTasks = objWord.Tasks
- Do
- If colTasks.Exists(WindowT) Then
- colTasks(WindowT).Activate
- colTasks(WindowT).WindowState = 0
- Exit Do
- End If
- Wscript.sleep 200
- Loop
- objWord.Quit
- End Sub
复制代码
|