topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 5:26 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Dumdum - Aero Shake clone project in AHK (was : Minimizing all windows[...])  (Read 23030 times)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
(sorry if i'm posting this in the wrong section)

I'm working on a new ahk script and i'm pretty happy with what i've done so far. However, i'm facing a problem and as i didn't get much help from the autohotkey forum, i thought i'd ask my donationcoder buddies :)

Problem :

I'm trying to minimize all windows except the active one, using the following piece of code :
Winget, activeId, id, A
Winget, winlist, list
loop %winlist%
{
  winid := winlist%A_Index%
  Wingettitle, wintitle, ahk_id %winid%
 
  if (strlen(wintitle) != 0 and winid != activeId and wintitle != "Program Manager")
  {
    PostMessage, 0x112, 0xF020,,, ahk_id %winid%
  }
}

The problem with this method is that it works well with some windows (they stay visible while the other ones get minimized) but it doesn't work with others (ie Freecommander, Pspad), who get minimized anyway. I tried to modify the code to minimize the active window only, and it worked fine except with the program mentionned earlier.

Anyway, my goal is to minimize all windows except the active one, and i'm out of ideas. I tried to WinMinimizeAll and then to bring the active window back, but it makes the window disappear for a moment, plus WinMinimizeAll doesn't work for people using Emerge shell (like myself). Sending #d or #m doesn't work for the same reasons.

If anyone has any idea, i'd be really glad to hear it :)

Thanks.
« Last Edit: November 11, 2008, 05:21 PM by ak_ »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #1 on: November 09, 2008, 03:27 PM »
I'm not sure about this, but aren't you trying to reinvent skrommel's MinimOther? :)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #2 on: November 09, 2008, 03:29 PM »
jgpaiva> wow you're like the fastest poster ever :D Anyway, thanks for the info, i'll have a look at Skrommel's method. Actually, the minimizing thing is just a part of my script (i've done the first part already, more or less).

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #3 on: November 09, 2008, 03:32 PM »
Ah, false joy : i ran MinimOther and the same problem happens with the same windows...

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #4 on: November 09, 2008, 03:46 PM »
Strange.. After reading your code, I have no idea why it isn't working :(

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #5 on: November 09, 2008, 04:18 PM »
After checking the list of the windows retrieved by the WinGet command, i think the problem comes from the fact that WinGet detects child windows, or inner-windows or whatever it is. I found out that every program causing a problem appeared in the list twice, sometimes with two different titles.

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #6 on: November 10, 2008, 04:39 AM »
try this:
Code: Autohotkey [Select]
  1. Winget, activeId, id, A
  2. WinRestore, ahk_id %activeId%
Workaround by minimizing all windows then quickly restoring the last active one ;)

helpfile also says:
If a particular type of window does not respond correctly to WinRestore, try using the following instead:

PostMessage, 0x112, 0xF120,,, WinTitle, WinText  ; 0x112 = WM_SYSCOMMAND, 0xF120 = SC_RESTOREThis command operates only upon the topmost matching window except when WinTitle is ahk_group GroupName, in which case all windows in the group are affected.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.


ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #7 on: November 10, 2008, 06:25 AM »
Justice :

I tried to WinMinimizeAll and then to bring the active window back, but it makes the window disappear for a moment, plus WinMinimizeAll doesn't work for people using Emerge shell (like myself).
-ak_

:)

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #8 on: November 10, 2008, 08:21 AM »
I'm sorry :(
I don't know of another way of minimizing it, so I'd list all the windows first to make sure that the problematic ones are recognised and that the problem is in the minmizing itself. can't help you further than that i'm afraid.

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #9 on: November 10, 2008, 08:38 AM »
I already did :) But i have another idea, i'll try it later. Thanks for your help, both of you.

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #10 on: November 11, 2008, 04:18 PM »
Ok, i found the solution to my problem and thought it might be useful to others so here it is.

I noticed that the problematic programs used tabs (Freecommander does, PSPad too) and realized that ahk detected the active tab as a window. So, i took a look at those tabs' window style and noticed that they had this one in common : WS_POPUP - 0x80000000. I added a condition to exclude windows containing this particular style and the problem is now solved :)

Of course now i'm facing another problem but i'm glad to be moving forward :)

Now, let me tell you about this script i'm working on. Its temporary name is Dumdum (don't ask why, i have no idea) and its purpose is to mimic the Aero Shake feature of Windows 7. You can try it, but first you have to know that it is a very early version. Right now, if you shake a window, it will minimize all others, but if you shake it again they won't come back (it is, of course, in the todo list). Another problem : sometimes, you shake a window and after the other windows have been minimized, the active window is not "dragged" anymore and goes back to its original place. It's hard to explain but i think you'll figure it out if you try. I couldn't find the origin of this bug yet.

Here it is :

In the future, the user will be able to choose the "shaking sensitivity" and the windows behaviour (minimize other windows, minimize active window, close active window etc).
« Last Edit: November 14, 2008, 11:51 AM by ak_ »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
sounds weird but interesting. :)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Weird/stupid ? :D

