Jump to content

edit pictures with autoit


lilx
 Share

Recommended Posts

Hello,

I made my self a program where i can easily take screenshots with my webcam thats working fine and very happy of it. But know trying to perfection ate my program I want to add to it, When I take a picture I want in some kind of way that I can cut out a part of the picture and save the part that is cute to a picture.

The current situation is I take a screenshot with my program then I need to edit that picture with paint and then save it. The reason why I need to edit my pictures is because i only need close up pictures of the face.

I hope you guys can help or at least say if it is possible. I am still quite amateur with programming so I am not able to create highly difficult application. So maybe you guys can help. and make it so easly as possible

Link to comment
Share on other sites

Hay Lilx,

when you say you want a way to cut out part of your image do you want to do this Manually after each image is Captured? So basicly you use your program as it is, it captures an image, then the image pops up and you can Select the persons face and it auto saves that to a new image? or did you want to be able to predifine an area to extract on each image?

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

hi,

it would be great if it would be possible to make your first suggestion

Manually after each image is Captured? So basicly you use your program as it is, it captures an image, then the image pops up and you can Select the persons face and it auto saves that to a new image?

Link to comment
Share on other sites

Here is one way you might do it. In this example just run the script then Left click at the Top-Left location of the total area you want to Save, then the bottom right.

#include <Misc.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Sleep(500)
$SearchArea = _DrawRect_Drag("01") ;Define Search area "01"=Left mouse Click
_ScreenCapture_Capture("Test.bmp",$SearchArea[0],$SearchArea[1],$SearchArea[2],$SearchArea[3])


;=================================   _DrawRect_Drag   ============================
; Function Name:    _DrawRect_Drag
; Requires:         <GUIConstants.au3> & <Misc.au3>
; Description:      Gives a visual aid while defineing Top\Left|bottom\Right of a given area
; Parameters:       $ActionKey      Hex code for key to press to begin and end render
;                   $color          Color of the display box
; Syntax:            _DrawRect_Drag([$ActionKey][,$color])
; Author(s):        ofLight
; Returns:          $array[4]      $array[0] = Left, $array[1] = Top, $array[2] = Right, $array[3] = Bottom
;===============================================================================
Func _DrawRect_Drag($ActionKey = "2D", $color = 0xFF0000)

    ;Opt("WinTitleMatchMode", 1)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
    ;Opt("PixelCoordMode", 0)        ;1=absolute, 0=relative, 2=client
    ;Opt("MouseCoordMode", 0)        ;1=absolute, 0=relative, 2=client
    ;Opt("GUIOnEventMode", 1)

    Do
        $pos = MouseGetPos()
        Sleep(25)
    Until _IsPressed($ActionKey)
    
    Local $ScanWidth = 1, $ScanHeight = 1
    Local $positions[4]
    $positions[0] = $pos[0] ;LEFT
    $positions[1] = $pos[1] ;TOP
    $x = $pos[0]
    $y = $pos[1]
    
    $GUI_DR = GUICreate("", 0, 0, $x, $y, $WS_POPUP)
    WinSetTrans($GUI_DR,"",210)
    $Top_DR = GUICreate("Top Line", $ScanWidth, 2, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Top_DR,"",210)
    GUISetState()
    $Left_DR = GUICreate("Left Line", 2, $ScanHeight, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Left_DR,"",210)
    GUISetState()
    $Right_DR = GUICreate("Right Line", 2, $ScanHeight, $x + $ScanWidth - 2, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Right_DR,"",210)
    GUISetState()
    $Bottom_DR = GUICreate("Bottom Line", $ScanWidth, 2, $x, $y + $ScanHeight, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Bottom_DR,"",210)
    GUISetState()
    Sleep(800)
    
    Do
        $MousePos = MouseGetPos()
        WinMove($Top_DR, "", $x, $y, $ScanWidth, 2)
        WinMove($Left_DR, "", $x, $y, 2, $ScanHeight) 
        WinMove($Right_DR, "", $x + $ScanWidth - 2, $y, 2, $ScanHeight)  
        WinMove($Bottom_DR, "", $x, $y + $ScanHeight, $ScanWidth, 2)
        If Not (($MousePos[0] - $x) <= 0) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y) <= 0) Then
            $ScanHeight = $MousePos[1] - $y - 1
        EndIf
    Until _IsPressed($ActionKey)
    
    $positions[2] = $MousePos[0] ;RIGHT
    $positions[3] = $MousePos[1] ;BOTTOM
    
    GUISetState(@SW_HIDE,$GUI_DR)
    GUISetState(@SW_HIDE,$Top_DR)
    GUISetState(@SW_HIDE,$Left_DR)
    GUISetState(@SW_HIDE,$Right_DR)
    GUISetState(@SW_HIDE,$Bottom_DR)

    Return $positions
