- You should probably rename the thread to something like:
copy in Adobe Reader - no clipboard owner
- It would be helpful to know why it is you want to know what program set the clipboard contents.
INTRO
- If you press Ctrl+C in a program, and then use GetClipboardOwner, you should get an hWnd for the program that set the clipboard contents.
- This worked in multiple programs, e.g. Notepad and Internet Explorer, but not Adobe Reader (it returned 0).
- I did a search for 'getclipboardowner adobe', and it appears that a 'randy_dom' asked on multiple forums about this, although they received little useful feedback, e.g.:
winapi - GetClipBoardOwner with Adobe acrobat reader - Stack Overflow
https://stackoverflow.com/questions/10397320/getclipboardowner-with-adobe-acrobat-reader
TESTS
Code: Select all
q:: ;test get clipboard owner
;MsgBox, % A_LastError
hWnd := DllCall("user32\GetClipboardOwner", Ptr)
;hWnd := DllCall("user32\GetOpenClipboardWindow", Ptr)
WinGetClass, vWinClass, % "ahk_id " hWnd
WinGet, vPName, ProcessName, % "ahk_id " hWnd
MsgBox, % hWnd "`r`n" vWinClass "`r`n" vPName
return
A POSSIBLE WORKAROUND FOR ADOBE READER
- I used NirSoft InsideClipboard to look for any info on the clipboard identifying Adobe Reader (as having set the clipboard contents).
- The RTF text stored on the clipboard contained this: '{\*\generator Adobe Acrobat Reader '. Cheers.
Code: Select all
w:: ;check if RTF text on clipboard contains 'Adobe Acrobat Reader'
vRtf := JEE_ClipboardGetRtf()
MsgBox, % !!InStr(vRtf, "{\*\generator Adobe Acrobat Reader ")
return
JEE_ClipboardGetRtf(vEnc:="CP0")
{
local
vFormat := DllCall("user32\RegisterClipboardFormat", Str,"Rich Text Format", UInt)
return JEE_ClipboardGetText(vFormat, vEnc)
}
JEE_ClipboardGetText(vFormat:=0xD, vEnc:="")
{
local
;CF_LOCALE := 0x10 ;CF_UNICODETEXT := 0xD
;CF_OEMTEXT := 0x7 ;CF_TEXT := 0x1
if !DllCall("user32\IsClipboardFormatAvailable", UInt,vFormat)
|| !DllCall("user32\OpenClipboard", Ptr,0)
return
if !hBuf := DllCall("user32\GetClipboardData", UInt,vFormat, Ptr)
{
DllCall("user32\CloseClipboard")
return
}
pBuf := DllCall("kernel32\GlobalLock", Ptr,hBuf, Ptr)
vSize := DllCall("kernel32\GlobalSize", Ptr,hBuf, UPtr)
VarSetCapacity(vOutput, vSize, 0)
DllCall("msvcrt\memcpy", Ptr,&vOutput, Ptr,pBuf, UPtr,vSize, "Cdecl Int")
if !(vEnc = "")
vOutput := StrGet(&vOutput, vSize, vEnc)
VarSetCapacity(vOutput, -1)
DllCall("kernel32\GlobalUnlock", Ptr,hBuf)
DllCall("user32\CloseClipboard")
return vOutput
}