//windows 98
//win2000 or xp
Detailed explanation of sendKeys(args[]) method (VB):
Use sendkeys remote control in vb.net:
Everyone has used sendkeys in vb6, and the screen passed Sending keyboard events to indirectly control external programs is called remote control.
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.
Mainly find sendkeys in the system.winforms family. The usage method is the same as vb6
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)"
If it is a function key, put it in braces such as "{f4}" Another: use represents shift, ^ represents ctrl, and % represents alt
For example, "a" means pressing shift and pressing a at the same time
The following is an example :
dim sdstr as system .winforms.sendkeys
sdstr.send("%{f4}") Send alt f4
The following code transfers the focus to the next control after pressing button2, so that the button can be pressed but cannot receive focus.
protected sub button2_click(byval sender as object, byval e
as system.eventargs)
dim sdstr as system.winforms.sendkeys
sdstr.send("{tab}")
end sub
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.
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 in vb.net to call external programs:
shell(pathname as string,[style as
microsoft.visualbasic.appwinstyle= 2],[wait as
boolean=false],[timeout as integer=-1]) as integer
Call the resource manager
dim pid as integer
pid = shell("explorer.exe http://vbnetcn.126.com ",
microsoft.visualbasic.appwinstyle.normalfocus, true)
Call the default program
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 DOS window that pops up when the program is running.
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.
Since sendkeys simulates keyboard messages, it can only simulate what can be input on the keyboard. Messages, such as
sendkeys("abcd")
In fact, it is not this script that sends the string "abcd"
but simulates keyboard input, which is equivalent to the keyboard clicking a first and then clicking b clicked c. . . . .
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
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. . . .
But we have chat content that we want to enter our Chinese characters, so what can we do?
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^_^)
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.
Rough