#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <File.au3>
#include <ScreenCapture.au3>
Opt("PixelCoordMode", 2)
global $color = 'ed1b24'
global $mainimg = @ScriptDir & "\sss.jpg"
global $grafickimg = @ScriptDir & "\ddd.jpg"
_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromFile($mainimg)
$img_w = _GDIPlus_ImageGetWidth($hBitmap)
$img_y = _GDIPlus_ImageGetHeight($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
$gui_w = @desktopwidth-60
$gui_y = @DesktopHeight-100
$normalize_w = $img_w/$gui_w
$normalize_y = $img_y/$gui_y
if($img_y/$normalize_w < $gui_y) Then
$total_w = $gui_w
$total_y = $img_y/$normalize_w
Else
$total_w = $img_w/$normalize_y
$total_y = $gui_y
EndIf
$hgui = GUICreate($mainimg, $gui_w, $gui_y, -1, -1, $WS_POPUP) ; Создаёт окно в центре экрана
$hImage = GUICtrlCreatePic($mainimg, 0, 0, $total_w, $total_y)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
WinWaitActive($hgui)
sleep(250)
$pixel_left_top_coords = PixelSearch(0, 0, $gui_w, $gui_y,'0x' & $color,0,5,$hgui)
if @error <> 1 Then
$pixel_right_top_coords = PixelSearch($gui_w, $pixel_left_top_coords[1], $pixel_left_top_coords[0], $pixel_left_top_coords[1],'0x' & $color,0,5,$hgui)
$pixel_left_bottom_coords = PixelSearch(0, $gui_y, $gui_w, 0,'0x' & $color,0,5,$hgui)
$pixel_right_bottom_coords = PixelSearch($gui_w, $pixel_left_bottom_coords[1], $pixel_left_bottom_coords[0], $pixel_left_top_coords[1],'0x' & $color,0,5,$hgui)
_ScreenCapture_CaptureWnd($grafickimg, $hgui, $pixel_left_top_coords[0]-5, $pixel_left_top_coords[1]-5, $pixel_right_bottom_coords[0]+5, $pixel_right_bottom_coords[1]+5, False)
Else
msgbox(0,"","рамка вокруг графика не найдена")
EndIf
GUIDelete()