Screenshot von Markierung machen

  • Wiedereinmal ein Skript, das es schon einige Male gibt, aber ich will immer alles auf meine Art machen ;)
    Zuerst Bereich markieren, F9 für Screenshot, Esc für Ende.

    Viel Spaß damit!

    Spoiler anzeigen
    [autoit]

    #include <Constants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $xStart = 0, $yStart = 0, $xStopp = 0, $yStopp = 0
    Global $title = 'Screenshot markieren'
    If Not IsDeclared("SM_VIRTUALWIDTH") Then Global Const $SM_VIRTUALWIDTH = 78
    If Not IsDeclared("SM_VIRTUALHEIGHT") Then Global Const $SM_VIRTUALHEIGHT = 79
    Global $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $VirtualDesktopWidth = $VirtualDesktopWidth[0]
    Global $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $VirtualDesktopHeight = $VirtualDesktopHeight[0]

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate($title, $VirtualDesktopWidth, $VirtualDesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUIRegisterMsg(0x0201, '_WM_LBUTTONDOWN') ;$WM_LBUTTONDOWN
    GUIRegisterMsg(0x0202, '_WM_LBUTTONUP') ;$WM_LBUTTONUP
    ;~ GUIRegisterMsg(0x0204, '_WM_RBUTTONDOWN') ;$WM_RBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit]

    WinSetTrans($title, "", 30)

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists(@ScriptDir & "\Screenshots") Then DirCreate(@ScriptDir & "\Screenshots")
    Global $hGraphic = GUICtrlCreateGraphic(0, 0, $VirtualDesktopWidth, $VirtualDesktopHeight)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 2)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    HotKeySet('{F9}', '_Make_Screenshot')
    HotKeySet('{ESC}', '_quit')

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _quit()
    Exit
    EndFunc ;==>_quit

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_LBUTTONDOWN($hWnd, $msg, $wParam, $lParam)
    Local $fwKeys = $wParam, $xPos = BitAND($lParam, 0xFFFF), $yPos = BitShift($lParam, 16)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0xffffff)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_RECT, $xStart, $yStart, $xStopp - $xStart, $yStopp - $yStart)
    ;~ GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH)
    $xStart = $xPos
    $yStart = $yPos
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_LBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_LBUTTONUP($hWnd, $msg, $wParam, $lParam)
    Local $fwKeys = $wParam, $xPos = BitAND($lParam, 0xFFFF), $yPos = BitShift($lParam, 16)
    $xStopp = $xPos
    $yStopp = $yPos
    GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0x0)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_RECT, $xStart, $yStart, $xStopp - $xStart, $yStopp - $yStart)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_LBUTTONUP

    [/autoit] [autoit][/autoit] [autoit]

    ;~ Func _WM_RBUTTONDOWN($hWnd, $msg, $wParam, $lParam)
    ;~ Local $fwKeys = $wParam, $xPos = BitAND($lParam, 0xFFFF), $yPos = BitShift($lParam, 16)
    ;~ GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0xffffff)
    ;~ GUICtrlSetGraphic($hGraphic, $GUI_GR_RECT, $xStart, $yStart, $xStopp - $xStart, $yStopp - $yStart)
    ;~ GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH)
    ;~ Return $GUI_RUNDEFMSG
    ;~ EndFunc ;==>_WM_RBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit]

    Func _Make_Screenshot()
    Local $x1, $x2, $y1, $y2
    Select
    Case $xStart < $xStopp
    $x1 = $xStart
    $x2 = $xStopp
    Case $xStart > $xStopp
    $x1 = $xStopp
    $x2 = $xStart
    EndSelect
    Select
    Case $yStart < $yStopp
    $y1 = $yStart
    $y2 = $yStopp
    Case $yStart > $yStopp
    $y1 = $yStopp
    $y2 = $yStart
    EndSelect
    If $x1 > 0 And $x2 > 0 And $y1 > 0 And $y2 > 0 Then _ScreenCapture_Capture(@ScriptDir & "\Screenshots\Screenshot" & @YEAR & @MDAY & @WDAY & "_" & @HOUR & @MIN & @SEC & ".jpg", $x1, $y1, $x2, $y2, False)
    EndFunc ;==>_Make_Screenshot

    [/autoit] [autoit][/autoit] [autoit]

    ;~ MK_LBUTTONUP The left mouse button is up. --> 0x00
    ;~ MK_LBUTTON The user pressed the left mouse button. --> 0x01
    ;~ MK_RBUTTON The user pressed the right mouse button. --> 0x02
    ;~ MK_SHIFT The user pressed the SHIFT key. --> 0x04
    ;~ MK_CONTROL The user pressed the CTRL key. --> 0x08
    ;~ MK_MBUTTON The user pressed the middle mouse button. --> 0x10

    [/autoit]
  • Sehr toll. Find ich sehr gut dein Script! ich würde es gern für mein besonderes Bedürfnis anpassen/erweitern.
    Ich möchte gern die Funktion einbauen, dass wenn ich nach der Markierung F8 drücke, dass der Screenshot im Zwischenspeicher landet. Und das Script beendet wird ohne extra noch ESC zu drücken, da ich ja nur einen machen möchte/kann.

  • Sorry, hab dass mit dem Zwischenspeicher überlesen :P

    Spoiler anzeigen
    [autoit]

    #include <Constants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>
    #Include <Clipboard.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $xStart = 0, $yStart = 0, $xStopp = 0, $yStopp = 0
    Global $title = 'Screenshot markieren'
    If Not IsDeclared("SM_VIRTUALWIDTH") Then Global Const $SM_VIRTUALWIDTH = 78
    If Not IsDeclared("SM_VIRTUALHEIGHT") Then Global Const $SM_VIRTUALHEIGHT = 79
    Global $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $VirtualDesktopWidth = $VirtualDesktopWidth[0]
    Global $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $VirtualDesktopHeight = $VirtualDesktopHeight[0]

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate($title, $VirtualDesktopWidth, $VirtualDesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUIRegisterMsg(0x0201, '_WM_LBUTTONDOWN') ;$WM_LBUTTONDOWN
    GUIRegisterMsg(0x0202, '_WM_LBUTTONUP') ;$WM_LBUTTONUP
    ;~ GUIRegisterMsg(0x0204, '_WM_RBUTTONDOWN') ;$WM_RBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit]

    WinSetTrans($title, "", 30)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGraphic = GUICtrlCreateGraphic(0, 0, $VirtualDesktopWidth, $VirtualDesktopHeight)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 2)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    HotKeySet('{F8}', '_Make_Screenshot')
    HotKeySet('{ESC}', '_quit')

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _quit()
    Exit
    EndFunc ;==>_quit

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_LBUTTONDOWN($hWnd, $msg, $wParam, $lParam)
    Local $fwKeys = $wParam, $xPos = BitAND($lParam, 0xFFFF), $yPos = BitShift($lParam, 16)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0xffffff)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_RECT, $xStart, $yStart, $xStopp - $xStart, $yStopp - $yStart)
    ;~ GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH)
    $xStart = $xPos
    $yStart = $yPos
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_LBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_LBUTTONUP($hWnd, $msg, $wParam, $lParam)
    Local $fwKeys = $wParam, $xPos = BitAND($lParam, 0xFFFF), $yPos = BitShift($lParam, 16)
    $xStopp = $xPos
    $yStopp = $yPos
    GUICtrlSetGraphic($hGraphic, $GUI_GR_COLOR, 0x0)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_RECT, $xStart, $yStart, $xStopp - $xStart, $yStopp - $yStart)
    GUICtrlSetGraphic($hGraphic, $GUI_GR_REFRESH)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_LBUTTONUP

    [/autoit] [autoit][/autoit] [autoit]

    Func _Make_Screenshot()
    Local $x1, $x2, $y1, $y2, $hBitmap
    Select
    Case $xStart < $xStopp
    $x1 = $xStart
    $x2 = $xStopp
    Case $xStart > $xStopp
    $x1 = $xStopp
    $x2 = $xStart
    EndSelect
    Select
    Case $yStart < $yStopp
    $y1 = $yStart
    $y2 = $yStopp
    Case $yStart > $yStopp
    $y1 = $yStopp
    $y2 = $yStart
    EndSelect
    If $x1 > 0 And $x2 > 0 And $y1 > 0 And $y2 > 0 Then
    $hBitmap = _ScreenCapture_Capture("", $x1, $y1, $x2, $y2, False)
    _ClipBoard_SetData($hBitmap, $CF_BITMAP)
    Exit
    EndIf
    EndFunc ;==>_Make_Screenshot

    [/autoit]
  • Perfekt!!! Danke danke danke. Toll!

    Edit: Toll, jetzt wo du es geschrieben hast, hab ich es in der UDFs3.chm gefunden... blöd. :)