EndFunc;==========================   _DrawRect_Drag   ============================

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

Here is one way you might do it. In this example just run the script then Left click at the Top-Left location of the total area you want to Save, then the bottom right.

#include <Misc.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Sleep(500)
$SearchArea = _DrawRect_Drag("01") ;Define Search area "01"=Left mouse Click
_ScreenCapture_Capture("Test.bmp",$SearchArea[0],$SearchArea[1],$SearchArea[2],$SearchArea[3])


;=================================   _DrawRect_Drag   ============================
; Function Name:    _DrawRect_Drag
; Requires:         <GUIConstants.au3> & <Misc.au3>
; Description:      Gives a visual aid while defineing Top\Left|bottom\Right of a given area
; Parameters:       $ActionKey      Hex code for key to press to begin and end render
;                   $color          Color of the display box
; Syntax:            _DrawRect_Drag([$ActionKey][,$color])
; Author(s):        ofLight
; Returns:          $array[4]      $array[0] = Left, $array[1] = Top, $array[2] = Right, $array[3] = Bottom
;===============================================================================
Func _DrawRect_Drag($ActionKey = "2D", $color = 0xFF0000)

    ;Opt("WinTitleMatchMode", 1)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
    ;Opt("PixelCoordMode", 0)        ;1=absolute, 0=relative, 2=client
    ;Opt("MouseCoordMode", 0)        ;1=absolute, 0=relative, 2=client
    ;Opt("GUIOnEventMode", 1)

    Do
        $pos = MouseGetPos()
        Sleep(25)
    Until _IsPressed($ActionKey)
    
    Local $ScanWidth = 1, $ScanHeight = 1
    Local $positions[4]
    $positions[0] = $pos[0] ;LEFT
    $positions[1] = $pos[1] ;TOP
    $x = $pos[0]
    $y = $pos[1]
    
    $GUI_DR = GUICreate("", 0, 0, $x, $y, $WS_POPUP)
    WinSetTrans($GUI_DR,"",210)
    $Top_DR = GUICreate("Top Line", $ScanWidth, 2, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Top_DR,"",210)
    GUISetState()
    $Left_DR = GUICreate("Left Line", 2, $ScanHeight, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Left_DR,"",210)
    GUISetState()
    $Right_DR = GUICreate("Right Line", 2, $ScanHeight, $x + $ScanWidth - 2, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Right_DR,"",210)
    GUISetState()
    $Bottom_DR = GUICreate("Bottom Line", $ScanWidth, 2, $x, $y + $ScanHeight, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Bottom_DR,"",210)
    GUISetState()
    Sleep(800)
    
    Do
        $MousePos = MouseGetPos()
        WinMove($Top_DR, "", $x, $y, $ScanWidth, 2)
        WinMove($Left_DR, "", $x, $y, 2, $ScanHeight) 
        WinMove($Right_DR, "", $x + $ScanWidth - 2, $y, 2, $ScanHeight)  
        WinMove($Bottom_DR, "", $x, $y + $ScanHeight, $ScanWidth, 2)
        If Not (($MousePos[0] - $x) <= 0) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y) <= 0) Then
            $ScanHeight = $MousePos[1] - $y - 1
        EndIf
    Until _IsPressed($ActionKey)
    
    $positions[2] = $MousePos[0] ;RIGHT
    $positions[3] = $MousePos[1] ;BOTTOM
    
    GUISetState(@SW_HIDE,$GUI_DR)
    GUISetState(@SW_HIDE,$Top_DR)
    GUISetState(@SW_HIDE,$Left_DR)
    GUISetState(@SW_HIDE,$Right_DR)
    GUISetState(@SW_HIDE,$Bottom_DR)

    Return $positions
EndFunc;==========================   _DrawRect_Drag   ============================
hello light,

this is a real great function. just tested it. and i will be tryin to inplant it into my script.

i hope that if i encounter some problems i can still ask them. many thanks mate :)

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...