Capture D'ecran

Aide et conseils concernant AutoIt et ses outils.
Règles du forum
.
Répondre
Gavriel
Niveau 3
Niveau 3
Messages : 32
Enregistré le : mer. 07 déc. 2016 22:29
Status : Hors ligne

Capture D'ecran

#1

Message par Gavriel »

Bonjour j'ai créé un logiciel de capture d'écran j'ai fait que j'ai la possibilité de me déplacer à l'horizontal avec
$hEdit = ControlGetHandle("[CLASS:tdghj]", '', 'Aguire2')
$tSBI = DllStructCreate($tagSCROLLINFO)
DllStructSetData($tSBI, 'cbSize', DllStructGetSize($tSBI))
DllStructSetData($tSBI, 'fMask', $SIF_ALL)
if $conth<$horizontal then
If _GUIScrollBars_GetScrollInfo($hEdit, $SB_VERT, $tSBI) Then
_SendMessage($hEdit, $WM_VSCROLL, $SB_top, 0)
Sleep($yTemp2)
   _SendMessage($hEdit, $WM_HSCROLL, $SB_pageright, 0)
 EndIf
 endif
Quand j'ai trois écrans précis vers la droite il me les captures je l'ai recolle et tout vas bien mais quand j'ai seulement deux écrans et demi vers la droite j'ai un problème il me prend une partie en double de l'image du dernier écran ma question est comment je peux calculer à la fin du deuxième écran combien il me reste de pixels jusqu'à la fin du demi écran pour capturer que cette parti
Merci
Avatar du membre
scorp84
Niveau 7
Niveau 7
Messages : 400
Enregistré le : mar. 04 nov. 2008 21:51
Localisation : Avignon, France
Status : Hors ligne

Re: Capture D'ecran

#2

Message par scorp84 »

Bonjour Gavriel,

Voici ce que j'utilise pour 2 écrans :
#include <APIGdiConstants.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPIGdiInternals.au3>
#include <WinAPIHObj.au3>
#include <APIGdiConstants.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Global $ghGDIPDll

f_CaptureMultiEcran()

Func f_CaptureMultiEcran()

   Global $tag_DISPLAY_DEVICE = "dword cb;char DeviceName[32];char DeviceString[128];dword StateFlags;char DeviceID[128];char DeviceKey[128]"
   ;Global Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008
   ;Global Const $DISPLAY_DEVICE_PRIMARY_DEVICE = 0x00000004

   Global $tag_POINTL = "long x;long y"
   Global $tag_DEVMOD = "char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _
         "ushort dmDriverExtra;dword dmFields;" & $tag_POINTL & ";dword dmDisplayOrientation;dword dmDisplayFixedOutput;" & _
         "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _
         "byte dmFormName[32];ushort LogPixels;dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _
         "dword dmDisplayFlags;dword dmDisplayFrequency"
   ;Global Const $ENUM_CURRENT_SETTINGS = -1

   Global $Left, $Top, $Right, $Bottom
   Global $i = 0

   While 1
      $struct = DllStructCreate($tag_DISPLAY_DEVICE)
      DllStructSetData($struct, "cb", DllStructGetSize($struct))

      $aRetrun = DllCall("user32.dll", "int", "EnumDisplayDevices", "ptr", 0, "dword", $i, "ptr", DllStructGetPtr($struct), "dword", 0)
      If Not $aRetrun[0] Then ExitLoop

      If Not BitAND(DllStructGetData($struct, "StateFlags"), $DISPLAY_DEVICE_MIRRORING_DRIVER) Then ; Avoid Virtual Displays
   ;~       ConsoleWrite(DllStructGetData($struct, "DeviceName") & @TAB & "Primary: " & (BitAND(DllStructGetData($struct, "StateFlags"), $DISPLAY_DEVICE_PRIMARY_DEVICE) > 0) & @CRLF)

         $dev = DllStructCreate($tag_DEVMOD)
         DllStructSetData($dev, "dmSize", DllStructGetSize($dev))
         $aRetrun = DllCall("user32.dll", "int", "EnumDisplaySettings", "str", DllStructGetData($struct, "DeviceName"), "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($dev))

         If Not IsNumber($Left) Or $Left > DllStructGetData($dev, "x") Then $Left = DllStructGetData($dev, "x")
         If Not IsNumber($Top) Or $Top > DllStructGetData($dev, "y") Then $Top = DllStructGetData($dev, "y")
         If Not IsNumber($Right) Or $Right < DllStructGetData($dev, "x") + DllStructGetData($dev, "dmPelsWidth") Then $Right = DllStructGetData($dev, "x") + DllStructGetData($dev, "dmPelsWidth")
         If Not IsNumber($Bottom) Or $Bottom < DllStructGetData($dev, "y") + DllStructGetData($dev, "dmPelsHeight") Then $Bottom = DllStructGetData($dev, "y") + DllStructGetData($dev, "dmPelsHeight")
      EndIf
      $i += 1
   WEnd

   If $CmdLine[0] = 1 Then
      _ScreenCapture_Capture($CmdLine[1], $Left, $Top, $Right, $Bottom)
   Else
      _ScreenCapture_Capture(@ScriptDir & "\capture.jpg", $Left, $Top, $Right, $Bottom)
   EndIf

   _GDIPlus_Startup()
   $hImg1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\capture.jpg")
   $L1 = _GDIPlus_ImageGetWidth($hImg1)
   $H1 = _GDIPlus_ImageGetHeight($hImg1)
   _GDIPlus_ImageDispose($hImg1)
   _GDIPlus_Shutdown()

   ; Compression image
   _ImageResize(@ScriptDir & "\capture.jpg",@ScriptDir & "\capture.jpg", $L1, $H1)

EndFunc



; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Func _ImageResize($sInImage, $sOutImage, $iW, $iH)

   ; #FUNCTION# =========================================================================================
   ; Name...........: _ImageResize
   ; Description....: Resize an image and optionally convert it to the format you want.
   ; Syntax.........: _ImageResize($sInImage, $sOutImage, $iW, $iH)
   ; Parameters ....: $sInImage  - Full path to the image to resize / convert.
   ;                               In types: *.bmp, *.gif, *.ico, *.jpg, *.jpeg, *.png, *.tif, *.tiff
   ;                  $sOutImage - Full path where to save the resized / converted image.
   ;                               Out types: *.bmp, *.gif, *.jpg, *.jpeg, *.png, *.tif, *.tiff
   ;                  $iW        - Width to resize image to.
   ;                  $iH        - Height to resize image to.
   ; Return values .: Success    - Return 1 and @error 0
   ;                  Failure    - Return 0 and @error 1~5
   ;                               @error 1 = In File does not exist
   ;                               @error 2 = In File format not supported
   ;                               @error 3 = Out File path does not exist
   ;                               @error 4 = Out file format not supported
   ;                               @error 5 = Resize Width or Height not an integer
   ; ====================================================================================================

    ;declaracion de variables
    Local $sOP, $sOF, $sInExt, $Ext, $hBitmap, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
    Local $sType = "BMP|GIF|ICO|JPG|JPEG|PNG|TIF|TIFF"


    If Not FileExists($sInImage) Then Return SetError(1, 0, 0)
    $sInExt = StringUpper(StringTrimLeft($sInImage, StringInStr($sInImage, ".", 0, -1)))
    If Not StringRegExp($sInExt, "\A(" & $sType & ")\z", 0) Then Return SetError(2, 0, 0)

    ;OutFile path, to use later on.
    $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
    If Not FileExists($sOP) Then Return SetError(3, 0, 0)

    ;OutFile name, to use later on.
    $sOF = StringTrimLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))


    ;OutFile extension , to use for the encoder later on.
    $Ext = StringUpper(StringTrimLeft($sOutImage, StringInStr($sOutImage, ".", 0, -1)))
    If Not StringRegExp($Ext, "\A(" & $sType & ")\z", 0) Or $Ext = "ICO" Then Return SetError(4, 0, 0)

    If Not IsInt($iW) And Not IsInt($iH) Then Return SetError(5, 0, 0)

    ; WinAPI to create blank bitmap at the width and height to put your resized image on.
    $hBitmap = _WinAPI_CreateBitmap($iW, $iH, 1, 32)

    ;Start GDIPlus
    _GDIPlus_Startup()

    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

   ;im not sure if this is better going here or if its the best form to call it
   DllCall($ghGDIPDll, "int", "GdipSetInterpolationMode", "hwnd", $hGraphic, "int", "7")

    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)


    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

   $sOutImage = @TempDir & "\pt.jpg"

    ;Save the new resized image.
   _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_Shutdown()

   If FileExists(@ScriptDir & "\capture.jpg") Then FileDelete(@ScriptDir & "\capture.jpg")

   FileMove($sOutImage,@ScriptDir & "\capture.jpg")

    Return SetError(0, 0, 1)
EndFunc   ;==>_ImageResize
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
J'espère que cela pourra t'aider.

Cordialement.

BM
Répondre