-
Jul 22nd, 2013, 02:07 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Copy Paste/change data issue
so this is a weird one.. I read data from one excel spreadsheeet and convert it into something different in another spread sheet. Here was "I thought" the easiest solution.....change the clipboard data... The problem is that it won't work on my Windows 8/Office 2013(works rarely), but will work on my Windows 7/Office 2010 (admin). However when I use it at work (windows 7/office 2010) it doesn't work (user not admin).. So originally I thought it was a windows 8 issue, but now I see the same issue with Windows 7 at work (non admin). Also an issue with Outlook.. seems as though outlook monitors the clipboard as well.. I have had outlook crash when I run this simple program which basically is just a timer that monitors the clipboard and REPLACES the text so it can be pasted into another format.
So here is an example.
I have a timer running to monitor the clipboard. IF the clipboard contains 1 2 3 4 5 it will REPLACE them with "6 7 8 9 10". Its like the Clipboard.settext is not working. It works intermittently not consistantly unless its on my home Windows 7/Office 2010. So I know my coding should be right its just something with the clipboard.
is there a more effiecent way of intercepting the clipboard/reading/changing/writing????besides Clipboard.gettext/settext
I read something about clipboard threads/threadstates when researching, but did not come accross a good example...
-
Jul 22nd, 2013, 02:15 PM
#2
Re: Copy Paste/change data issue
you can hook the clipboard, so you receive notification of changes:
Code:
Public Class Form1
Private Const WM_DRAWCLIPBOARD As Integer = &H308
Private Declare Function SetClipboardViewer Lib "user32" Alias "SetClipboardViewer" (ByVal hwnd As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim result As Integer = SetClipboardViewer(Me.Handle.ToInt32)
While result <> Me.Handle.ToInt32
result = SetClipboardViewer(Me.Handle.ToInt32)
End While
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_DRAWCLIPBOARD Then
'clipboard changed
End If
MyBase.WndProc(m)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 22nd, 2013, 09:29 PM
#3
Thread Starter
Addicted Member
Re: Copy Paste/change data issue
so how do you settext, clear, gettext???
-
Jul 23rd, 2013, 08:28 AM
#4
Re: Copy Paste/change data issue
Originally Posted by BlayzeX
so how do you settext, clear, gettext???
you use my code with gettext + settext.
the is also a method:
Code:
if Clipboard.ContainsText
or something similar, so you'll be accessing the clipboard + modifying its contents far less often
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 23rd, 2013, 06:38 PM
#5
Thread Starter
Addicted Member
Re: Copy Paste/change data issue
thank you for you reply... i found the issue with excel. If you leave it selected after pressing copy, office wants to keep it in teh clipboard, but if you press ESC and deselect it, then you can modify it in the clipboard. However I will definitely check out your method of monitoring the clipboard.
-
Jul 31st, 2024, 11:54 AM
#6
Junior Member
Re: Copy Paste/change data issue
WM_CHANGECBCHAIN needs to be handled by all viewers in the chain.
Last edited by philo; Jul 31st, 2024 at 12:04 PM.
-
Jul 31st, 2024, 12:02 PM
#7
Re: Copy Paste/change data issue
Originally Posted by philo
WM_CHANGECBCHAIN needs to be handled by all viewers in the chain.
You’re a little late to the party. This is an eleven year old resolved thread
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 31st, 2024, 12:08 PM
#8
Junior Member
Re: [RESOLVED] Copy Paste/change data issue
Yeah, now it is.
Code:
Case WM_CHANGECBCHAIN
If wParam = nextviewer Then
nextviewer = lParam
ElseIf nextviewer <> 0 Then
SendMessage nextviewer, uMsg, wParam, lParam
End If
-
Jul 31st, 2024, 12:57 PM
#9
Re: [RESOLVED] Copy Paste/change data issue
Originally Posted by philo
Yeah, now it is.
Code:
Case WM_CHANGECBCHAIN
If wParam = nextviewer Then
nextviewer = lParam
ElseIf nextviewer <> 0 Then
SendMessage nextviewer, uMsg, wParam, lParam
End If
That wouldn’t work in vb.net
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
|