vb中点击按钮后,如何模拟鼠标动作自动全选文本框中所有文字

2024年11月30日 11:36
有3个网友回答
网友(1):

个人觉得一个过程好控制些
而且text1.selstart应为0而不是1

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
Dim l As Long
l = 0
Text1.SetFocus
Text1.SelStart = 0
Do While l <= Len(Text1) - Text1.SelStart
Text1.SelLength = l
l = l + 1
DoEvents
Sleep 50 '延时50毫秒
Loop
End Sub

难得你想实现按键精灵的效果?
用API mouse_event和 getwindowrect

网友(2):

建一个timer

模拟
Private Sub Timer1_Timer()
Text1.SelStart = 1
For i = 1 To Len(Text1)
Text1.SelLength = i
Next i
End Sub
速度由timer的interval决定

网友(3):

Text1.SelStart = 0
Text1.SelLength =len(Text1)