Tip:
1. This action is triggered every 1.8 seconds after a window exists, and only one action is sent. Wait for the next window to jump out and recycle.
2. In each loop, only Ctrl + V is sent and then stopped, instead of sending it all the time.
When you see the problem, start writing the test now.CodeAt this time, the problem occurs:
After the inputbox window pops up, the vbs is paused. Wait for the user to enter the box and click OK or cancel,
So wshshell. sendkeys "^ V" after it cannot be executed,
If you click OK or cancel after the inputbox window pops up, you cannot paste the content in the clipboard into the inputbox window by pressing CTRL + v. sendkeys "^ V" won't work if it is placed before inputbox, because inputbox hasn't been popped up, And Ctrl + V cannot paste the content to inputbox,
In this way, we write inputbox and sendKey into two files so that they do not conflict with each other. The final solution code is as follows:Copy codeThe Code is as follows: Set wshshell = wscript. Createobject ("wscript. Shell ")
Wscript. Sleep 2000
Set FSO = wscript. Createobject ("scripting. FileSystemObject ")
Set F = FSO. opentextfile ("sendKey. vbs", 2, true)
F. Write ("set wshshell = wscript. Createobject (" & CHR (34) & "wscript. Shell" & CHR (34 )&")")
F. writeblanklines (1)
F. Write ("wscript. Sleep 1800 ")
F. writeblanklines (1)
F. Write ("wshshell. appactivate" & CHR (34) & "prompt" & CHR (34 ))
F. writeblanklines (1)
F. Write ("wshshell. sendkeys" & CHR (34) & "^ V" & CHR (34 ))
F. writeblanklines (1)
F. Close
Wshshell. Run ("sendKey. vbs ")
Inputbox "enter", "prompt ",""
FSO. deletefile ("sendKey. vbs ")
The code first writes sendKey. run the vbs command and wait for 1.8 seconds to send Ctrl + V. Then, inputbox is displayed. At this time, inputbox is displayed, and sendKey is displayed. after waiting for 1.8 seconds, vbs also runs Ctrl + V to paste the content into the inputbox input box. problem Solving
conclusion: When you encounter some problems, it is not difficult to solve them!