Tips:
1. This action is required 1.8 seconds after each window jump, and it is only sent once. After sending, wait for the next window to jump out for recycling
2. In each cycle, only one Ctrl + V is sent and then it stops, instead of sending all the time

When you see the problem, start to write the test code immediately. At this time, the problem appears:

After the InputBox window pops up, VBS is in a suspended state, waiting for user input, click OK or cancel,

So the wshshell.sendkeys “^ V” after it will not execute,

If you click OK or cancel after the input box window pops up, then you can’t paste the contents of the clipboard into the input box window if you execute Ctrl + V again. If you put wshshell.sendkeys “^ V” before the input box, you can’t either, because the input box hasn’t popped up, or Ctrl + V can’t paste the contents into the input box,

Convert the following ideas. We write the InputBox and sendkey into two files, so that they will 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 “please input”, “prompt”, “”
fso.DeleteFile (“sendkey.vbs”)

The code first writes sendkey.vbs and executes. During execution, it will wait for 1.8 seconds to send Ctrl + V, and then input box pops up. At this time, input box pops up. Sendkey.vbs also executes Ctrl + V after waiting for 1.8 seconds to paste the content into input box

Conclusion: when we encounter some problems, we can’t get to the top of the heap. To change our thinking, it’s not difficult to solve them!