Copy code The code is as follows: //windows 98 <br>//var wsh = new ActiveXObject("WScript.Shell"); <br>//wsh.Run("rundll32.exe user.exe,exitWindows"); <br> //win2000 or xp <br>var wsh = new ActiveXObject("WScript.Shell"); <br>wsh.sendKeys("^{ESC}"); // Equivalent to pressing the Ctrl ESC key<br>wsh.sendKeys("U~"); //Press the U key to enter<br>wsh.sendKeys("S~"); //Press the S key to enter<br>< ;/script> <br> </div> <br>Detailed explanation of sendKeys(args[]) method (VB): <br>Use sendkeys remote control in vb.net: <br>Everyone has used sendkeys in vb6, and the screen passed Sending keyboard events to indirectly control external programs is called remote control. <br>I found this in vb7 and it didn’t work, so I left it alone. Then I saw this when I checked msdn, so I tried it, and it still works just as well as it has a new look. <br><br> Mainly find sendkeys in the system.winforms family. The usage method is the same as vb6 <br> key: the general character keys are as follows: "a" "b" "c"…………"z", etc. , if you want to press more than two consecutive keys, use the form of "ab". If press ab at the same time, use brackets such as "(ab)" <br>If it is a function key, put it in braces such as "{f4}" Another: use represents shift, ^ represents ctrl, and % represents alt <br> For example, "a" means pressing shift and pressing a at the same time <br><strong>The following is an example </strong>: <br>dim sdstr as system .winforms.sendkeys <br>sdstr.send("%{f4}") Send alt f4 <br>The following code transfers the focus to the next control after pressing button2, so that the button can be pressed but cannot receive focus. <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="124" class="copybut" id="copybut124" onclick="doCopy('code124')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code124"> <br>protected sub button2_click(byval sender as object, byval e <br>as system.eventargs) <br>dim sdstr as system.winforms.sendkeys <br>sdstr.send("{tab}") <br>end sub <br> </div> <br>Use sendwait below, use The method is the same as above, but executing this process will wait until the sent key is executed before continuing to execute the following code. <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="78098" class="copybut" id="copybut78098" onclick="doCopy('code78098')"><u>Copy code</u></a></span> The code is as follows: </div> <div class="codebody" id="code78098"> <br>protected sub button2_click(byval sender as object, byval e <br>as system.eventargs) <br>dim sdstr as system.winforms.sendkeys <br>'sdstr.send ("{tab}") <br>sdstr.sendwait("{tab}") <br>end sub <br> </div> <br>Use shell in vb.net to call external programs: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="17618" class="copybut" id="copybut17618" onclick="doCopy('code17618')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code17618"> <br>shell(pathname as string,[style as <br>microsoft.visualbasic.appwinstyle= 2],[wait as <br>boolean=false],[timeout as integer=-1]) as integer <br> </div> <br>Call the resource manager <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="99056" class="copybut" id="copybut99056" onclick="doCopy('code99056')"> <u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code99056"> <br>dim pid as integer <br>pid = shell("explorer.exe http://vbnetcn.126.com ", <br>microsoft.visualbasic.appwinstyle.normalfocus, true) <br> </div> <br>Call the default program<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="81302" class="copybut" id="copybut81302" onclick="doCopy('code81302')"><u>Copy code</u></a> </span> The code is as follows: </div> <div class="codebody" id="code81302"> <br>dim pid as integer <br>pid = shell("start.exe mailto:vbnetcn@163.com", <br>microsoft.visualbasic.appwinstyle.hide, true) <br> </div> <br>Use the microsoft.visualbasic.appwinstyle.hide parameter to hide the DOS window that pops up when the program is running. <br><br>sendkeys is a function that simulates keyboard messages. Let’s not talk about the windows message driver for now and simply consider the sendkey function. <br>Since sendkeys simulates keyboard messages, it can only simulate what can be input on the keyboard. Messages, such as <br>sendkeys("abcd") <br>In fact, it is not this script that sends the string "abcd" <br> but simulates keyboard input, which is equivalent to the keyboard clicking a first and then clicking b clicked c. . . . . <br>The key message sent by Join was received by the QQ chat box, so we all know that his solution is to display English letters in the chat box <br> But we found that if Join uses sendkey to simulate inputting Chinese characters, it seems that It’s unrealistic because there are no Chinese keys on the keyboard. . . . <br>But we have chat content that we want to enter our Chinese characters, so what can we do? <br><br>Let’s talk about the principle. Sendkey is actually a function that sends a specific message in Windows (I guess it sends the WM_SYSKEYDOWN message, I haven’t tested it^_^) <br><br>If we want to send the content of the chat box with Chinese characters, we must also start with the windows message mechanism. First find the handle of the chat message (you can use the findwindow function or use the spy tool), and then find the handle of the chat box above. Then we can send the WM_SETTEXT message to this handle. <br>Rough<br>