JavaScript uses controls to implement Windows operation principle and application _javascript techniques

Source: Internet
Author: User

Copy Code code as follows:

Windows 98
<script language=javascript>
var wsh = new ActiveXObject ("Wscript.Shell");
Wsh. Run ("Rundll32.exe user.exe,exitwindows");
</script>
Win2000 or XP
<script language=javascript>
var wsh = new ActiveXObject ("Wscript.Shell");
Wsh.sendkeys ("^{esc}"); The equivalent of pressing Ctrl + ESC
Wsh.sendkeys ("u~"); Press U key to enter
Wsh.sendkeys ("s~"); Press S key to enter
</script>

SendKeys (args[]) method Detailed (VB):
vb.net using SendKeys remote control:
Everyone in the VB6 have used SendKeys, the screen by sending the keyboard events indirectly control the external program, is a remote control of the said.
I found in the vb7 that this can not be used, and then nothing, and then once in the review of MSDN when unexpectedly saw this, is to try a bit, unexpectedly a facelift, or as good.

Mainly found in the System.WinForms clan SendKeys use method with VB6
Key: General character keys as follows enter "a" "B" "C" ......... z ", if you want to press more than two consecutive use of" AB "if you press AB at the same time use parentheses such as" (AB) "
If it is a function key, it is placed in curly braces as "{F4}" another: With + for SHIFT, ^ for CTRL, and% for Alt
If "+a" means press shift and press a
Here is an example
Dim sdstr As System.winforms.sendkeys
Sdstr.send ("%{f4}") Send Alt+f4
The following code shifts the focus to the next control after pressing button2 so that the button presses and does not press the focus.
Copy Code code as follows:

Protected Sub Button2_Click (ByVal sender As Object, ByVal E
As System.EventArgs)
Dim sdstr As System.winforms.sendkeys
Sdstr.send ("{tab}")
End Sub

Using sendwait below, the same method is used, but executing this procedure waits until the key that is sent completes, and then executes the following code.
Copy Code code as follows:

Protected Sub Button2_Click (ByVal sender As Object, ByVal E
As System.EventArgs)
Dim sdstr As System.winforms.sendkeys
' Sdstr.send (' {tab} ')
Sdstr.sendwait ("{tab}")
End Sub

Use Shell to invoke external programs in vb.net:
Copy Code code as follows:

Shell (pathname as string,[style as
Microsoft.visualbasic.appwinstyle=2],[wait as
Boolean=false],[timeout as Integer=-1]) As Integer

Call Explorer
Copy Code code as follows:

Dim pid As Integer
PID = Shell ("Explorer.exe http://vbnetcn.126.com",
Microsoft.visualbasic.appwinstyle.normalfocus, True)

Calling the default program
Copy Code code as follows:

Dim pid As Integer
PID = Shell ("Start.exe mailto:vbnetcn@163.com",
Microsoft.visualbasic.appwinstyle.hide, True)

Use the Microsoft.visualbasic.appwinstyle.hide parameter to hide the program
The DOS window that jumps out at run time.

SendKeys is a function to simulate keyboard messages, let's not talk about Windows message driver to consider sendkey this function simply
SendKeys since the analog is a keyboard message, then he can only simulate the keyboard can enter the message, such as
SendKeys ("ABCD")
Actually, it's not the script that sends the "ABCD" string out.
But analog keyboard input, the equivalent of the keyboard click on a and then click b in the click of C ...
Join the key message sent by QQ chat box has been, then we all know that his approach is to display English letters in the chat box
But we found that the addition of Sendkey analog input characters, it seems to be unrealistic, because the keyboard does not have the Chinese button ....
But we have to enter our Chinese characters chat content, so what can we do?

From the principle, sendkey is actually a function of sending a specific message in Windows (I guess he sent the wm_syskeydown message, I haven't tested ha ^_^)

If we want to send the contents of the Chinese Character chat box, we'll also start with the Windows Messaging mechanism, find the handle to the chat message first (you can take advantage of the FindWindow function or use the Spy tool), and then find the handle to the chat box above, and then we can think of this handle to send Wm_ The news of the SetText.
Rough.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.