AutoHotkey Community

It is currently May 27th, 2012, 11:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 9th, 2004, 12:56 am 
My wish list items:

- An option to Group(De)activate to activate the previous window in a group, instead of the next.

- Command(s) to activate the next/previous window in taskbar order.


Andras


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 1:15 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
Group(De)activate to activate the previous window in a group, instead of the next.

That seems like a good option, thanks for suggesting it.

Quote:
Command(s) to activate the next/previous window in taskbar order.

Use Win+Tab and Shift+Win+Tab to do that. After a button on the task bar is selected, press Spacebar to activate that window.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 5:22 pm 
Online

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
this reminds me of ahk_group

remember Chris? u liked the idea.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 5:33 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Yes, that's on the list (maybe not as a published item, but high priority). It's a great example of your often-brilliant suggestions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 8:37 pm 
Chris wrote:
Quote:
Command(s) to activate the next/previous window in taskbar order.

Use Win+Tab and Shift+Win+Tab to do that. After a button on the task bar is selected, press Spacebar to activate that window.


I'm afraid that's not what I was looking for. I'd like to switch to and activate the next/prev window with a single keystroke. (Just like alt+[shift]+esc does, but in taskbar order.) If I create a hotkey to do both, by sending win+[shift]+tab and then space, weird things happen; it seems that cycling not always starts from the currently active window. (It's not an AHK issue, the same weirdness is present if I use win+tab and then space manually.)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 9th, 2004, 8:52 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Unfortunately, I don't know any other way to find out the order of windows represented in the task bar. One thing that might help is to make a Window Group to which you add various ahk_class entries. Then you can use GroupActivate to retrieve windows sorted by class. This is somewhat similar to task bar ordering when you have the bar set to display one button per application type.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2008, 3:41 am 
If I want to use a gamepad Axis for scrolling through the windows in the task bar would it look something like this? :
Code:

GetKeyState, joyx, %JoystickNumber%Joyx

