Including a Gui directly into a window?
Posted: 05 Feb 2018, 11:13
Hi,
Is it possible to add Gui elements to a specific window like in this example?
I'm not sure, but I think these points would be mandatory:
- #if WinActive("ahk_class Notepad") (will only work for Notepad in this case)
- Get the current window's x and y pos
- Gui, -Caption (no border)
- Gui, Add, Text, BackgroundTrans (text won't cover the background)
- the gui elements' positions would have to be relative to X0Y0 of the specific window.
I tried it with this code, but it doesn't work.
Even though the MessageBox shows the correct values, the gui has a problem with the gx and gy.
Thanks for any help!
Is it possible to add Gui elements to a specific window like in this example?
I'm not sure, but I think these points would be mandatory:
- #if WinActive("ahk_class Notepad") (will only work for Notepad in this case)
- Get the current window's x and y pos
- Gui, -Caption (no border)
- Gui, Add, Text, BackgroundTrans (text won't cover the background)
- the gui elements' positions would have to be relative to X0Y0 of the specific window.
I tried it with this code, but it doesn't work.
Even though the MessageBox shows the correct values, the gui has a problem with the gx and gy.
Code: Select all
^F2::
#if WinActive("ahk_class Notepad")
WinGetPos, x, y, Width, Height, Unbenannt - Editor
Sleep, 5
gx := x + 20
gy := y + 20
Gui, -Caption
Gui, +AlwaysOnTop
Gui, Show, %gx% %gy% w100 h10
Gui, Add, Text, BackgroundTrans x0 y0, Test
;MsgBox, %x%, %y%, %gx%, %gy%
return