 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Andras Guest
|
Posted: Fri Jul 09, 2004 12:56 am Post subject: GroupActivate previous window; prev/next window on taskbar |
|
|
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 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jul 09, 2004 1:15 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Fri Jul 09, 2004 5:22 pm Post subject: |
|
|
this reminds me of ahk_group
remember Chris? u liked the idea. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jul 09, 2004 5:33 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Andras Guest
|
Posted: Fri Jul 09, 2004 8:37 pm Post subject: |
|
|
| 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.) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jul 09, 2004 8:52 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Guest
|
Posted: Wed May 28, 2008 3:41 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2492 Location: Australia, Qld
|
Posted: Thu May 29, 2008 6:38 am Post subject: |
|
|
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
} |
|
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 30, 2008 2:20 am Post subject: oops |
|
|
| Sorry, I meant to put in {Rwin} or {Lwin} instead of the "#" sign in my post. I'll look into your code. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 30, 2008 3:23 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2492 Location: Australia, Qld
|
Posted: Fri May 30, 2008 8:51 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 30, 2008 6:19 pm Post subject: got it working |
|
|
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 |
|
| 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
|