Code: Select all
#Persistent
#SingleInstance, Force
SetTitleMatchMode, 2
Global PotGuiHwnd
Global PotPlayerID
Global PotPlayerPID
Gui, Main: +HwndPotGuiHwnd -DPIScale
SetTimer, Main, 1
return
Main:
if WinExist("PotPlayer")
{
WinWait, PotPlayer
WinGet, CurrentPotPlayerID, ID, PotPlayer
WinGet, CurrentPotPlayerPID, PID, PotPlayer
;Hook
DllCall("SetWinEventHook"
, "UInt", 0x8004
, "UInt", 0x8004
, "Ptr" , 0x0
, "Ptr" , RegisterCallback("WinEventProc")
, "UInt", CurrentPotPlayerPID
, "UInt", 0x0
, "UInt", 0x0|0x2) ;_In_ UINT dwflags
;----
DllCall("SetParent", ptr, PotGuiHwnd, ptr, CurrentPotPlayerID)
Gui, Main: Show, w300 h40 x0 y0 NA
WinWaitClose, ahk_id %CurrentPotPlayerID%
DllCall("UnhookWinEvent", "Ptr",Hook)
}
Return
WinEventProc(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime) {
WinSet, Top, , ahk_id %PotGuiHwnd%
}
Basically trying to make a nested gui inside PotPlayer and having some issues!
1.The code above works fine but when the PotPlayer window is closed and runs again, something weird happens, the gui "bugs out" and i can't get it to show up.
I can work-around this with gui destroy and creating the gui in the "main" every time but that's my last resort and i'd rather not do that.
2.You see that winevent hook? i made it because the gui window would get "behind" the potplayer window when the potplayer window is resized and on a couple other occasions.
you can see what happens if you just delete WinSet, Top, , ahk_id %PotGuiHwnd% line from the wineventproc function. Any way to make the gui "always above" instead of constantly firing WinSet, Top, , ahk_id %PotGuiHwnd%?