This is an example with notepad, but i want to use it with Mp3tag which only has ahk_exe to work with.
What i want to do is:
1 Script stays at tray hidden when no notepad exist
2 Script shows up and stays at top of notepad (and all windows) when notepad starts and working with it
3 When i select the script window, it stays at top of notepad (and all windows) when notepad is already showing up and running
4 Script hides to tray when notepad losses focus or it is minimized
5 Script shows up and stays at top of notepad (and all windows) when notepad is refocused or maximized from taskbar
6 Script stays at tray hidden when i exit notepad
And all starts from the beginning...
The script works fine except from number 3 which makes the script and notepad flicker back and forth.
I can't find the solution myself, so if anyone can help i will by thankful.
Here is the script named as (newtest.ahk) that i have so far:
Code: Select all
#SingleInstance, Force
#NoEnv
SetWorkingDir %A_ScriptDir%
Gui +Resize +AlwaysOnTop +Owner
Gui, Show, W300 H500, newtest
Loop
{
IfWinExist, ahk_exe Notepad.exe
{
ifWinActive, ahk_exe Notepad.exe
{
IfWinExist, ahk_exe newtest.ahk
{
Gui, show
}
Else
{
Gui, Restore
}
}
Else
{
ifWinNotActive, ahk_exe Notepad.exe
Gui, Hide
}
}
else
{
Gui, Hide
}
}
return
GuiClose:
ExitApp