The Clipboard API dates from Windows 3.0 (or before?) and is badly designed.
Unfortunately, instead of having get/set primitives, it uses open/close,
which makes it possible for applications to hold its access for far too long.
Some improvement was brought by Vista to the handling of the viewers
chain, but no new API.
With the existing API, it is possible to identify the owner of the clipboard
only if that owner also has at least one open window.
If the owner has no windows, then one is out of luck.
In the thread Why has my clipboard stopped working?, Jay Parzych has
contributed the following vbs code where the GetClipboardLocker function
returns the file-name of the process holding the clipboard :
<DllImport("user32.dll")> _
Public Function GetOpenClipboardWindow() As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True)> _
Public Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, ByRef lpdwProcessId As Integer) As Integer
End Function
Public Function GetClipboardLocker() As String
Dim hwnd As IntPtr = GetOpenClipboardWindow()
If hwnd <> IntPtr.Zero Then
Dim processId As Integer
GetWindowThreadProcessId(hwnd, processId)
Dim p As Process = Process.GetProcessById(processId)
GetClipboardLocker = p.Modules(0).FileName
Else
GetClipboardLocker = String.Empty
End If
End Function
A similar C# function can be found in the post
Get Clipboard owners Title/Caption.
@Ramhound machine has a lot of components much of which are needed for the robot activity. Starting from a clean machine and install the software one by one until reproducing the bug will be very expensive. – Áxel Costas Pena – 2014-06-19T12:36:19.550
@Wutnaut not sure what you are thinking of, I think this doesn't apply to that, robot fills web forms by writing to clipboard and pasting its contents – Áxel Costas Pena – 2014-06-19T12:36:54.190
@all we finally found it was the vncserver's fault. Even explicitly disabling its clipboard sharing feature. Anyway the question was explicit and I am interested anyway in finding an answer, so the question remains open – Áxel Costas Pena – 2014-06-19T12:40:17.710
@ÁxelCostasPena - Sounds like you already have your answer. You had a service being loaded that was causing the conflict. I never told you to start with a "clean" machine. I told you to boot using only the software you need. If you had done that, and it worked, you would have a list of possible problem children. When it didn't work you would also have a list. – Ramhound – 2014-06-19T13:10:12.610
@Ramhound yeah I solved your problem, but I'd love to find if is there any way to ask windows who has a clipboard open, and even monitor clipboard accesses – Áxel Costas Pena – 2014-06-19T17:06:23.503
I do believe there are applications that exist to monitor clipboard access. – Ramhound – 2014-06-19T18:01:34.027
I simply don't know, but it's hard to believe there aren't. But two hours of google gave me no one tool – Áxel Costas Pena – 2014-06-20T08:01:46.737
Does this happen in a minimal boot configuration? – Ramhound – 2014-06-18T16:27:47.890
The robots software doesn't work in safe mode, that is one of the difficulties – Áxel Costas Pena – 2014-06-18T16:45:46.080
1I didn't say Safe Mode I said in a minimal boot configuration there is a difference. – Ramhound – 2014-06-18T16:48:26.670
Manual clipboard: save the text to a file, call the text in that file, delete the file. – Wutnaut – 2014-06-18T17:20:31.760