Jump to content

Simple overlay


Recommended Posts

I was wondering if anyone could help me or point me in the right direction with a project I'm trying to do.

Basically all I want to do is create a graphic overlay (a grid) on the screen and someone allow the user to adjust the size of the grid. The AutoIt script will the use the position and the size of the grid to accomplish the tasks I want. The grid would have to be transparent and the script should be allowed to click through it.

I did use search and I came across GhostIt which would allow me to accomplish this to some degree. I haven't tried it yet, but before I jump in head first, I wanted to see if there was possibly another approach I can take.

Link to comment
Share on other sites

  • Moderators


Welcome to the Autoit forum. :D

From what I can see from the thread, GhostIt does not pass clicks. So drawing a GDI grid might be a better bet as this does allow clicks to pass.

Perhaps something like this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

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

Global $hGUI, $aRadio[5], $hButton, $iStep

$hGUI = GUICreate("Grid", 150, 190)

GUICtrlCreateLabel("Choose a grid step value", 10, 10, 150, 20)

For $i = 0 To 4
    $aRadio[$i] = GUICtrlCreateRadio(100 + ($i * 100), 55,  30 + ($i * 20), 100, 20)
GUICtrlSetState($aRadio[0], $GUI_CHECKED)

$hButton = GUICtrlCreateButton("Show Grid", 35, 150, 80, 30)


While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $hButton
            GUISetState(@SW_HIDE, $hGUI)
            For $i = 0 To 4
                If GUICtrlRead($aRadio[$i]) = 1 Then
                    $iStep = GUICtrlRead($aRadio[$i], 1)


; -------------

Func Grid()

    Local $iVerticals = Floor(@DesktopWidth / $iStep)
    Local $iHorizontals = Floor(@DesktopHeight / $iStep)

    Local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)

    Local $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)

    For $i = 0 To $iVerticals
        $hMask = _WinAPI_CreateRectRgn($i * $iStep, 0, ($i * $iStep) + 1,  @DesktopHeight)
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)

    For $i = 0 To $iHorizontals
        $hMask = _WinAPI_CreateRectRgn(0, $i * $iStep, @DesktopWidth, ($i * $iStep) + 1)
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)

    ; Set overall region
    _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)


    While 1



EndFunc   ;==>Grid

Func On_Exit()



I hope that helps.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
Share on other sites

  • 1 year later...

Thank you for this, it's almost exactly what I was looking for. 5stars :)

I only have one question. What value(s) are changed to tighten up the grid, I need something just a tad smaller then 100. I know this is resurrection, but I don't see the point in making anew post if question(s) is/are still relevant.

NVM I got it, thanks. :)

BTW in case anyone is wondering the same, try adjusting the numbers in the GUICtrlCreateRadio.

Edited by uber125
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...