Jump to content

Hide titlebar and menubar of an application window (like Notepad)

Go to solution Solved by AlessandroAvolio,

Recommended Posts

Is there existing code that can hide the titlebar and menubar of a running application (like Notepad)?

I've searched for an answer to this and see that the answer will make use of _WinAPI_SetWindowLog and $GWL_Style, but I haven't been to figure out the correct syntax. 

I'll be grateful for any examples or instruction

Link to comment
Share on other sites

  • Solution

Hello, this could help you.

#include <GuiConstants.au3>
#include <WinAPISysWin.au3>
#include <GuiMenu.au3>


Func Main()

    Local $hWnd, $iStyle, $hMenu, $aWinPos

    $hWnd = WinWait("[Class:Notepad]", "")

    ;~ Retrieves the handle of the menu assigned to the given window
    $hMenu = _GUICtrlMenu_GetMenu($hWnd)

    ;~ Deletes menu items from the specified menu
    For $i = _GUICtrlMenu_GetItemCount ($hMenu) - 1 To 0 Step -1
        _GUICtrlMenu_RemoveMenu($hMenu, $i)

    ;~ Retrieves style about the specified window
    $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)

    ;~ Remove title bar
    $iStyle = BitXOR($iStyle, $WS_POPUPWINDOW)
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle)

    ;~ Refresh window style
    $aWinPos = WinGetPos($hWnd)
    WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] + 1)

    Return 0



Edited by AlessandroAvolio
Link to comment
Share on other sites

That is perfect, thank you!

I've also been trying it with the DOSBox-X emulator, which seems to rebuild its window when it opens. I've got it working by waiting for the window to appear the first time, then waiting for a second, and then getting the handle of the window by title, after it's been rebuilt. It works perfectly. Thank you again!

Edited by emendelson
Found the answer
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...