To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management
Building Composable Apps in .NET 4 with the Managed Extensibility Framework
CLR Inside Out: Formatting and Parsing Time Intervals in the .NET Framework 4



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Jul 6th, 2005, 04:18 PM   #1
stilekid007
Hyperactive Member
 
stilekid007's Avatar
 
Join Date: Apr 05
Location: DUDE! I'm your neighbor! HELLO!!!
Posts: 388
stilekid007 is an unknown quantity at this point (<10)
Resolved [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
__________________
Quote:
Originally Posted by stilekid007
I RATE ALL HELPFULL POSTS!
stilekid007 is offline   Reply With Quote
Old Jul 6th, 2005, 04:29 PM   #2
manavo11
Super Moderator
 
manavo11's Avatar
 
Join Date: Nov 02
Location: Other side of town from si_the_geek
Posts: 7,147
manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)
Re: Monitoring clipboard for changes.

Either a timer (which isn't really a good solution) or the SetClipboardViewer API
__________________


Has someone helped you? Then you can Rate their helpful post.
manavo11 is offline   Reply With Quote
Old Jul 6th, 2005, 04:31 PM   #3
manavo11
Super Moderator
 
manavo11's Avatar
 
Join Date: Nov 02
Location: Other side of town from si_the_geek
Posts: 7,147
manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)
Re: Monitoring clipboard for changes.

And here's an example of the SetClipboardViewer API :

VB Code:
  1. 'Create a new project, add a module to it
  2. 'Add a command button to Form1
  3. 'In the form
  4. Private Sub Form_Load()
  5.     'KPD-Team 1999
  6.     'URL: [url]http://www.allapi.net/[/url]
  7.     'E-Mail: [email]KPDTeam@Allapi.net[/email]
  8.     'Subclass this form
  9.     HookForm Me
  10.     'Register this form as a Clipboardviewer
  11.     SetClipboardViewer Me.hwnd
  12. End Sub
  13. Private Sub Form_Unload(Cancel As Integer)
  14.     'Unhook the form
  15.     UnHookForm Me
  16. End Sub
  17. Private Sub Command1_Click()
  18.     'Change the clipboard
  19.     Clipboard.Clear
  20.     Clipboard.SetText "Hello !"
  21. End Sub
  22. 'In a module
  23. 'These routines are explained in our subclassing tutorial.
  24. 'http://www.allapi.net/vbtutor/subclass.php
  25. Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  26. 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
  27. Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
  28. Public Const WM_DRAWCLIPBOARD = &H308
  29. Public Const GWL_WNDPROC = (-4)
  30. Dim PrevProc As Long
  31. Public Sub HookForm(F As Form)
  32.     PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)
  33. End Sub
  34. Public Sub UnHookForm(F As Form)
  35.     SetWindowLong F.hwnd, GWL_WNDPROC, PrevProc
  36. End Sub
  37. Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  38.     WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
  39.     If uMsg = WM_DRAWCLIPBOARD Then
  40.         MsgBox "Clipboard changed ..."
  41.     End If
  42. End Function
__________________


Has someone helped you? Then you can Rate their helpful post.
manavo11 is offline   Reply With Quote
Old Jul 6th, 2005, 04:35 PM   #4
stilekid007
Hyperactive Member
 
stilekid007's Avatar
 
Join Date: Apr 05
Location: DUDE! I'm your neighbor! HELLO!!!
Posts: 388
stilekid007 is an unknown quantity at this point (<10)
Re: Monitoring clipboard for changes.

PERFECT MANAVO11! Thank you so much! YOU GET A NICE PLUMP RATING! lol

Thanks buddy!
Stilekid007
__________________
Quote:
Originally Posted by stilekid007
I RATE ALL HELPFULL POSTS!
stilekid007 is offline   Reply With Quote
Old Jul 6th, 2005, 04:48 PM   #5
manavo11
Super Moderator
 
manavo11's Avatar
 
Join Date: Nov 02
Location: Other side of town from si_the_geek
Posts: 7,147
manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)manavo11 is a jewel in the rough (300+)
Re: [RESOLVED] Monitoring clipboard for changes.

Hehe, thanks and you're welcome
__________________


Has someone helped you? Then you can Rate their helpful post.
manavo11 is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:31 AM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.