Move a window with no title bar

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Meroveus
Posts: 44
Joined: 23 May 2016, 17:38

Move a window with no title bar

12 Oct 2018, 19:13

I want to create an on-screen "hud" display whose window is created with no title bar, and whose background is transparent
Here is the entire demo script I'm using to try this out:
(Example #6 from the help)

Code: Select all

CustomColor = EEAA99  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, Courier new s32  ; Set a large font size (32-point).
Gui, Add, Text, vMyText cLime, XXXXX YYYYY  ; XX & YY serve to auto-size the window.
; Make all pixels of this color transparent and make the text itself translucent (150):
WinSet, TransColor, %CustomColor% 150
SetTimer, UpdateOSD, 200
Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
Gui, Show, x0 y400 NoActivate  ; NoActivate avoids deactivating the currently active window.
return

UpdateOSD:
MouseGetPos, MouseX, MouseY
GuiControl,, MyText, X%MouseX%, Y%MouseY%
return
What must I do so that I can move the window by clicking anywere in the window, and dragging with the mouse?
I tried making the background opaque, but that doesn't work.
lexikos
Posts: 9589
Joined: 30 Sep 2013, 04:07
Contact:

Re: Move a window with no title bar

12 Oct 2018, 19:40

[How To] Enable Drag for a GUI without a Titlebar - Tutorials (archive forum)

If you want to detect clicks anywhere on the GUI (not just on the text control as in the tutorial), you can monitor the WM_LBUTTONDOWN message.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Move a window with no title bar

12 Oct 2018, 19:51

lexikos' links combine for this:

Code: Select all

CustomColor = EEAA99  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, Courier new s32  ; Set a large font size (32-point).
Gui, Add, Text, vMyText cLime, XXXXX YYYYY  ; XX & YY serve to auto-size the window.
; Make all pixels of this color transparent and make the text itself translucent (150):
WinSet, TransColor, %CustomColor% 150
SetTimer, UpdateOSD, 200
Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
Gui, Show, x0 y400 NoActivate  ; NoActivate avoids deactivating the currently active window.
OnMessage(0x201, "WM_LBUTTONDOWN")
return

WM_LBUTTONDOWN()
{
   PostMessage 0xA1, 2
}

UpdateOSD:
MouseGetPos, MouseX, MouseY
GuiControl,, MyText, X%MouseX%, Y%MouseY%
return
the problem is that you've made the GUI transparent so its hard to drag it, you have to click on exactly one of the letters

Meroveus
Posts: 44
Joined: 23 May 2016, 17:38

Re: Move a window with no title bar

12 Oct 2018, 22:33

Thanks -- that is quite slick.
My next task in this exercise is to make the window automatically resize as the length and number of rows of text change.
Is there a way to do this other than destroying the window and re-creating it?

Thanks!
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: Move a window with no title bar

13 Oct 2018, 13:11

automaticaly? Not that i know of

you know this:
Gui, Show, x0 y400 w300 h400 NoActivate ; put new sizes and positions whenever you want
lexikos
Posts: 9589
Joined: 30 Sep 2013, 04:07
Contact:

Re: Move a window with no title bar

13 Oct 2018, 16:02

The Text control won't be autosized, but you can change its size with GuiControl and then autosize the Gui (Gui, Show, AutoSize).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 302 guests