Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_CaptureBehindWindow


  • Please log in to reply
18 replies to this topic

#1 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 19 October 2008 - 04:53 AM


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, 24 October 2008 - 07:04 PM.








#2 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 21 October 2008 - 02:11 PM

any opinion ?

#3 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,334 posts

Posted 21 October 2008 - 03:30 PM

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, 21 October 2008 - 03:41 PM.


#4 Marlo

Marlo

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 304 posts

Posted 21 October 2008 - 03:36 PM

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

#5 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 21 October 2008 - 04:02 PM

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

#6 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 21 October 2008 - 04:54 PM

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 .

#7 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 23 October 2008 - 04:52 PM

okay important improvements on the script , now it works like magic
no flushing , no delaying , see first post for the update

Edited by komalo, 23 October 2008 - 04:57 PM.


#8 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 23 October 2008 - 07:03 PM

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

#9 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 24 October 2008 - 05:45 AM

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 :(

#10 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 24 October 2008 - 07:08 AM

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, 24 October 2008 - 07:34 AM.


#11 Marlo

Marlo

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 304 posts

Posted 24 October 2008 - 07:39 AM

I run the script and absolutely noting happens : /
Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

#12 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 24 October 2008 - 07:41 AM

I run the script and absolutely noting happens : /

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

Try this:
AutoIt         
#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")


#13 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 24 October 2008 - 07:41 AM

I run the script and absolutely noting happens : /

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

Try this:
AutoIt         
#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")


#14 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 24 October 2008 - 10:40 AM

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

Try this:

AutoIt         
#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, 24 October 2008 - 10:42 AM.


#15 Marlo

Marlo

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 304 posts

Posted 24 October 2008 - 01:06 PM

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

#16 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 24 October 2008 - 05:02 PM

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

#17 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 24 October 2008 - 07:01 PM

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

#18 Manadar

Manadar

         

  • MVPs
  • 10,900 posts

Posted 24 October 2008 - 07:18 PM

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.

#19 komalo

komalo

    Prodigy

  • Active Members
  • PipPipPip
  • 171 posts

Posted 24 October 2008 - 07:26 PM

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, 04 November 2008 - 04:09 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users