Jump to content

AutoIt drawing overlay


Recommended Posts

Hi, I'm new to the forums but have been trying to learn AutoIT for a few weeks now and managed to automate some cool stuff at the startup of my pc etc...

I was thinking about 1 cool thing I don't think is possible in AutoIT but I felt like asking before giving up.

 

Is there a way to make draw an overlay that is "always on top" around a window. I would put a label somewhere there with the status of the part of the animation it's doing.

I would also need the option of it being "click throughable", that's the best way I can say it.

 

Thanks in advance.

Link to comment
Share on other sites

@Rexit Take a look at this thread and run uez code.  Let see if that it's close enough to go further.  It hasn't have the click throughable thing.  But could serve as a starter...

 

Link to comment
Share on other sites

11 minutes ago, Nine said:

@Rexit Take a look at this thread and run uez code.  Let see if that it's close enough to go further.  It hasn't have the click throughable thing.  But could serve as a starter...

 

The ability to click through is the most important part...

Link to comment
Share on other sites

This may help you.
I haven't been able to drag the border with Notepad or the main GUI.
Someone else may be able to help with this if this is the type of idea you wanted.

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPISysWin.au3>

Global $iBorder = 50, $hGUIMain, $hWndBorder

;Local $hGUIMain = GUICreate("Example")
; or
Run("notepad.exe", "")
$hGUIMain = WinWait("[CLASS:Notepad]", "", 10)

WinSetOnTop($hGUIMain, "", 1)
GUISetState(@SW_SHOW, $hGUIMain)

$aPos = WinGetPos($hGUIMain) ;Get windowsize
$hWndBorder = _GuiBorder($aPos, "Window's Title: " & WinGetTitle($hGUIMain))

;ConsoleWrite("$hWndBorder: " & $hWndBorder & @CRLF)
;ConsoleWrite("$hGUIMain: " & $hGUIMain & @CRLF)

GUIRegisterMsg($WM_MOUSEMOVE, "_WinMove")
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "_WinMove")

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Or Not WinExists($hGUIMain) Or Not WinExists($hWndBorder) Then
        If WinExists($hWndBorder) Then GUIDelete($hWndBorder)
        If WinExists($hGUIMain) Then WinClose($hGUIMain)
        ExitLoop
    EndIf
WEnd


Func _GuiBorder($aGUIPos, $sText = "Window information")
    Local $iWidth = 2 * $iBorder + $aGUIPos[2]
    Local $iHeight = 2 * $iBorder + $aGUIPos[3]
    Local $hGUI, $aSize, $hRegion, $hRegion1, $hRGN
    $hGUI = GUICreate("GDI+", $iWidth, $iHeight, $aGUIPos[0] - $iBorder, $aGUIPos[1] - $iBorder, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x00FFFF) ;Set window background color to blue
    GUICtrlCreateLabel($sText, 0, 0, $iWidth - 10, 30, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $aSize = WinGetPos($hGUI) ;Get windowsize
    $hRegion1 = _GDIPlus_RegionCreateFromRect($iBorder + 7, $iBorder + 1, $aSize[2] - $iBorder * 2 - 14, $aSize[3] - $iBorder * 2 - 8)
    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $aSize[2], $aSize[3])
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion1, 3)
    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Clean up resources
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_Shutdown()
    Return $hGUI
EndFunc   ;==>_GuiBorder

Func _WinMove($hWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG
    ;ConsoleWrite($hWnd & @CRLF)
    If $hWnd = $hWndBorder Then
        $aPos = WinGetPos($hWndBorder)
        WinMove($hGUIMain, "", $aPos[0] + $iBorder, $aPos[1] + $iBorder)
    EndIf
EndFunc   ;==>_WinMove

 

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