ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnView1.IO.CaptureFromScreen

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
w2m Posted - Aug 27 2012 : 13:32:46
Before calling ImageEnView1.IO.CaptureFromScreen(iecsForegroundWindow) is there any API to determine if there is a foreground window?

A question posted at StackOverflow failed to produce any code that works.

I created a work-around for the problem that seems to work, but some windows API would be better.

If you call ImageEnView1.IO.CaptureFromScreen(iecsForegroundWindow) and there is no foreground window a large completely black bitmap is returned. The work-around uses imageen to determine if the dominantcolor of the capturedimage is 100%. If the dominantcolor is 100 then you can display an error message and blank the image.
iPercentage := ImageEnView1.Proc.GetDominantColor(iColor);
//the image is all one color!
if iPercentage = 100 then
begin
   ImageEnView1.Blank;
   MessageBox(0, 'There is no foreground window.' + #10#13 + 'Make a window the foreground window, then try again.', 'No Active Window', MB_ICONWARNING or MB_OK);
end;

It is also interesting that if there is no foreground window, the ImageEnView1.IO.CaptureFromScreen(iecsForegroundWindowClient) returns a bitmap of the start button on the taskbar.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
7   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Sep 05 2012 : 10:12:41
To what window GetForegroundWindow refers returning 263058? Is that "minimized"? In this case you could check the window status (minimized, hided, etc...).
w2m Posted - Sep 04 2012 : 11:24:59
Hi Fabrizio,

With Windows 7, GetForegroundWindow = 263058 and GetShellWindow = 65866 when there are no visible windows on the deskup... so the test fails. I think you have to click on the desktop for this to work, but when capturing a clientwindow with ImageEnView1.IO.CaptureFromScreen(iecsForegroundWindow) there is no API to force a mouseclick on the desktop is there?


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
fab Posted - Sep 03 2012 : 13:39:52
Hi Bill,
I don't know if this helps. When there isn't a foreground window then GetForegroundWindow should return the same value of GetShellWindow, so you could try:

if GetForegroundWindow() = GetShellWindow() then
...there is no foreground....
w2m Posted - Aug 31 2012 : 14:13:05
Uwe,

I am not sure if this will help because I think you have to click on the window to get the correct foreground window.... will investigate this more.

William Miller
Uwe Posted - Aug 31 2012 : 10:23:42
William, does this help?

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633505%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632599%28v=vs.85%29.aspx#foreground

Quote:
"To check if your application window is the foreground window, compare the handle returned by GetForegroundWindow to that of your application window."

Uwe
ehkhalid Posted - Aug 31 2012 : 00:23:10
I use another way to detect if a page is blank, I calculcate "standard deviation" it give you if pixels variation is uniform or not, so if it's uniform, it mean image's pixels has the same color.

Hope this help
w2m Posted - Aug 30 2012 : 08:29:25
No one has any ideas?

William Miller