重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
既然你可以输入英文,只要系统切换到中文输入方式下,例如“谷歌拼音”,不就可以输入中文了
我们提供的服务有:成都网站设计、成都做网站、微信公众号开发、网站优化、网站认证、大庆ssl等。为超过千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的大庆网站制作公司
假如Form1有个TextBox1,双击TextBox1填入123
Public Class Form1
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
System.Windows.Forms.SendKeys.Send("123")
End Sub
End Class
看你的VB.NET 版本了
用 My.Computer.Keyboard.SendKeys("123", True) 代替 System.Windows.Forms.SendKeys.Send("123") 也可以
原码:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.DoubleClick
My.Computer.Keyboard.SendKeys("123", True)
End Sub
End Class
'这个需要用PostMessage,不能用keybd_event。
'看看这两个函数的声明就明白了。
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
'因为PostMessage声明中有句柄参数hwnd,而keybd_event声明中没有句柄参数。
'所以PostMessage可以指向键盘消息发送对象的句柄hwnd,而keybd_event只能模拟按哪个键盘,不能把键盘消息发送到指定的对象,如文本框。
'"源码可以参考"'
Call Mida("2.1458", A, B, C)
msgbox(A)
msgbox(B)
msgbox(C)
Sub Mida(Myi As integer,ByRef A As Integer, ByRef B As Integer, ByRef C As Integer)
msgbox(myi)
A=2
B= 14
C = 58
End Sub
以上是过程,如果是在模块里就将Sub改用Function