• Offizieller Beitrag

    Hi,

    ich weiß nicht, inwiefern dies bereits bekannt ist. Evtl. kann es ja jemand gebrauchen.

    Spoiler anzeigen
    [autoit]

    #include <GuiConstants.au3>

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

    $my_gui = GUICreate("MyGUI", 392, 323)

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

    _GuiHole($my_gui, 80, 30, 200, 300)
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case Else
    ;;;
    EndSelect
    WEnd
    Exit

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

    Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
    Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret
    $pos = WinGetPos($h_win)

    $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
    If IsArray($outer_rgn) Then
    $inner_rgn = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh)
    If IsArray($inner_rgn) Then
    $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    If IsArray($combined_rgn) Then
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", 4)
    $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
    If $ret[0] Then
    Return 1
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf

    EndFunc ;==>_GuiHole

    [/autoit]

    hier mal ein kleines Bsp was man damit so machen kann:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    HotKeySet("{ESC}", "_end")

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

    Global $start = MouseGetPos()

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

    $gui = GUICreate("GUI", 30, 30, $start[0] - 15, $start[1] - 15, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x00FF00)

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

    _GUICreateInvRect($gui, 5, 5, 20, 20)
    GUISetState()

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

    While 1
    Sleep(10)
    $now = MouseGetPos()
    WinMove($gui, "", $now[0] - 15, $now[1] - 15)
    WEnd

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

    Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
    $pos = WinGetPos($hwnd)

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

    $1 = 0
    $2 = 0
    $3 = $pos[2]
    $4 = $t
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = 0
    $3 = $l
    $4 = $pos[3]
    $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = $l + $w
    $2 = 0
    $3 = $pos[2]
    $4 = $pos[3]
    $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = $t + $h
    $3 = $pos[2]
    $4 = $pos[3]
    $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

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

    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)

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

    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
    EndFunc ;==>_GUICreateInvRect

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

    Func _end()
    Exit(0)
    EndFunc

    [/autoit]

    So long,

    Mega

    • Offizieller Beitrag

    Hallo!

    Schönes script, danke :) Habe vor einiger zeit auchmal damit rumhantiert, für ein Settrans (transparten setzen) programm! Leider hab ich das programm weggeworfen ~~ hab es in einfacher form nochmal mit deiner Funktion nachgebaut.. das programm umrandet einfach nur das momentan aktive fenster..

    Also noch ein bsp:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    HotKeySet("{ESC}", "_end")
    MsgBox(0,"by gtaspider","Close mit ESC!")
    Global $start = MouseGetPos()

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

    $gui = GUICreate("GUI", 30, 30, $start[0] - 15, $start[1] - 15, $WS_POPUP, $WS_EX_TOPMOST+$WS_EX_TOOLWINDOW)
    GUISetBkColor(0xff0000)
    ;~ _GUICreateInvRect($gui, 5, 5, 20, 20)
    GUISetState()

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

    While 1
    Sleep(100)
    $now = WinGetTitle("")
    $now = WinGetPos($now)
    WinMove($gui, "", $now[0], $now[1],$now[2],$now[3])
    _GUICreateInvRect($gui, 5, 5, $now[2]-10, $now[3]-10)
    WEnd

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

    Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
    $pos = WinGetPos($hwnd)

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

    $1 = 0
    $2 = 0
    $3 = $pos[2]
    $4 = $t
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = 0
    $3 = $l
    $4 = $pos[3]
    $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = $l + $w
    $2 = 0
    $3 = $pos[2]
    $4 = $pos[3]
    $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = $t + $h
    $3 = $pos[2]
    $4 = $pos[3]
    $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

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

    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)

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

    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
    EndFunc ;==>_GUICreateInvRect

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

    Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
    Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret
    $pos = WinGetPos($h_win)

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

    $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
    If IsArray($outer_rgn) Then
    $inner_rgn = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh)
    If IsArray($inner_rgn) Then
    $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    If IsArray($combined_rgn) Then
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", 4)
    $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
    If $ret[0] Then
    Return 1
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf

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

    EndFunc ;==>_GuiHole

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

    Func _end()
    Exit (0)
    EndFunc ;==>_end

    [/autoit]

    Mfg Spider