Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.06 KB

sample_029.md

File metadata and controls

42 lines (31 loc) · 1.06 KB

主页

谁拥有 Windows 剪贴板

翻译:xinjie 2021.01.03

代码:

DO declare

hWindow=GetActiveWindow()
hOwner=GetClipboardOwner()
	
? "活动窗口: ............", hWindow,;
	"["+GetWinText(hWindow)+"]"

? "_SCREEN.HWnd: .............", _screen.HWnd,;
	"["+GetWinText(_screen.HWnd)+"]"

? "拥有剪贴板的窗口: ..", hOwner,;
	"["+GetWinText(hOwner)+"]"

FUNCTION GetWinText(hWindow)
	LOCAL nBufsize, cBuffer
	nBufsize = 128
	cBuffer = Repli(Chr(0), nBufsize)
	nBufsize = GetWindowText(hWindow, @cBuffer, nBufsize)
RETURN Iif(nBufsize=0, "", Left(cBuffer, nBufsize))

PROCEDURE declare
	DECLARE INTEGER GetActiveWindow IN user32
	DECLARE INTEGER GetClipboardOwner IN user32

	DECLARE INTEGER GetWindowText IN user32;
		INTEGER hwnd, STRING @lpString, INTEGER cch  

函数列表:

GetActiveWindow
GetClipboardOwner
GetWindowText