Jump to content
Sign in to follow this  

_ScreenCapture_Capture and WinGetPos Problem

Recommended Posts


I use the following code to capture new windows:

Func _ShellHookProc($hWnd, $iMsg, $wParam, $lParam)     
    Switch $hWnd         
    Case $hForm             
        Switch $wParam                

            $title = WinGetTitle($lParam)
            if StringInStr($title, "joebox") == 0 AND BitAND(WinGetState($lParam), 1) Then
                $pos = WinGetPos($lParam)  
                If $pos <> 0  Then 
                    $shoot = "C:\screen\window" & $nbrOfShots& ".jpg"

                    $screenShot = _ScreenCapture_Capture("", $pos[0], $pos[1], $pos[0]+$pos[2], $pos[1]+$pos[3])

                    _ScreenCapture_SaveImage($shoot, $screenShot)
                    ;ConsoleWrite("Title: " & $title &  $pos[0] & " " & $pos[1] & " " &  $pos[0]+$pos[2]  $pos[1]+$pos[3]@LF)
                    _ArrayAdd($shoots, $title)
                    _ArrayAdd($shoots, $shoot)
                    $shootArraySize = $shootArraySize + 2
                    $nbrOfShots = $nbrOfShots + 1

With that code I have the following questions for some new windows:

1. $pos[2] and $pos[3] is sometimes 0 although the window width and height isn't 0 (I checked with AutoIt Window Info)

2. _ScreenCapture_Capture does not capture the new window on front but the area right below that image (waiting does not help, same problem after 5s waiting and taking screen then)

Any suggestions how to solve these problems?


Share this post

Link to post
Share on other sites

Are you sure $lparam is returning a valid handle to that particular window?

Do the $pos[0] and $pos[1] match the actual window pos?


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...