|
-
Apr 6th, 2009, 01:10 AM
#1
Thread Starter
Fanatic Member
Is it possible to paste the clipboard data in another application just by clicking ..
Dear Friends,
Is it possible to paste the clipboard data in another application just by clicking the textbox of another third party software application?
Say: 105689 this number is on the clipboard and I want to paste the same number in any other application that has the input text box to enter the value.
Instead of clicking the another application's textbox then right click and select "Paste" from it (or pressing Ctrl + V). Just I would like to click on that textbox so that the number to be pasted. Is there anyway?
-
Apr 6th, 2009, 01:37 AM
#2
Re: Is it possible to paste the clipboard data in another application just by clickin
Heres a quick idea, but note it doesn't check to see what type of window its sending the text to or anything.
Code:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
'Private Const EM_REPLACESEL = &HC2
Private Const WM_SETTEXT = &HC
Private Sub Command1_Click()
' enable quick paste
Timer1.Interval = 32
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
' disable quick paste
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
' // quick paste //
Dim pt32 As POINTAPI
Dim hWndOver As Long
Call GetCursorPos(pt32) ' Get cursor position.
hWndOver = WindowFromPointXY(pt32.x, pt32.y) ' Get window handle cursor is over.
If GetAsyncKeyState(vbKeyLButton) And &H8000 Then ' left mouse button is down?
Timer1.Enabled = False ' disable quick paste!
' paste text in window mouse is over!
SendMessage hWndOver, WM_SETTEXT, 0, ByVal Clipboard.GetText
End If
End Sub
Last edited by Edgemeal; Apr 7th, 2009 at 05:46 AM.
Reason: changed message to WM_SETTEXT
-
Apr 9th, 2009, 12:43 AM
#3
Thread Starter
Fanatic Member
Re: Is it possible to paste the clipboard data in another application just by clickin
 Originally Posted by Edgemeal
Heres a quick idea, but note it doesn't check to see what type of window its sending the text to or anything.
Thanks for the code. It works but it paste the clipboard text to even a locked cell in vb application.
Could you please let me know code to modify to use the same with using [B]"Insert" *******ey instead of click event.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|