Jump to content

GUI POPUP RESIZEABLE MOVEABLE TRANSPARENT


Recommended Posts

hello guys im new here. im looking for help with my 'box hui'. i want to make it work perfect but i cantget right way. i have few examples. plz help me to fix it or give me any method to 'paint' box

all i want to make box empty inside u can move it and resize and popup.
sorry formy english

 

#include <GUIConstants.au3>

    HotKeySet("{q}", "_quit")
    HotKeySet("{a}", "_boxplus")
    HotKeySet("{z}", "_boxminus")

$GUI = GUICreate("Clicker", 500, 400,0, 0, -1)
MsgBox(1,"info", " Press Q to Quit" & @LF & " Press A to size up"& @LF & " Press Z to size down")
$BoxTop = GUICreate('',2,2,0,0,$WS_POPUP,$WS_EX_TOPMOST);WHLT
GUISetBkColor(0x00ff00);Green
$BoxRight = GUICreate('',2,2,2,0,$WS_POPUP,$WS_EX_TOPMOST,$BoxTop)
GUISetBkColor(0x00ff00)
$BoxBottom = GUICreate('',2,2,2,2,$WS_POPUP,$WS_EX_TOPMOST,$BoxTop);WHLT
GUISetBkColor(0x00ff00)
$BoxLeft = GUICreate('',2,2,0,2,$WS_POPUP,$WS_EX_TOPMOST,$BoxTop);WHLT
GUISetBkColor(0x00ff00)

$box_range = 50

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
        $pos = MouseGetPos()
        GUISetState (@SW_SHOW,$BoxTop)
        GUISetState (@SW_SHOW,$BoxLeft)
        GUISetState (@SW_SHOW,$BoxBottom)
        GUISetState (@SW_SHOW,$BoxRight)
        WinMove($BoxTop,'',     MouseGetPos(0)-$box_range,MouseGetPos(1)-$box_range,$box_range*2,3)
        WinMove($BoxBottom,'',  MouseGetPos(0)-$box_range,MouseGetPos(1)+$box_range,$box_range*2,3)
        WinMove($BoxLeft,'',    MouseGetPos(0)+$box_range,MouseGetPos(1)-$box_range,3,$box_range*2)
        WinMove($BoxRight,'',   MouseGetPos(0)-$box_range,MouseGetPos(1)-$box_range,3,$box_range*2)
WEnd

Func _boxminus()
        $box_range = $box_range - 10
EndFunc

Func _boxplus()
        $box_range = $box_range + 10
EndFunc

Func _quit()
        Exit
    EndFunc
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

 HotKeySet("q", "_Quit")
 HotKeySet("w", "_CutGui")

Global $GUI = GUICreate("Empty Window", 200, 200,500,100,$WS_SIZEBOX)
$cut_gui = GUICtrlCreateButton("Cut Inside Gui", 50, 100, 100)
GUISetState(@SW_SHOW)

Local $iMsg
While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $iMsg = $cut_gui
            _CutGui()
    EndSelect
WEnd

Func _CutGui()
    Local $aPos = WinGetPos($GUI)
    $gui_full = _WinAPI_CreateRectRgn(0, 0, $aPos[2], $aPos[3])
    $gui_part = _WinAPI_CreateRectRgn(8, 30, $aPos[2]-8, $aPos[3]-8)
    $gui_RGN = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($gui_RGN, $gui_full, $gui_part, $RGN_DIFF)
    _WinAPI_SetWindowRgn($GUI, $gui_RGN)
EndFunc   ;==>_GuiHole

 Func _Quit()
     Exit
 EndFunc
