VB Code:
Public Sub Paste(ByVal hwnd As Long)
SendMessage hwnd, WM_PASTE, 0&, ByVal 0&
Debug.Print "hwnd "; hwnd; " gettickcount "; GetTickCount
End Sub
Private Function gethwnd()
Dim hFore As Long, hFocus As Long
hFocus = GetFocus
If hFocus = 0 Then
hFore = GetForegroundWindow()
Call AttachThreadInput(GetWindowThreadProcessId(hFore, 0&), GetCurrentThreadId, True)
hFocus = GetFocus
Call AttachThreadInput(GetWindowThreadProcessId(hFore, 0&), GetCurrentThreadId, False)
End If
Paste hFocus
Me.Caption = hFocus
End Function
Private Sub List1_Click(index As Integer)
Dim newtext As String
newtext = List1(index).Text
Clipboard.Clear
Clipboard.SetText List1(index).Text
Me.Hide
gethwnd
Me.Show
List1(index).SetFocus
End Sub