 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Serenity
Joined: 08 Nov 2004 Posts: 1010
|
Posted: Sat Feb 26, 2005 3:13 am Post subject: WinMinimize issues |
|
|
I'm not sure if this is really a bug with AutoHotkey which is why I'm posting this here.
I've noticed that if I run what is essentially the same script from the quicklaunch, WinMinimize behaves quite differently compared to being launched from one of the icons in the titlebarclock script.
| Code: | ; foobar2000 quicklaunch
#notrayicon
path = D:\foobar2000\foobar2000.exe
IfWinActive, ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}
WinMinimize
else
Run, %path% |
Creating a link to the script in the quicklaunch behaves like the taskbar buttons, if the window is active, it will be minimized, showing the window underneath it, otherwise it will run it, bringing it to the top. foobar2000 will only allow one instance to be running, which is why the run command reactivates the window in this example.
When using the scriptlet above within the titlebarclock script, WinMinimize appears to do nothing, so I tried substituting WinMinimize with:
| Code: | | PostMessage, 0x112, 0xF020,,, ahk_class {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8} |
and got the same results, the window does not minimize at all. I had this issue with Winamp as well. Apart from sending mouse clicks to the minimize button in the titlebar, are there any other methods I can try that behave like clicking on the taskbar/quicklaunch buttons to toggle the window view between minimized and active?
I've also noticed that if the window is active but not maximized, instead of minimizing the window, it reduces it to its custom size, whereas both taskbar and quicklaunch remember whether it was maximized or a custom size and restores it to this state and toggles between this and minimized. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Feb 27, 2005 11:52 pm Post subject: |
|
|
If you're saying that WinMinimize has no effect when the script that contains it was launched from the QuickLaunch bar, I can't explain that. Perhaps something to do with DetectHiddenWindows?
If you can produce this problem with some standard app such as notepad, I could try to fix it. However, since WinMinimize boils down to one line of code in the program, this might be difficult. |
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 1010
|
Posted: Mon Feb 28, 2005 12:30 am Post subject: |
|
|
I think the problem lies within the IfWinActive command. By using the g-label for the icon in the titlebarclock script, clicking on that icon executes the script below. However, clicking on the icon makes the titlebarclock the active window, therefore it cannot tell that notepad is active. Even though notepad may appear to be on top, it doesn't have mouse focus, the titlebarclock script has.
For use with the titlebarclock script, I need to work out how to detect what the last active window was before the titlebarclock script was made the active window, so that I can send it the minimize command, unless there is some way of preventing it from becoming the active window by clicking on one of its icons.
For the quicklaunch, this script works fine; I suspect this is because windows regards mouse focus on the taskbar area as seperate to windows even though it is itself a window class:
| Code: | #notrayicon
IfWinActive, ahk_class Notepad
WinMinimize
else
IfWinExist, ahk_class Notepad
WinActivate
return |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 1010
|
Posted: Mon Feb 28, 2005 4:08 am Post subject: |
|
|
Solved it!
Ok this gives taskbar-like toggle view functionality to a gui item with a g-label:
| Code: | app = foobar2000.exe
path = D:\foobar2000\foobar2000.exe
class = {E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8} ; case sensitive
togglewin:
; first check to see if process exist, if process doesn't exist then run app
Process, Exist, %app%
PID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
If PID = 0
{
run, %path%
return
}
else
; now we know clicking the item with g-label steals active window
; so we get class of active window..
WinGetClass, A_Class, A
; ..and now we need to check, if it isn't class of our app
If A_Class <> %class%
; if class isn't our app then check what state our app is in
; -1: The window is minimized (WinRestore can unminimize it).
; 1: The window is maximized (WinRestore can unmaximize it).
; 0: The window is neither minimized nor maximized.
; this should: if state minimized then activate else minimize
WinGet, State, MinMax, ahk_class %class%
If State = -1
WinActivate, ahk_class %class%
else
WinMinimize, ahk_class %class%
return |
_________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|