Actually, i understand how this "Aero shake" feature might not seem very useful. Personally, i don't think i'm gonna be using it anytime soon. However, i thought the idea was fun and thought it might be an interesting ahk project. That's why i'd really appreciate if anyone took a few minutes to try it and tell me if it works fine or not :) Again, i understand if the program itself doesn't look appealing to you because it is not to me (but it is as a project).

Thanks :)

VideoInPicture

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 467
    • View Profile
    • Circle Dock
    • Donate to Member
Works on my computer. Windows Vista - 32 bit.
Author of Circle Dock: http://circledock.wikidot.com
Author of Video In Picture: http://videoinpicture.wikidot.com
Author of Webcam Signature: http://webcamsignature.wikidot.com
Author of Easy Unicode Paster: http://easyunicodepaster.wikidot.com

cyberkilla

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Hey, you've started now! Please finish!;)

You are the only person with a decent clone so far. If you could get the windows to come back, and only the ones minimised in the first place, it would be brilliant.

Still, I've used it. I'm still using it. I find it *highly* useful and intuitive. Whoever thought of this at Microsoft should be given given a raise.

Thanks for making it. I'm happy with it as it is, but if you did manage to get the windows to come back again, it would be the icing on the cake.

Note: Just make sure that you disregard any extra shakes until the window has been let go of.
What I mean is, before you check for a shake to 'reverse' the effects of the minimising shake, ensure that the window has stopped moving first.

The consequences of not doing this is simple - over-shaking will make windows come and go every now and then, which is what bothered me in another clone I found.

The argument I've heard is that it's just as easy to do WIN + M then reopen the window you closed.
My counter argument is simple: I've just pulled the window I want to the front of the visible stack. I'm already holding the damned thing's titlebar on most occasions. Why not shake it to clean up the mess?:)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Videoinpicture> thanks a lot for trying it :)

cyberkilla> i'm glad you posted this message, it motivates me to finish this thing :)

Since you're here, let me ask you a question : when the windows have been minimized, when should Dumdum "forget" about those windows ? I mean, if i shake a window, then restore a few by hand, close some others, work for 3 hours and then shake the same window again, i suppose it should minimize every other windows (instead of restoring the ones that have been minimized earlier). I hope i'm clear :)

cyberkilla

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Videoinpicture> thanks a lot for trying it :)

cyberkilla> i'm glad you posted this message, it motivates me to finish this thing :)

Since you're here, let me ask you a question : when the windows have been minimized, when should Dumdum "forget" about those windows ? I mean, if i shake a window, then restore a few by hand, close some others, work for 3 hours and then shake the same window again, i suppose it should minimize every other windows (instead of restoring the ones that have been minimized earlier). I hope i'm clear :)

I don't have a certain answer for that, but this is my understanding...

When you use the windows taskbar's Stack, Cascade or Side by Side feature, it will provide an Undo button until you change something.

So, in my opinion, your best plan is to remember *what* you minimized the last time, restoring it on the next shake if everything is in the same state as before.

To explain that a little better, I'll put it this way: If the same window is open, and all of the others are minimised and not closed, restore the windows.

This allows you to, for example, open your mail inbox, shake other windows away, open a composer window, send the message and return to your inbox.
Then, you can shake the window again to restore the old windows.
I'd even go as far to say that you can restore some of the other windows, use them and minimise them again.

As long as you shake the original window, with all of the originally minimised windows in the same state, restore them.

What do you think? If somebody opens extra windows and shakes one of them, he is more likely to be wanting THEM to be minimized, rather than restore the old ones to add to the mess.

That's my logic, and it is, as far as I know, the same behaviour of the other taskbar functions.

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
Yes, i agree with you.

cyberkilla

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Yes, i agree with you.

Well, good luck with your endeavour.

cyberkilla

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
How you doing?

Have you given up? Looks like a harder task that it appears? :Thmbsup:

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: Minimizing all windows except one in AHK - call for help
« Reply #20 on: November 21, 2008, 08:57 AM »
Right now, if you shake a window, it will minimize all others

Can you insert any code to stabilize me after a night of heavy drinking (that Horlicks is powerul stuff)?
I'm shaking so much here that, with your program running, my windows keep disappearing!

Seriously, thanks for documenting what you're up to. It's interesting to follow these kinds of adventures on DoCo.


ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Read more about this member.
    • Donate to Member
cyberkilla> actually, just when i thought the hardest part was done, i just found myself facing a stupid bug that drives me crazy. When i minimize all windows, i keep their "unique id number" in a variable so i can call them back later. The stupid thing is : some windows, when minimized, are not detected anymore, so calling their id number does nothing.

I actually ran into this problem with Pspad only, so i can still post the latest version here, it should work with most windows (if not all).

cranioscopical> i'll add a "hangover mode" to the todo list :D

cyberkilla

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
I can imagine which windows you mean.

I often have trouble with WinSCP. Something they do is obviously a bit strange, because the minimise animation of WinSCP is that of a window being closed, rather than minimised, but it's still on the taskbar!

It seems that they use Form.hide rather than a proper minimise.
Perhaps you describe something entirely different.