Brother jmz573515's sample code on the 3rd floor is very detailed and easy to understand~:)
Now let's explain the code given by Brother jmz573515:
set ws=wscript.createobject("wscript.shell")
ws.run "calc.exe" 'This is the program you want to run, write the full path.
' The above sentence is to run an application that will receive the key values you send. The above is to start the Windows calculator.
wscript.sleep 2000
' The above is to delay (that is, wait) for 2 seconds. That 2000 refers to milliseconds - 1 second is equal to 1000 milliseconds.
ws.sendkeys "12321" 'Here is the number you want to fill in.
' The above ws.SendKey is the instruction to send simulated key presses, sending the string 12321 to the calculator.
' Similarly, you can also send simulated keys, such as Enter, etc......
ws.sendkeys "~"
Brother, you can save the code on the 3rd floor as a file named "Calculator.VBS" and then double-click to execute it with the mouse.
Another thing: Brother, don't test the code you mentioned on the 5th floor for now. That is to write VBS code into a VBS script using batch processing.
So it also includes batch file operation skills, which actually increases the learning difficulty.
It is recommended to only test the code on the 3rd floor. Start with the Windows calculator, then try Notepad, and then try to control more complex applications.
The following are examples of key values that VBS can send:
(Part of the following key value list is taken from a certain website on the Internet, the original author is unknown)
For the SendKeys command, what can be sent, we can see the following list:
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
SHIFT +
CTRL ^
ALT %
Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._