Sign in to follow this  
Followers 0

_CaptureBehindWindow

19 posts in this topic

#1 ·  Posted (edited)

hi

this my first script in this forum , it is a tiny script for capture screen

behind a specific window

edit : okay important improvements on the script , now it works like magic

no flushing , no delaying

it works fine for me but not for some users (maybe all) for unknown reasons

so it seems that it will not work for any one but i will leave it here

if any one wanted it

Demo & a Little Function

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

_CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
ShellExecute(@ScriptDir & "\Behind Current window.bmp")

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    Local Const $WS_EX_COMPOSITED = 0x2000000
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow
Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted

any opinion ?


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

any opinion ?

Might as well put the includes in there.

#Include <WinAPI.au3>

#Include <ScreenCapture.au3>

#Include <Constants.au3>

edit: Doesn't seem to work quite right. Maybe add a delay till picture is done?

Edited by spudw2k

Share this post


Link to post
Share on other sites

#4 ·  Posted

Very buggy =( and you also didnt specify what includes were requires :P

Heres the screenshot that was taken on my system. (only half draws a window)

Posted Image


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites

#5 ·  Posted

Good try, but it doesn't work that way.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Might as well put the includes in there.

#Include <WinAPI.au3>

#Include <ScreenCapture.au3>

#Include <Constants.au3>

edit: Doesn't seem to work quite right. Maybe add a delay till picture is done?

Very buggy =( and you also didnt specify what includes were requires :P

Heres the screenshot that was taken on my system. (only half draws a window)

Posted Image

Good try, but it doesn't work that way.

sorry guys , that's my first script shared here so i didn't know what to do .

i put all the includes now .

about that delay , the script works fine with me but maybe there's timing between

apply the style and taking the screen shot so i modified the script and put a sleep

between SetTrans and capture.

you can try it now .


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

okay important improvements on the script , now it works like magic

no flushing , no delaying , see first post for the update

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#8 ·  Posted

Still doesn't repaint the picture the area behind the window when it is needed. You should look into GDI a bit more. :P

Share this post


Link to post
Share on other sites

#9 ·  Posted

first it works for me fine now so i don't really get it , why it is not captured for you :P

second i am not using GDI Here :(


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

What OS are you running? Vista has made a lot of changes in the way this works. Win XP SP3 here.

Edit: It does work for me in most non-user drawn forms. But it still makes huge flashes.

Edited by Manadar

Share this post


Link to post
Share on other sites

#11 ·  Posted

I run the script and absolutely noting happens : /


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites

#12 ·  Posted

I run the script and absolutely noting happens : /

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

Share this post


Link to post
Share on other sites

#13 ·  Posted

I run the script and absolutely noting happens : /

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

That's because it's an UDF style script. It's an #include basically.

Try this:

#include <WinAPI.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

;#VARIBLES#===============================================================================
Global Const $WS_EX_COMPOSITED = 0x2000000

;#FUNCTION#===============================================================================
;
; Name...........: _CaptureBehindWindow
; Description ...: Capture the screen behind a specific window
; Syntax.........: _CaptureBehindWindow($sTitle , $sText , $sFile)
; Parameters ....: $sTitle = The title of the window . See Title special definition.
;                  $sText = text The text of the window .
;                  $sFile = Full path and extension of the image file to save the capture image in
; Return values .: None
; Author ........: komalo
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; _CaptureBehindWindow("","", @ScriptDir & "\Behind Current window.bmp")
;
;==========================================================================================

Func _CaptureBehindWindow($sTitle, $sText, $sFile)
    $hWnd = WinGetHandle($sTitle, $sText)

    $Old_EX_STYLE = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))

    _ScreenCapture_Capture($sFile, 0, 0, -1, -1, False)
    _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $Old_EX_STYLE)
EndFunc   ;==>_CaptureBehindWindow


Opt("WinTitleMatchMode", 2)

;; THE ACTUAL SCRIPT
_CaptureBehindWindow(" - SciTE", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")
@Manadar : thank you for replaying to others

now i knew why it wasn't working for you

if you try this

_CaptureBehindWindow("Untitled -", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

with notepad you will not get the flushing

I am XP SP2 User

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#15 ·  Posted

I'm not a complete novice at AutoIt you know :(

Ofc i wrote out the function yet still nothing happened.

:P


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites

#16 ·  Posted

Yeah, so I try this:

;; THE ACTUAL SCRIPT
Opt("WinTitleMatchMode", 2)

WinActivate("Untitled - ")
_CaptureBehindWindow("Untitled -", "", "C:\test.jpg")
ShellExecute("C:\test.jpg")

I don't see what the difference is between getting a winhandle using the first part of the string, or the last part of the string. A window handle is a window handle.

Result: You can clearly see where the window was before.

Posted Image

Share this post


Link to post
Share on other sites

#17 ·  Posted

i am getting board , it works for me that what i want

so i will leave this script here

just for clearing the idea of the script :

bitblt function doesn't get Bits by layered windows

so i get the exstyle of the window and sets the exstyle

to $WS_EX_LAYERED make a screencapture which is

made by bitblt and sets the exstyle to the orginal


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

#18 ·  Posted

just for clearing the idea of the script :

bitblt function doesn't get Bits by layered windows

so i get the exstyle of the window and sets the exstyle

to $WS_EX_LAYERED make a screencapture which is

made by bitblt and sets the exstyle to the orginal

You should be able to do this quite effectively using BitBlt and GetDC using a specific hWnd and not null.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

ScreenCapture_Capture Uses Desktop's handle ( _WinAPI_GetDesktopWindow )

and i am able to finish it , what i don't get it

is why it is not working right for you

Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

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