#include <GuiConstantsEx.au3>
#include <Windowsconstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>


 Global Const $SC_DRAGMOVE = 0xF012

 HotKeySet("{ESC}", "_Quit")

 ; Set distance from edge of window where resizing is possible
 Global Const $iMargin = 10

 $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP,$WS_SIZEBOX)
 GUISetBkColor(0x00FF00)
 GUISetState()

 ; Register message handlers
 GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")            ; For cursor type change
 GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")     ; For resize/drag

 While 1

     _GDIPlus_Startup()
    $aPos = WinGetPos($hGUI)
    $hPath = _GDIPlus_PathCreate() ;tworzenie ścieżki
    _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
    $hReg = _GDIPlus_RegionCreateFromPath($hPath)
    $hReg2 = _GDIPlus_RegionCreateFromRect(20, 20, $aPos[2]-40, $aPos[3]-40)
    _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3) ;łączenie regionów typu XOR
    $hRGN = _GDIPlus_RegionGetHRgn($hReg)
    _WinAPI_SetWindowRgn($hGUI, $hRGN)

    ;zwolnienie zasobów
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hReg)
    _GDIPlus_RegionDispose($hReg2)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()

    Sleep(10)
 WEnd

 ; Set cursor to correct resizing form if mouse is over a border
 Func _SetCursor()
     Local $iCursorID
     Switch _Check_Border()
         Case 0
             $iCursorID = 2
         Case 1, 2
             $iCursorID = 13
         Case 3, 6
             $iCursorID = 11
         Case 5, 7
             $iCursorID = 10
         Case 4, 8
             $iCursorID = 12
     EndSwitch
     GUISetCursor($iCursorID, 1)
 EndFunc ;==>SetCursor

 ; Check cursor type and resize/drag window as required
 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
     Local $iCursorType = _Check_Border()
     If $iCursorType > 0 Then ; Cursor is set to resizing style so send appropriate resize message
         $iResizeType = 0xF000 + $iCursorType
         _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0)
     Else
         Local $aCurInfo = GUIGetCursorInfo($hGUI)
         If $aCurInfo[4] = 0 Then ; Mouse not over a control
             _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
         EndIf
     EndIf
 EndFunc ;==>WM_LBUTTONDOWN

 ; Determines if mouse cursor over a border
 Func _Check_Border()
     Local $aCurInfo = GUIGetCursorInfo()
     If @error Then Return -1
     Local $aWinPos = WinGetPos($hGUI)
     Local $iSide = 0
     Local $iTopBot = 0
     If $aCurInfo[0] < $iMargin Then $iSide = 1
     If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2
     If $aCurInfo[1] < $iMargin Then $iTopBot = 3
     If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6
     Return $iSide + $iTopBot
 EndFunc ;==>_Check_Border



 Func _Quit()
     Exit
 EndFunc

 

Link to comment
Share on other sites

Maybe this ?

#include <GuiConstantsEx.au3>
 #include <Windowsconstants.au3>
 #include <SendMessage.au3>
 #include <WinAPI.au3>

 Global Const $SC_DRAGMOVE = 0xF012
 
 HotKeySet("{ESC}", "On_Exit")
 
 ; Set distance from edge of window where resizing is possible
 Global Const $iMargin = 4
 
 ; Create GUI
 $hGUI = GUICreate("Y", 120, 120, -1, -1, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_COMPOSITED, $WS_EX_TOPMOST))
 GUISetBkColor(0x00FF00)
$btn = GuiCtrlCreateButton("close", 20, 20, 60, 25)
GuiCtrlCreateLabel("", 10, 10, 100, 100)
GUICtrlSetBkColor(-1, 0xABCDEF)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
 GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)


 ; Register message handlers
 GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")            ; For cursor type change
 GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")     ; For resize/drag
 
 While 1
$msg = GUIGetMsg()
Switch $msg
    Case $btn
           On_Exit()
 EndSwitch
WEnd
 
 ; Set cursor to correct resizing form if mouse is over a border
 Func _SetCursor()
     Local $iCursorID
     Switch _Check_Border()
         Case 0
             $iCursorID = 2
         Case 1, 2
             $iCursorID = 13
         Case 3, 6
             $iCursorID = 11
         Case 5, 7
             $iCursorID = 10
         Case 4, 8
             $iCursorID = 12
     EndSwitch
     GUISetCursor($iCursorID, 1)
 EndFunc ;==>SetCursor
 
 ; Check cursor type and resize/drag window as required
 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
     Local $iCursorType = _Check_Border()
     If $iCursorType > 0 Then ; Cursor is set to resizing style so send appropriate resize message
         $iResizeType = 0xF000 + $iCursorType
         _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0)
     Else
         Local $aCurInfo = GUIGetCursorInfo($hGUI)
         If $aCurInfo[4] = 0 Then ; Mouse not over a control
             _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
         EndIf
     EndIf
 EndFunc ;==>WM_LBUTTONDOWN
 
 ; Determines if mouse cursor over a border
 Func _Check_Border()
     Local $aCurInfo = GUIGetCursorInfo()
     If @error Then Return -1
     Local $aWinPos = WinGetPos($hGUI)
     Local $iSide = 0
     Local $iTopBot = 0
     If $aCurInfo[0] < $iMargin Then $iSide = 1
     If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2
     If $aCurInfo[1] < $iMargin Then $iTopBot = 3
     If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6
     Return $iSide + $iTopBot
 EndFunc ;==>_Check_Border
 
 
 Func On_Exit()
     Exit
 EndFunc

 

