【发布时间】:2016-05-21 19:29:55
【问题描述】:
大家下午好。
我想从我的远程协助工具中看到一个在“新桌面环境”中打开的窗口,但我无法使用如下常规功能看到这个窗口:
function RandomPassword(PLen: Integer): string;
var
str: string;
begin
Randomize;
str := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Result := '';
repeat
Result := Result + str[Random(Length(str)) + 1];
until (Length(Result) = PLen)
end;
procedure Printscreen;
var
DCDesk: HDC;
bmp: TBitmap;
hmod, hmod2 : HMODULE;
BitBltAPI: function(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): BOOL; stdcall;
GetWindowDCAPI: function(hWnd: HWND): HDC; stdcall;
begin
hmod := GetModuleHandle('Gdi32.dll');
hmod2:= GetModuleHandle('User32.dll');
if (hmod <> 0) and (hmod2 <> 0) then begin
bmp := TBitmap.Create;
bmp.Height := Screen.Height;
bmp.Width := Screen.Width;
GetWindowDCAPI:= GetProcAddress(hmod2, 'GetWindowDC');
if (@GetWindowDCAPI <> nil) then begin
DCDesk := GetWindowDCAPI(GetDesktopWindow);
end;
BitBltAPI:= GetProcAddress(hmod, 'BitBlt');
if (@BitBltAPI <> nil) then begin
BitBltAPI(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DCDesk, 0, 0, SRCCOPY);
bmp.SaveToFile('ScreenShot_------_' + RandomPassword(8) + '.bmp');
end;
ReleaseDC(GetDesktopWindow, DCDesk);
bmp.Free;
FreeLibrary(hmod);
FreeLibrary(hmod2);
end;
end;
begin
while True do
begin
Printscreen;
Sleep(5000);
end;
end.
以已经使用Team View软件为例,屏幕截图正常出现窗口,并产生this result。
那么,是否有某种方式可以像从 Team View 软件中一样在屏幕截图中查看此窗口?
欢迎所有建议。
【问题讨论】:
-
在你的程序生命周期中只调用一次随机化,否则你会得到一些令人讨厌的惊喜。尝试循环调用 RandomPassword。
-
"graphics" 已经使用了"windows",不使用"windows" 中声明的函数你不会获得任何收益。
标签: delphi screenshot