if joyx > %JoyThresholdUpper%
{
    send {#}{Tab}{Space}                           
}
else if joyx < %JoyThresholdLower%
{
    send {Shift}{#}{Tab}{Space}
}
else
    DeltaX = 0 ;
return


It's not working correctly, could someone help? I'm trying to go by what was recommended previously in this thread (Win+Tab+Space) to activate the windows in the task bar. thx.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2008, 6:38 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
The following sends the individual keystrokes: Shift, Hash, Tab, Space.
Code:
send {Shift}{#}{Tab}{Space}

Modifiers should be prepended to the {keyname}, and not surrounded by braces.
Code:
Send +#{Tab}{Space}

Then there is another issue: #{Tab} always begins at the second task button. I use the following function to switch tasks:
Code:
;~ Example code
Loop 2 {
    TaskSwitchDelta(-1)
    Sleep, 1000
}
Loop 2 {
    TaskSwitchDelta(+1)
    Sleep, 1000
}
;~ End example code

TaskSwitchDelta(delta, wrap=true)
{
    delta := round(delta)
    if !delta
        return
   
    idxTB := GetTaskSwBar()
    ControlGet, hwndTB, Hwnd,, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd

    if !WinExist("ahk_id " hwndTB)
        return
   
    WinGet, pidTaskbar, PID
   
    hProc := DllCall("OpenProcess", "uint", 0x38, "int", 0, "uint", pidTaskbar)
    pRB := DllCall("VirtualAllocEx", "uint", hProc, "uint", 0, "uint", 20, "uint", 0x1000, "uint", 0x4)
   
    VarSetCapacity(btn, 20)
   
    SendMessage, 0x418  ; TB_BUTTONCOUNT
    count := ErrorLevel
   
    Loop, %count%
    {
        SendMessage, 0x417, A_Index - 1, pRB  ; TB_GETBUTTON
       
        DllCall("ReadProcessMemory", "uint", hProc, "uint", pRB, "uint", &btn, "uint", 20, "uint", 0)
        DllCall("ReadProcessMemory", "uint", hProc, "uint", NumGet(btn, 12), "uint*", hwnd, "uint", 4, "uint", 0)
        btn%A_Index%_hwnd  := hwnd
        btn%A_Index%_idn   := NumGet(btn, 4, "int")
        btn%A_Index%_state := NumGet(btn, 8, "UChar")
    }

    ; Find the active window's button.
    Loop, %count%
        if ((hwnd := btn%A_Index%_hwnd) && WinActive("ahk_id " hwnd))
        {
            i := A_Index
            break
        }
    ; If the active window has no directly associated button,
    ; use the first or last button which appears to be active.
    if (!i)
    {
        i = 1
        Loop, %count%
        {
            if (btn%A_Index%_state & 1) ; TBSTATE_CHECKED
            {
                i := A_Index
                if (delta<0)
                    break
            }
        }
    }

    dir := (delta<0) ? -1 : +1
   
    ; In the unlikely event that no buttons have an associated hwnd,
    Loop % (count>abs(delta) ? count : abs(delta)) ; this prevents infinite loop.
    {
        if (Abs(delta)<1)
            break
       
        i += dir
       
        if (i<1 or i>count) {
            i := (i<1 = wrap) ? count : 1
            if !wrap
                break
        }
       
        if (btn%i%_hwnd)
            delta -= dir
    }

    if !(btn%i%_state & 8)  ; ! TBSTATE_HIDDEN (if hidden, can't be clicked)
    {
        SendMessage, 0x433, % btn%i%_idn, pRB,, ahk_id %hwndTB%  ; TB_GETRECT
        got_rect := ErrorLevel && ErrorLevel != "FAIL"
        if got_rect
            DllCall("ReadProcessMemory", "uint", hProc, "uint", pRB, "uint", &btn, "uint", 16, "uint", 0)
    }
   
    DllCall("VirtualFreeEx", "uint", hProc, "uint", pRB, "uint", 0, "uint", 0x8000)
    DllCall("CloseHandle", "uint", hProc)
   
    ; Clicking the button is generally more reliable, but is not possible for
    ; hidden buttons (i.e. buttons which have been grouped.)
    ; WinActivate often causes flashing button syndrome.
    if (got_rect)
    {
        ControlClick, % "x" NumGet(btn,0,"int") " y" NumGet(btn,4,"int"), ahk_id %hwndTB%
    }
    else
    {
        WinActivate, % "ahk_id " btn%i%_hwnd

        ; Cure flashing button syndrome.       
        Loop, %count%
        {
            if (hwnd := btn%A_Index%_hwnd)
            {   ; Stop flashing any flashing windows/buttons.
                VarSetCapacity(fwi, 20, 0)
                NumPut(20, fwi, 0)
                NumPut(hwnd, fwi, 4)
                DllCall("FlashWindowEx", "uint", &fwi)
            }
        }
    }
}

GetTaskSwBar()
{
   WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
   RegExMatch(ControlList, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", nTB)

   Loop, %nTB%
   {
      ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
      hParent := DllCall("GetParent", "uint", hWnd)
      WinGetClass, sClass, ahk_id %hParent%
      If (sClass <> "MSTaskSwWClass")
         Continue
      idxTB := A_Index
         Break
   }

   Return idxTB
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: oops
PostPosted: May 30th, 2008, 2:20 am 
Sorry, I meant to put in {Rwin} or {Lwin} instead of the "#" sign in my post. I'll look into your code.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2008, 3:23 am 
Don't really know how to incorporate that function into my IF statement. How would I combine that function with movements of my JoyX? I'm trying to get to this:

Hit my JoyX to the right to activate the first window in task bar.
Hit my JoyX to the right again to activate the next window to the right of the first one.
.....3rd, 4th, and so on.

Hit my JoyX to the left to go back and activate the first window to the left of last active window

Is that what the function essentially does, but with the movement of the mouse wheel?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2008, 8:51 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Anonymous wrote:
Is that what the function essentially does, but with the movement of the mouse wheel?
TaskSwitchDelta does nothing more than switch tasks based on their buttons in the taskbar. It has nothing to do with the mouse wheel. Call it when you want to switch tasks...
Quote:
Sorry, I meant to put in {Rwin} or {Lwin} instead of the "#" sign in my post. I'll look into your code.

Sending {Shift}{Lwin}{Tab}{Space} would press Shift, release Shift, press LWin, release LWin, and so on. To hold Shift and Lwin then press Tab, you need to use the + and # modifiers as I demonstrated, or explicitly send {Shift Down}, {Shift Up}, etc.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: got it working
PostPosted: May 30th, 2008, 6:19 pm 
Thanks Lexikos, that function does do exactly what I was looking for!

I ended up using:
Code:
send, {RWin Down}{Tab}{RWin Up}
sleep, 300

and
Code:
send, {Shift Down}{LWin Down}{Tab}{LWin Up}{Shift Up}
sleep, 300

to just scroll through each window in taskbar without activating it


Report this post
Top
  
Reply with quote  
 Post subject: Windows 7?
PostPosted: November 8th, 2009, 6:36 am 
Offline

Joined: June 18th, 2009, 4:39 pm
Posts: 19
Location: Salt Lake City, Utah
Hi,

I'm looking to do the exact same thing, but under Windows 7. I can't seem to get anything to work quite how I'd like it to. Can anyone help?

Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 7:35 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Windows 7's taskbar is (clearly) very different, both on the surface and internally. The methods used by my script were afaik never documented or supported by Microsoft, and will not work on Windows 7. I'm not aware of any working alternative. Microsoft Active Accessibility might come close, if you'd care to research it.

ACC.ahk
Active Accessibility SDK 2.0 Tools (accExplorer may be helpful)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2009, 7:31 pm 
Offline

Joined: June 18th, 2009, 4:39 pm
Posts: 19
Location: Salt Lake City, Utah
Alright, I'll look into those things and see if I can figure something out. If I can, I'll post back here. Thanks!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 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