16,554
社区成员
发帖
与我相关
我的任务
分享
Dim IsSelectedAll As Boolean
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
Dim p0 As Point = Cursor.Position
Dim p As Point = ComboBox1.PointToScreen(New Point(ComboBox1.Width - 23, 5))
Dim p1 As Point = ComboBox1.PointToScreen(New Point(0, 5))
If p0.X > p1.X And p0.X < p.X Then
If Not IsSelectedAll Then
ComboBox1.SelectionStart = ComboBox1.Text.Length
ComboBox1.SelectionLength = 0
SendKeys.Send("+{LEFT " & ComboBox1.Text.Length & "}")
IsSelectedAll = True
Else
IsSelectedAll = False
End If
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
SendKeys.Send("{RIGHT}")
SendKeys.Send("+{LEFT " & ComboBox1.Text.Length & "}")
IsSelectedAll = True
End Sub
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
Dim p0 As Point = Cursor.Position
Dim p As Point = ComboBox1.PointToScreen(New Point(ComboBox1.Width - 23, 5))
Dim p1 As Point = ComboBox1.PointToScreen(New Point(0, 5))
If p0.X > p1.X And p0.X < p.X Then
ComboBox1.SelectionStart = ComboBox1.Text.Length 要加上这一句
ComboBox1.SelectionLength = 0
SetCursorPos(p.X, p.Y)
mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0)
mouse_event(MOUSEEVENTF_MOVE, -2000, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, p1.X, p.Y, 0, 0)
SetCursorPos(p0.X, p0.Y)
End If
End Sub
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
Dim p0 As Point = Cursor.Position
Dim p As Point = ComboBox1.PointToScreen(New Point(ComboBox1.Width - 23, 5))
Dim p1 As Point = ComboBox1.PointToScreen(New Point(0, 5))
If p0.X > p1.X And p0.X < p.X Then
SetCursorPos(p.X, p.Y)
mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0)
mouse_event(MOUSEEVENTF_MOVE, -2000, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, p1.X, p.Y, 0, 0)
SetCursorPos(p0.X, p0.Y)
End If
End Sub
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
Dim p0 As Point = Cursor.Position
Dim p As Point = ComboBox1.PointToScreen(New Point(ComboBox1.Width - 23, 5))
Dim p1 As Point = ComboBox1.PointToScreen(New Point(0, 5))
If p0.X > p1.X And p0.X < p.X Then
ComboBox1.SelectionStart = ComboBox1.Text.Length
ComboBox1.SelectionLength = 0
SendKeys.Send("+{LEFT " & ComboBox1.Text.Length & "}")
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
SendKeys.Send("{RIGHT}")
SendKeys.Send("+{LEFT " & ComboBox1.Text.Length & "}")
End Sub
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Long, ByVal dy As Integer, _
ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Const MOUSEEVENTF_LEFTDOWN = &H2 '模拟鼠标左键按下
Public Const MOUSEEVENTF_LEFTUP = &H4 '模拟鼠标左键释放
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 '模拟鼠标中间键按下
Public Const MOUSEEVENTF_MIDDLEUP = &H40 '模拟鼠标中间键释放
Public Const MOUSEEVENTF_RIGHTDOWN = &H8 '模拟鼠标右键按下
Public Const MOUSEEVENTF_RIGHTUP = &H10 '模拟鼠标右键释放
Public Const MOUSEEVENTF_MOVE = &H1 '模拟鼠标指针移动
Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
Private Sub ComboBox1_DropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDownClosed
Dim p0 As Point = Cursor.Position
Dim p As Point = ComboBox1.PointToScreen(New Point(ComboBox1.Width - 23, 5))
Dim p1 As Point = ComboBox1.PointToScreen(New Point(0, 5))
SetCursorPos(p.X, p.Y)
mouse_event(MOUSEEVENTF_LEFTDOWN, p.X, p.Y, 0, 0)
mouse_event(MOUSEEVENTF_MOVE, -2000, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, p1.X, p.Y, 0, 0)
SetCursorPos(p0.X, p0.Y)
End Sub