Jump to content

_ScreenCapture_Capture does not always work


 Share

Recommended Posts

Because the first work and the second does not?

#include<ScreenCapture.au3>
Local $a1=_ScreenCapture_Capture("c:Downloads1.jpg",1,187,639,500, False)
Local $a2=_ScreenCapture_Capture("c:Downloads2.jpg",9,52,1267,28, False)
msgbox(0,$a1,$a2)
Edited by Ontosy
Link to comment
Share on other sites

Because the first work and the second does not?

#include<ScreenCapture.au3>
Local $a2=_ScreenCapture_Capture("c:\Downloads\2.jpg",9,52,1267,28, False)
msgbox(0,$a1,$a2)

Looks to me like the UDF is bugged, it wont check for error if Bottom right is smaller than top left.

Basically, it does not work because 28 is smaller than 52.

Make the bottom right bigger than 52 & it should work:

Local $a2=_ScreenCapture_Capture("c:\Downloads\2.jpg",9,52,1267,53, False)
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Looks to me like the UDF is bugged, it wont check for error if Bottom right is smaller than top left.

Func _ScreenCapture_Capture($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
    If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN)
    If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN)
    If $iRight < $iLeft Then Return SetError(-1, 0, 0)
    If $iBottom < $iTop Then Return SetError(-2, 0, 0)
Link to comment
Share on other sites

Func _ScreenCapture_Capture($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
    If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN)
    If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN)
    If $iRight < $iLeft Then Return SetError(-1, 0, 0)
    If $iBottom < $iTop Then Return SetError(-2, 0, 0)

I ran his code, it does not return anything. Help file does not elaorate on this issue.

If it does not tell him why it returned nothing, then this function should be re-written, so user wont have to come hire & ask why it is happening.

therefore I consider this to be a buggy function.

If shit happens, :) we want to know why.

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Looking at the UDF for _ScreenCapture_Capture, there isn't any information as to what the return values mean in the header, but looking at the code, it is quite obvious that if Bottom is less than Top, it returns an error code of -2. The return values should be documented, but if you know what the code says you don't really need much.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I ran his code, it does not return anything. Help file does not elaorate on this issue.

If it does not tell him why it returned nothing, then this function should be re-written, so user wont have to come hire & ask why it is happening.

therefore I consider this to be a buggy function.

If shit happens, :) we want to know why.

But function already tells user what is happening. Read the code I posted, Return SetError, etc..

I will make sure that documentation is updated. You say "function is buggy" but this is wrong. Open the function and read it.

#include<ScreenCapture.au3>
Local $a1=_ScreenCapture_Capture("c:Downloads1.jpg",1,187,639,500, False)
If @error Then
    ConsoleWrite("1st _ScreenCapture_Capture errored with error code: " & @error & @CRLF)
    Exit
EndIf
Local $a2=_ScreenCapture_Capture("c:Downloads2.jpg",9,52,1267,28, False)
If @error Then
    ConsoleWrite("2nd _ScreenCapture_Capture errored with error code: " & @error & @CRLF)
    Exit
EndIf
msgbox(0,$a1,$a2)
Edited by Manadar
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...