Jump to content
Sign in to follow this  
lJoel

_ScreenCapture_Capture and WinGetPos Problem

Recommended Posts

lJoel

Hi

I use the following code to capture new windows:

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

            $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"

                                        WinWaitActivate($lParam)
                
                    $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
                
                EndIf
            
            EndIf
                          
        EndSwitch     
    EndSwitch 
EndFunc

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?

Cheers

Share this post


Link to post
Share on other sites
PsaltyDS

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?

:idea:


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  

×