Here is a function to make a gui window belong to another program's window (it will then get minimized/moved along with the other parent window without needing to use a timer). Some program's don't work well with this method, like notepad and calculator, you also can't position the gui on the titlebar.
(The original code came from Laszlo's taskbar clock).
You can either use the title of a program's window to identify the parent or if you use the function I commented out below instead, then you can use the class's name.
Code:
; e.g. run an internet explorer window and go to the page: "about:blank" so that is the start of the title text
; then run this script and it adds a gui window onto the internet explorer window.
; Some programs, such as notepad and calculator, don't seem to work properly with this technique.
Gui, 7: Margin, 0, 0
Gui, 7: +ToolWindow ; -Caption ; no title, no taskbar icon
Gui, 7: Add, Text,, This gui is stuck to the parent... `nbut I haven't programmed it to do anything `;-)
Set_Parent_by_title("about:blank", 7) ; can be done before or after showing the gui
Gui, 7: Show, x200 y200
Return
/*
or to use the window id of the parent instead of the title:
Set_Parent_by_id(Window_ID, Gui_Number) ; title text is the start of the title of the window, gui number is e.g. 99
{
Gui, %Gui_Number%: +LastFound
Return DllCall("SetParent", "uint", WinExist(), "uint", Window_ID) ; success = handle to previous parent, failure =null
}
*/
Set_Parent_by_title(Window_Title_Text, Gui_Number) ; title text is the start of the title of the window, gui number is e.g. 99
{
WinGetTitle, Window_Title_Text_Complete, %Window_Title_Text%
Parent_Handle := DllCall( "FindWindowEx", "uint",0, "uint",0, "uint",0, "str", Window_Title_Text_Complete)
Gui, %Gui_Number%: +LastFound
Return DllCall( "SetParent", "uint", WinExist(), "uint", Parent_Handle ) ; success = handle to previous parent, failure =null
}
/*
or to use the class instead of the title:
Set_Parent_by_class(Window_Class, Gui_Number) ; class e.g. Shell_TrayWnd, gui number is e.g. 99
{
Parent_Handle := DllCall( "FindWindowEx", "uint",0, "uint",0, "str", Window_Class, "uint",0)
Gui, %Gui_Number%: +LastFound
Return DllCall( "SetParent", "uint", WinExist(), "uint", Parent_Handle ) ; success = handle to previous parent, failure =null
}
*/