Edited by mikell
Link to comment
Share on other sites

txh bro. works perfect

EDIT: Almost perfect...

u added in scrpit 

GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")            ; For cursor type change
 GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")     ; For resize/drag

so after i done that box function, GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")  and GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") still exist for whole script. how to set this function back after i finish box one ??? i mean how UNREGISTER this.

or just set this function working only for box gui 

PLZ HELP

EDIT DONE

i have another small problem. code is working perfect (guess) but im sure can do it much easier
needed: Crate box, resize it by hotkeys
any suggestion how do it easier way ???

 

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

HotKeySet("{ESC}", "On_Exit")

$GUI = GUICreate("Clicker", 100, 100,-1,-1)
GUISetState()

$button_get_image = GUICtrlCreateButton("get box", -1,-1)
$size = 100

Local $hGui ; Local ?? Global ?? i dont get it what is right

While 1
    $pos = MouseGetPos()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_get_image
            _getimg()
    EndSwitch
WEnd

Func _getimg()
    HotKeySet("{[}", "_boxminus")
    HotKeySet("{]}", "_boxplus")

    GUISetState(@SW_MINIMIZE, $GUI)
    Global $hGUI = GUICreate(" Test", $size, $size, $pos[0] - ($size / 2), $pos[1] - ($size / 2), $WS_POPUP,-1,$GUI)
    GUISetBkColor(0xff0000, $hGUI)
    GUISetState()

    _GDIPlus_Startup()
    $aPos = WinGetPos($hGUI)
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
    $hReg = _GDIPlus_RegionCreateFromPath($hPath)
    $hReg2 = _GDIPlus_RegionCreateFromRect(3, 3, $aPos[2] - 6, $aPos[3] - 6)
    _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
    $hRGN = _GDIPlus_RegionGetHRgn($hReg)
    _WinAPI_SetWindowRgn($hGUI, $hRGN)

    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hReg)
    _GDIPlus_RegionDispose($hReg2)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()

    $lupa_aktywna = True

    While $lupa_aktywna = True
        $pos = MouseGetPos()
        WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
        While _IsPressed('01')
            GUISetState(@SW_HIDE, $hGUI)
            $lupa_aktywna = False
            HotKeySet("[")
            HotKeySet("]")
        WEnd
    WEnd
EndFunc   ;==> crate box

Func _boxminus()
    If $size >= 30 Then $size = $size - 10
    If $size < 30 Then $size = $size - 1

    WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
    _GDIPlus_Startup()
    $aPos = WinGetPos($hGUI)
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
    $hReg = _GDIPlus_RegionCreateFromPath($hPath)
    $hReg2 = _GDIPlus_RegionCreateFromRect(3, 3, $aPos[2] - 6, $aPos[3] - 6)
    _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
    $hRGN = _GDIPlus_RegionGetHRgn($hReg)
    _WinAPI_SetWindowRgn($hGUI, $hRGN)

    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hReg)
    _GDIPlus_RegionDispose($hReg2)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc

Func _boxplus()
    $size = $size + 10

    WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
    _GDIPlus_Startup()
    $aPos = WinGetPos($hGUI)
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
    $hReg = _GDIPlus_RegionCreateFromPath($hPath)
    $hReg2 = _GDIPlus_RegionCreateFromRect(3, 3, $aPos[2] - 6, $aPos[3] - 6)
    $aPos = WinGetPos($hGUI)
    _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
    $hRGN = _GDIPlus_RegionGetHRgn($hReg)
    _WinAPI_SetWindowRgn($hGUI, $hRGN)

    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hReg)
    _GDIPlus_RegionDispose($hReg2)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc


 Func On_Exit()
     Exit
 EndFunc

 

 

Edited by Verssuss
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...