I have been trying to do this a long time ago.
Code: Select all
Window_Focuser:
IfWinNotActive, ahk_exe EVOLUTIO.exe
WinSet, AlwaysOnTop, Off, EVO_WIN
WinSet, Bottom,, EVO_WIN
else,
WinSet, AlwaysOnTop, On, EVO_WIN
return
Code: Select all
Window_Focuser:
IfWinNotActive, ahk_exe EVOLUTIO.exe
WinSet, AlwaysOnTop, Off, EVO_WIN
WinSet, Bottom,, EVO_WIN
else,
WinSet, AlwaysOnTop, On, EVO_WIN
return
what do you mean with caution? like be careful or is it another code?
By caution I mean that the gui will only exist in the client area of the parent so if you were to try to move the gui out of the way off the window it will be lost in limbo, also while playing around with this a while ago I found that position of the gui can cause it to not show up at all, there are a few other things that I saw as well but can't recall them all, testing will reveal if it is a good fit.
I have only ever played around with this so I don't know all the ins and outs, but are you minimizing the gui its self? Because I think that it should pop up the gui otherwise, like I said though, I've only played around with doing it and haven't used it in a project yet so there could be things that I'm out of the loop on. There are work around hacks if needed though.
Are you talking about doing that with the window as the parent of your gui?
I tried that and it didn't work. The GUI stays at the center of the screen and in the background like bottom of every other window. also looks like owner+ does not work because GUI does not respond to parent minimize or restore actions.
Code: Select all
#NoEnv
SetBatchLines, -1
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance, force
; builds menu
Menu, Tray, NoStandard
Menu, Tray, Icon, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\EVOLUTIO_0000.ico
Menu, Tray, Add, About, About_B
Menu, Tray, Add
Menu, Tray, Add, Reload_B
Menu, Tray, Add
Menu, Tray, Add, Exit, Exit_B
;default variables
EVOLUTIO_width := 1028 ; width of parent
EVOLUTIO_height := 794 ; height of parent
IfWinExist ahk_exe EVOLUTIO.exe
SetTimer, ExitAppIfEVOLUTIOisOff, 150 ; exits app if parent window does not exist
SetTimer, FocusListadeClientes, 150 ; this is something that has nothing to do with the problem please omit
SetTimer, Window_coordChecker, 500 ; this checks parent coords and other stuff.
SetTimer, Window_coordSnapper, 150 ;this checks and compares old parent coords with new parent codes, if they aren't equal, it moves the gui.
gosub, Initiate_Gui
return
Window_coordChecker:
WinGetPos, xpos, ypos,xw,yw,ahk_exe EVOLUTIO.exe
old_xpos := xpos
old_ypos := ypos
old_xw := xw
old_yw := yw
return
Window_coordSnapper:
WinGetPos, xpos, ypos,xw,yw,ahk_exe EVOLUTIO.exe
If (xw != EVOLUTIO_width) & (yw != EVOLUTIO_height)
{
return ; stop condition
}
else if (old_xpos != xpos) || (old_ypos != ypos)
{
;~ ToolTip, %xw% and %yw%
moveX := xpos+1030
moveY := ypos+0
WinMove, EVO_WIN,,%moveX%,%moveY%
;~ ToolTip
} return
ExitAppIfEVOLUTIOisOff:
IfWinNotExist ahk_exe EVOLUTIO.exe
ExitApp
return
FocusListadeClientes:
IfWinActive, Lista de clientes
{
Send, {Tab}
WinWaitClose, Lista de clientes
} else{
return
} return
Initiate_Gui:
Gui, 1: margin, 5,5
Gui, 1: +ToolWindow -Caption ;-SysMenu
Gui, 1: font, cblack s13 bold
Gui, 1: Color, silver ;1A6DAE
Gui, 1: Add, Picture, y+10 w50 h-1 gAYUDA, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\Seller.png
Gui, 1: Add, DropDownList, y+1 w60 vSellerChoice Choose1, 1|11|12|13|2|22|23|33
Gui, 1: Add, Picture, y+10 w50 h-1 gDESCUENTO, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\discount.png
Gui, 1: Add, DropDownList, y+1 w60 vDiscountChoice Choose2, 10|20|25|other
Gui, 1: Add, Picture, y+10 w50 h-1 gFACTURAR, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\print.png
Gui, 1: +Owner EVOLUTIO.exe
Gui, 1: Show, NoActivate AutoSize, EVO_WIN
return
fenchai wrote: ↑21 Jan 2019, 11:53I tried that and it didn't work. The GUI stays at the center of the screen and in the background like bottom of every other window. also looks like owner+ does not work because GUI does not respond to parent minimize or restore actions.
The code below works well but has some problems...
- GUI getting covered by other windows even when parent is active window.
- When reactivating the Parent Window GUI will not show because of the problem above.
- Looks like GUI is not able to be an active window unless activated. This is what is causing the above problems
Apart from that everything works!
- Looks like Right-Clicking the GUI script Tray makes the GUI Activate to solve above problem
The rest of the script are labels so nothing important.Code: Select all
#NoEnv SetBatchLines, -1 SendMode Input SetWorkingDir %A_ScriptDir% #SingleInstance, force ; builds menu Menu, Tray, NoStandard Menu, Tray, Icon, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\EVOLUTIO_0000.ico Menu, Tray, Add, About, About_B Menu, Tray, Add Menu, Tray, Add, Reload_B Menu, Tray, Add Menu, Tray, Add, Exit, Exit_B ;default variables EVOLUTIO_width := 1028 ; width of parent EVOLUTIO_height := 794 ; height of parent IfWinExist ahk_exe EVOLUTIO.exe SetTimer, ExitAppIfEVOLUTIOisOff, 150 ; exits app if parent window does not exist SetTimer, FocusListadeClientes, 150 ; this is something that has nothing to do with the problem please omit SetTimer, Window_coordChecker, 500 ; this checks parent coords and other stuff. SetTimer, Window_coordSnapper, 150 ;this checks and compares old parent coords with new parent codes, if they aren't equal, it moves the gui. gosub, Initiate_Gui return Window_coordChecker: WinGetPos, xpos, ypos,xw,yw,ahk_exe EVOLUTIO.exe old_xpos := xpos old_ypos := ypos old_xw := xw old_yw := yw return Window_coordSnapper: WinGetPos, xpos, ypos,xw,yw,ahk_exe EVOLUTIO.exe If (xw != EVOLUTIO_width) & (yw != EVOLUTIO_height) { return ; stop condition } else if (old_xpos != xpos) || (old_ypos != ypos) { ;~ ToolTip, %xw% and %yw% moveX := xpos+1030 moveY := ypos+0 WinMove, EVO_WIN,,%moveX%,%moveY% ;~ ToolTip } return ExitAppIfEVOLUTIOisOff: IfWinNotExist ahk_exe EVOLUTIO.exe ExitApp return FocusListadeClientes: IfWinActive, Lista de clientes { Send, {Tab} WinWaitClose, Lista de clientes } else{ return } return Initiate_Gui: Gui, 1: margin, 5,5 Gui, 1: +ToolWindow -Caption ;-SysMenu Gui, 1: font, cblack s13 bold Gui, 1: Color, silver ;1A6DAE Gui, 1: Add, Picture, y+10 w50 h-1 gAYUDA, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\Seller.png Gui, 1: Add, DropDownList, y+1 w60 vSellerChoice Choose1, 1|11|12|13|2|22|23|33 Gui, 1: Add, Picture, y+10 w50 h-1 gDESCUENTO, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\discount.png Gui, 1: Add, DropDownList, y+1 w60 vDiscountChoice Choose2, 10|20|25|other Gui, 1: Add, Picture, y+10 w50 h-1 gFACTURAR, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\print.png Gui, 1: +Owner EVOLUTIO.exe Gui, 1: Show, NoActivate AutoSize, EVO_WIN return
Code: Select all
Gui, 1: +Owner EVOLUTIO.exe
Code: Select all
The_Hwnd := WinActive() ; you need to fill in the windows title or some other related info. See link below
Code: Select all
Gui, 1: +Owner%The_Hwnd%
Code: Select all
#SingleInstance, force
The_Hwnd := WinActive("ahk_class Notepad")
Gui, 1: margin, 5,5
;~ Gui, 1: +ToolWindow -Caption ;-SysMenu
Gui, 1: font, cblack s13 bold
Gui, 1: Color, silver ;1A6DAE
Gui, 1: Add, Picture, y+10 w50 h-1 gnull, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\Seller.png
Gui, 1: Add, DropDownList, y+1 w60 vSellerChoice Choose1, 1|11|12|13|2|22|23|33
Gui, 1: Add, Picture, y+10 w50 h-1 gnull, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\discount.png
Gui, 1: Add, DropDownList, y+1 w60 vDiscountChoice Choose2, 10|20|25|other
Gui, 1: Add, Picture, y+10 w50 h-1 gnull, C:\Users\%A_UserName%\Google Drive\AHK\R-EVOLUTIO\print.png
Gui, 1: +Owner%The_Hwnd%
Gui, 1: Show, NoActivate AutoSize, EVO_WIN
return
null:
return
Code: Select all
#SingleInstance, Force
IfWinNotExist, ahk_class Notepad
{
msgbox, The window doesn't exist`nThe script will now exit
ExitApp
}
WinGet, The_Hwnd , ID, ahk_class Notepad
Gui,1: +Owner%The_Hwnd%
Gui,1:Show,w300 h100, test
return
GuiClose:
ExitApp
Wow that worked, the GUI now pops when Parent window is on and also stays on top of the parent window. that's great! this solved my issue with my older script!Hellbent wrote: ↑21 Jan 2019, 22:42Here this should fix it.
Code: Select all
#SingleInstance, Force IfWinNotExist, ahk_class Notepad { msgbox, The window doesn't exist`nThe script will now exit ExitApp } WinGet, The_Hwnd , ID, ahk_class Notepad Gui,1: +Owner%The_Hwnd% Gui,1:Show,w300 h100, test return GuiClose: ExitApp
I said parentfenchai wrote: ↑21 Jan 2019, 22:54
But I don't understand why you say that with this +owner, I don't need to make the GUI move in a loop. I mean this +Owner setting only works for copying minimize and restore from Parent window right? since the GUI stays in the center and does not move when the parent is moving.
Code: Select all
#SingleInstance, Force
WinGet, TargetHwnd , ID , ahk_class SciTEWindow
Gui, 1: +HwndGuiHwnd
Gui, 1: Color, 222222
DllCall( "SetParent" , "uint" , GuiHwnd , "uint" , TargetHwnd )
Gui,1:Show, w300 h100, test
return
GuiClose:
*^ESC::
ExitApp
uint means unsigned integer, something that you don't normally have to worry about when using ahk.