|
-
Jul 6th, 2005, 03:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Monitoring clipboard for changes.
Hello,
Is there any way for me to monitor the clipboard for changes?
Like say the clipboard data is "HELLO" and it changes to "Goodbye" how can I have it check that automatically? The program will be running full time in the system tray.
Thank you and have a great day!
Stilekid007
 Originally Posted by stilekid007
-
Jul 6th, 2005, 03:29 PM
#2
-
Jul 6th, 2005, 03:31 PM
#3
Re: Monitoring clipboard for changes.
And here's an example of the SetClipboardViewer API :
VB Code:
'Create a new project, add a module to it
'Add a command button to Form1
'In the form
Private Sub Form_Load()
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
'Subclass this form
HookForm Me
'Register this form as a Clipboardviewer
SetClipboardViewer Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Unhook the form
UnHookForm Me
End Sub
Private Sub Command1_Click()
'Change the clipboard
Clipboard.Clear
Clipboard.SetText "Hello !"
End Sub
'In a module
'These routines are explained in our subclassing tutorial.
'http://www.allapi.net/vbtutor/subclass.php
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
Public Const WM_DRAWCLIPBOARD = &H308
Public Const GWL_WNDPROC = (-4)
Dim PrevProc As Long
Public Sub HookForm(F As Form)
PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnHookForm(F As Form)
SetWindowLong F.hwnd, GWL_WNDPROC, PrevProc
End Sub
Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
If uMsg = WM_DRAWCLIPBOARD Then
MsgBox "Clipboard changed ..."
End If
End Function
Has someone helped you? Then you can Rate their helpful post. 
-
Jul 6th, 2005, 03:35 PM
#4
Thread Starter
Hyperactive Member
Re: Monitoring clipboard for changes.
PERFECT MANAVO11! Thank you so much! YOU GET A NICE PLUMP RATING! lol
Thanks buddy!
Stilekid007
 Originally Posted by stilekid007
-
Jul 6th, 2005, 03:48 PM
#5
-
May 7th, 2017, 05:32 AM
#6
New Member
Re: [RESOLVED] Monitoring clipboard for changes.
Hi there, I'm trying to use these macro but I'm not getting it working. I think it's maybe because I'm using a 64 bit machine and I should change some function declaration made for 32 bit machines but I don't know how.
Does someone know if this can be right and how to solve it?
Thanks for all the help given yet and in advance .
Diego López.
-
May 7th, 2017, 06:20 AM
#7
Re: [RESOLVED] Monitoring clipboard for changes.
-
May 7th, 2017, 03:28 PM
#8
Re: [RESOLVED] Monitoring clipboard for changes.
Sounds like an Office VBA user. Subclassing can be a pain in Office since things like UserForms were designed to make subclassing difficult by hiding window handles and such.
-
May 7th, 2017, 11:20 PM
#9
Re: [RESOLVED] Monitoring clipboard for changes.
This example appears to be using similar API to that in manavo11's post, but thought it might be of interest to some -
https://www.planet-source-code.com/v...57727&lngWId=1
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
|