Sign in to follow this  
Followers 0
myspacee

screencapture focused window

6 posts in this topic

#1 ·  Posted (edited)

hello,

Need to screen capture focused in my desktop but different func

return different value to accomplish this task. Understand that i must use

@DesktopWidth @DesktopHeight but going mad.

anyone can help me?

m.

Edited by myspacee

Share this post


Link to post
Share on other sites



Is this what you are looking to do

#include <ScreenCapture.au3>

$h = WinGetHandle("Program Manager")

_ScreenCapture_CaptureWnd(@ScriptDir & "\testing.bmp", $h,0,0,@DesktopWidth,@DesktopHeight)

Share this post


Link to post
Share on other sites

thank you picea,

but your code screencapure whole desktop.

I want to sreencapture window with focus, post image to define better my request:

Posted Image

with:

$size = WinGetPos("[active]")
tooltip($size[0] & " " & $size[1] & " " & $size[2] & " " & $size[3],0,0)

I obtain :

x = $size[0]

y = $size[1]

width = $size[2]

height = $size[3]

For difference with @DesktopWidth @DesktopHeight and these values, I should obtain :

left = ?

top = ?

right = ?

bottom = ?

But can't deduce whic are values to use...

Anyone can help ?

Thank you,

m.

Share this post


Link to post
Share on other sites

#include <ScreenCapture.au3>

Run('calc.exe')
WinWaitActive('Calculator')

Dim $aPos = WinGetPos('Calculator')
_ScreenCapture_Capture(@ScriptDir & '\TestCalc.bmp', $aPos[0], $aPos[1], $aPos[0]+$aPos[2], $aPos[1]+$aPos[3])
ShellExecute(@ScriptDir & '\testcalc.bmp')

After you have the position array you need to add the width to the x coordinate to get the right and the same for the height because specifying $iLeft as 44 and the window width is 55 but sending $iRight 55 is wrong, it should be 99.

Share this post


Link to post
Share on other sites

perfect,

need small adjustment for window > <, @DesktopWidth @DesktopHeight, but resolve.

thank you.

m.

Share this post


Link to post
Share on other sites

made this little script, that 'map' in middle mouse button abilty to snapshot windows with focus:

#Include <Misc.au3>
#include <ScreenCapture.au3>
#include <Date.au3>
#Include <WinAPI.au3>

$dll = DllOpen("user32.dll")

while 1

;if middle mouse is pressed
    If _IsPressed("04", $dll)  Then
        $aPos = WinGetPos("[active]")
    ; Capture window with focus
        _ScreenCapture_Capture(@ScriptDir & '\snap\TestCalc' & _Date_Time_GetTickCount() & '.jpg', $aPos[0], $aPos[1], $aPos[0]+$aPos[2], $aPos[1]+$aPos[3])
        sleep(1000)
    EndIf
    
    
    sleep(100)
    
wend

DllClose($dll)

But often script exit with an error

_WinAPI_CreateCompatibleBitmap: Parametro non corretto.

I think I must delete GDI resource every cicle, but can't understand how, anyone can help me ?

thank you,

m.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0