 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Thu Apr 01, 2021 12:24 pm Post subject: |
|
|
Here is the latest update on this subject. There is an undocumented function called grab_desktop_dib@ that avoids the need to use the clipboard. It works for 32 bits but not for 64 bits at the moment.
Code: | use clrwin
integer, parameter::grhandle = 42
integer(7) hdib
integer actual_width,actual_height,my_error
actual_width = clearwin_info@("SCREEN_WIDTH")
actual_height = clearwin_info@("SCREEN_DEPTH")
call grab_desktop_dib@(hdib,0,0,actual_width,actual_height)
my_error = create_graphics_region@(grhandle,actual_width,actual_height)
my_error = dib_paint@(0,0,hdib,0,0)
my_error = export_image@("image42.png")
my_error = delete_graphics_region@(grhandle)
call release_screen_dib@(hdib)
end |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Thu Apr 01, 2021 2:33 pm Post subject: |
|
|
ClearWin+ has now been fixed so that the above sample will work for 64 bits as well as for 32 bits. Updated DLLs are available on request for users of v8.70. |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Fri Apr 02, 2021 12:25 pm Post subject: |
|
|
Looks interesting. One question: is it possible with this method to save just the selected portion of the entire screen ? PrintScreen button started to offer recently such capability: you hit the PrintScreen and the monitor screen gets grayed and offer you to select the region to save |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Sat Apr 03, 2021 2:48 pm Post subject: |
|
|
As far as grabbing the entire desktop, I think this is a great functionality to have, but does not satisfy the requirement that I have imposed so that I can grab a window and not have to select it (using the Windows snapshot function) or edit it (as I would for a full desktop grab). It is a function of convenience. Keystroke: done and saved.
One could debate that the ability to grab a window programmatically by the user does take control of the clipboard and changes the contents, but if you already would have done it anyway using a Windows Snapshot or Alt+PrntScrn, there is no additional harm done by doing this programmatically.
I have seen (MSDN documentation) that it is possible to dig deep into device contexts in Windows to grab video memory that shows the current window, but it exceeds both my expertise and willingness to invest time. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Sat Apr 03, 2021 5:31 pm Post subject: |
|
|
Bill
I have added a routine that exports an image of a given window and I will provide details shortly (probably Monday). |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Sat Apr 03, 2021 7:13 pm Post subject: |
|
|
Awesome, Paul! Looking forward to giving it a try! |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Sat Apr 03, 2021 8:29 pm Post subject: |
|
|
I use for videorecording nice program called Snaggit (right now it does not matter if this program is good or bad and it is not about making videorecording functionality) and what it doing really handy is that after you start it - it offers you to select one of many your open windows with mouse by highlighting each window when you move your mouse over the screen. As soon as you click on the window you want, it grabs the position of the window and the video recording starts. Same actions are for the photo recording. Same windows selection functionality with Clearwin would be great. You can then grab series if still images of specific window during the program run and later user with different software could make a movies out of them. This Clearwin function would ask you to select the window you want and then all next times it will be called it will use this selection without asking |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Apr 05, 2021 4:08 pm Post subject: |
|
|
Bill
Here is a sample program that illustrates what you will be able to do with the updated ClearWin+....
Code: | module mymod
use clrwin
integer(7) hwnd
contains
integer function export()
iw = export_window_image@(hwnd,"image.png",0_3)
export = 2
end function
end module
winapp
program main
use mymod
iw = winio@("%ca[Capture Window Image]&")
iw = winio@("%hw&",hwnd)
iw = winio@("%cn%^bb[Export]", export)
end program |
export_window_image@ uses the HWND of the current window and exports its image to the given file. The third argument is reserved and must be zero. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Mon Apr 05, 2021 4:18 pm Post subject: |
|
|
Dan
Your request posed an interesting challenge. The following program illustrates what will be possible with an updated ClearWin+. It presents a symbol. When you drag this symbol and drop it over a window then an image of that window is copied to the speciified file.
Code: | module mymod
use mswin
integer(7) hMain,hStatus
logical mouseDown
contains
integer function find()
integer(7) hOld,hCur
mouseDown = .true.
hCur = SetCursor(LoadResource@("find","Cursor"))
hOld = SetCapture(hMain)
find = 3
end function
integer function export()
integer(7) hThis,hfgrd,hCur
logical L
mouseDown = .false.
L = ReleaseCapture()
hCur = SetCursor(LoadResource@("Arrow","Cursor"))
hThis = WindowAtCursor@(0_3)
hfgrd = GetForegroundWindow()
L = BringWindowToTop(hThis)
iw = export_window_image@(hThis,"image.png",0_3)
L = BringWindowToTop(hfgrd)
call set_status_text@(hStatus, 0, " Window image saved to image.png")
export = 3
end function
integer function move()
integer pos(2)
character(40) txt
logical L
if(mouseDown)then
L = GetCursorPos(pos)
write(txt, "('(',i4,',',i4,')')") pos
call set_status_text@(hStatus, 0, trim(txt))
else
call set_status_text@(hStatus, 0, "Drag the symbol to capture a window image")
endif
move = 3
end function
end module mymod
winapp
use mymod
mouseDown = .false.
iw = winio@("%ca[Capture Window Image]&")
iw = winio@("%mg&", WM_LBUTTONDOWN, find)
iw = winio@("%mg&", WM_LBUTTONUP, export)
iw = winio@("%mg&", WM_MOUSEMOVE, move)
iw = winio@("%sb%lc&", hStatus)
iw = winio@("%hw&", hMain)
iw = winio@("%cn%`bm[static]&", LoadResource@("capture","Bitmap"))
iw = winio@("%ff%nl%cn%6bb[Close]")
end
resources
find CURSOR find.cur
capture BITMAP capture.bmp |
|
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Mon Apr 05, 2021 6:21 pm Post subject: |
|
|
Paul, this would be perfect for me.
Thanks, I shall await the updated Clearwin+!
Bill |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Mon Apr 05, 2021 10:19 pm Post subject: |
|
|
Thanks Paul,
please inform when the DLLs will be ready, right now these functions are missing
WINDOWATCURSOR#
EXPORT_WINDOW_IMAGE
LOADRESOURCE |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Apr 06, 2021 1:49 pm Post subject: |
|
|
I have now updated the downloads for the DLLs and INCLUDE files so that the sample program now works for 32 bits as well as 64 bits.
In the sample program it is necessary to call GetCursorPos@ rather than GetCursorPos. This is the call that was failing for 32 bits. |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2923 Location: South Pole, Antarctica
|
Posted: Wed Apr 07, 2021 2:34 am Post subject: |
|
|
Paul,
The size of saved are is a bit larger than the actual window size. Do you see the same ? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Apr 07, 2021 9:04 am Post subject: |
|
|
Dan
Yes. I noticed that but I don't know how to easily get the exact size. I have used GetWindowRect and even allowed for the width of the borders. Hopefully it can be tollerated. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|