How to hide or remove Windows title bar

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mhcha
Junior Coder
Posts: 33
Joined: Sat Jan 01, 2022 11:10 am

How to hide or remove Windows title bar

Post by mhcha » Thu Jun 20, 2024 2:27 pm

Hello,

I'm trying to hide or remove the title bar of a particular window using the SetWindowLongA function of User32.dll.

I tried the code below, but it failed.

LibFunc>User32,SetWindowLongA,r,%nHandle%,-16,0

Pages referenced:
https://learn.microsoft.com/ko-kr/windo ... indowlonga
viewtopic.php?t=1759

If there is any other way, I would appreciate it if you could let me know.

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: How to hide or remove Windows title bar

Post by Grovkillen » Thu Jun 20, 2024 3:51 pm

Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: How to hide or remove Windows title bar

Post by JRL » Thu Jun 20, 2024 8:22 pm

This technique changes the title of a window. Removing it would simply be make the title blank.

After reading Grovkillen's response I'm not sure whether you want to rename a window, remove it from the taskbar or remove the titlebar from the window.

If you want to remove the titlebar, things get a little more complex. This modified from Marcus here
Open Notepad then run the following. Should work similarly with most windows. Be aware that with the title bar gone you may find it tedious to close the window. Notepad can be closed by selecting the window and then pressing Alt + F4

Code: Select all

GetWindowHandle>Notepad*,wndhndl

Let>WS_CAPTION=12582912
Let>WS_MINIMIZEBOX=131072
Let>WS_MAXIMIZEBOX=65536
Let>WS_SYSMENU=524288
Let>WS_THICKFRAME=262144
Let>WS_POPUP=2147483648
Let>WS_CHILD=1073741824
Let>WS_VISIBLE=268435456
Let>WS_BORDER=8388608
//get current style
LibFunc>user32,GetWindowLongA,style,wndhndl,-16
//modify style to remove borders and size frame
Let>style={(%style% And Not %WS_CAPTION%)}
Let>style={(%style% And Not %WS_THICKFRAME%)}
LibFunc>user32,SetWindowLongA,sres,wndhndl,-16,style
//refresh - we have to tell it the frame changed
Let>SWP_FRAMECHANGED=32
Let>SWP_NOMOVE=2
Let>SWP_NOZORDER=4
Let>SWP_NOSIZE=1
Let>flags={(%SWP_FRAMECHANGED% OR %SWP_NOMOVE% OR %SWP_NOZORDER% OR %SWP_NOSIZE%)}
LibFunc>user32,SetWindowPosA,r,wndhndl,0,0,0,0,0,flags

mhcha
Junior Coder
Posts: 33
Joined: Sat Jan 01, 2022 11:10 am

Re: How to hide or remove Windows title bar

Post by mhcha » Fri Jun 21, 2024 1:14 am

JRL wrote:
Thu Jun 20, 2024 8:22 pm
This technique changes the title of a window. Removing it would simply be make the title blank.

After reading Grovkillen's response I'm not sure whether you want to rename a window, remove it from the taskbar or remove the titlebar from the window.

If you want to remove the titlebar, things get a little more complex. This modified from Marcus here
Open Notepad then run the following. Should work similarly with most windows. Be aware that with the title bar gone you may find it tedious to close the window. Notepad can be closed by selecting the window and then pressing Alt + F4

Code: Select all

GetWindowHandle>Notepad*,wndhndl

Let>WS_CAPTION=12582912
Let>WS_MINIMIZEBOX=131072
Let>WS_MAXIMIZEBOX=65536
Let>WS_SYSMENU=524288
Let>WS_THICKFRAME=262144
Let>WS_POPUP=2147483648
Let>WS_CHILD=1073741824
Let>WS_VISIBLE=268435456
Let>WS_BORDER=8388608
//get current style
LibFunc>user32,GetWindowLongA,style,wndhndl,-16
//modify style to remove borders and size frame
Let>style={(%style% And Not %WS_CAPTION%)}
Let>style={(%style% And Not %WS_THICKFRAME%)}
LibFunc>user32,SetWindowLongA,sres,wndhndl,-16,style
//refresh - we have to tell it the frame changed
Let>SWP_FRAMECHANGED=32
Let>SWP_NOMOVE=2
Let>SWP_NOZORDER=4
Let>SWP_NOSIZE=1
Let>flags={(%SWP_FRAMECHANGED% OR %SWP_NOMOVE% OR %SWP_NOZORDER% OR %SWP_NOSIZE%)}
LibFunc>user32,SetWindowPosA,r,wndhndl,0,0,0,0,0,flags
모두 도움을 주셔서 감사합니다.

JRL이 알려준 코드가 제게 맞는 것 같습니다만 아쉽게도 제가 하려고하는 크롬 창에는 적용되지 않는 것 같습니다.

작동하는 윈도우와 불가능한 윈도우가 있는것 같아요.

저는 윈도우11을 사용하고 있습니다.
크롬의 타이틀바를 제거하여 내용을 다이얼로그 패널 크기에 맞추려는 작업을 시도하고 있었습니다.

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: How to hide or remove Windows title bar

Post by Grovkillen » Fri Jun 21, 2024 6:59 pm

Ah, JRL's answer makes me revaluate my answer. You're asking to remove the title bar of the individual window, my answer is regarding the Taskbar.
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: How to hide or remove Windows title bar

Post by JRL » Tue Jun 25, 2024 6:22 pm

Perhaps SetParent would do what you want. See Marcus' example here. The sample uses Internet Explorer, you will want to use a different browser of your choice. The reason I think SetParent might help is that the browser window can be positioned in the dialog such that the upper portion of the browser window will be hidden. No way a user can move the browser within the dialog.

When the dialog is closed the Browser window closes as does the browser application.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts