AutoHotkey Community

It is currently May 26th, 2012, 10:18 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 24th, 2009, 4:06 am 
Offline

Joined: October 24th, 2009, 3:58 am
Posts: 4
So, a quick intro here: I'm eX.A.K.R., but you may also call me Alex if you wish.

Here's my problem: I have been trying to create a script for my Samurize config to minimise all but the active window. I had tried using VBScript in Windows Vista, but even with JSSys3.dll I couldn't get it to work. I then discovered AutoHotkey through the AeroShake script that was posted on LifeHacker, and decided that it had similar functionality as to what I need here. Trouble is, I have no idea how to port over the code in the AeroShake script to my own so that I can get it to run when I run the script "on demand" (i.e. when I run the script through my Samurize config). I do wonder if this is possible, and if not, if I can somehow elegantly duplicate this functionality.

Thanks for any help here.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 5:14 am 
Offline

Joined: May 22nd, 2007, 1:06 am
Posts: 73
Perhaps a little backwards, but works, and is quick

Code:
F1::
WinGetActiveTitle, current
WinMinimizeAll
WinActivate, %current%


F1 to activate


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 7:35 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Here is a script that does it non-backwards :wink:
Code:
F1::    ; hotkey is F1

WinGetActiveTitle, OutputVar

;modified from Winget Example #2: This will visit all windows on the entire system and display info about each of them:

WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    WinGetTitle, this_title, ahk_id %this_id%

    if (OutputVar = this_title)
    {
;   msgbox Active Window is %this_title%
    }
    else
    {
   winminimize %this_title%
    }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 7:43 am 
Offline

Joined: October 24th, 2009, 3:58 am
Posts: 4
Leef_me wrote:
Here is a script that does it non-backwards :wink:
Code:
F1::    ; hotkey is F1

WinGetActiveTitle, OutputVar

;modified from Winget Example #2: This will visit all windows on the entire system and display info about each of them:

WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    WinGetTitle, this_title, ahk_id %this_id%

    if (OutputVar = this_title)
    {
;   msgbox Active Window is %this_title%
    }
    else
    {
   winminimize %this_title%
    }
}


I was about to say the previous one was not very elegant in doing it backwards, when you showed up. Thanks! :D

By the way, what is the syntax for assigning a function to the Window + Home key combination (I do know the Window key is represented by "#")? Windows 7 has this shortcut key that does something similar, and I want to duplicate it on my Vista machine for now until I upgrade to 7.

Edit: the code doesn't seem to play nice with Samurize here. Any help for that?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:20 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Quote:
Edit: the code doesn't seem to play nice with Samurize here. Any help for that?
Sorry, can't offer any suggestions.

But since AutoHotkey comes alphabetically before Samurize, isn't it therefore better than Samurize? :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:37 am 
Offline

Joined: October 24th, 2009, 3:58 am
Posts: 4
Leef_me wrote:
Quote:
Edit: the code doesn't seem to play nice with Samurize here. Any help for that?
Sorry, can't offer any suggestions.

But since AutoHotkey comes alphabetically before Samurize, isn't it therefore better than Samurize? :wink:


Heh :lol: .

Actually, what I'm trying to do here is to create a Samurize config that can interface with and minimise and restore all windows or just the inactive ones through a point-and-click interface (I flip between both the keyboard and mouse frequently, so it's best that I can configure both functions to be accessible through the keyboard and mouse).

In any case, is it actually possible to create a AutoHotkey script that runs itself?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 7:29 am 
Offline

Joined: October 24th, 2009, 3:58 am
Posts: 4
I decided to start thinking about this on my own and came up with some pseudocode:

Code:
; pseudocode for minorbutactivewindow script, accessible from an eg. Samurize config
Persistent

Run MinAllButActive

Function MinAllButActive
Activate TopMostWindow   ; Assume top-most window as last active window

Count UnMinimisedWindows
If UnMinimisedWindows > 1
   Enumerate ListOfUnMinimisedWindows
   Loop ListOfUnMinimisedWindows
      If Window on ListOfUnMinimisedWindows != ActiveWindow
         Minimise
         ListOfWindowsToRestore = ListOfUnMinimisedWindows
      End If
   Next
   Exit Function   ; Exit funtion once it exits from the loop
ElseIf UnMinimisedWindows = 1   ; Function used before, restore windows from saved list
   If ListOfWindowsToRestore > 0   ; Check if there's a list of windows to be restored
      Loop ListOfWindowsToRestore
         Restore
      Next
   Elseif ListOfWindowsToRestore = 0   ; No windows to restore
      Exit Function
   End if
   ListOfWindowsToRestore = 0
   Exit Function
ElseIf UnMinimisedWindows < 1       ; No windows
   ListOfWindowsToRestore = 0   ; User may have minimised or restored windows on his/her own, reset the script
   Exit Function
End If


As I am not well-versed in AutoHotkey scripting language at all though, I have no knowledge of porting this over to actual working code. Could someone look into my pseudocode above and see if it can be turned into real working code? Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, Cristi®, JSLover, Leef_me, patgenn123, rbrtryn, XstatyK and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group