 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Thu Feb 28, 2008 3:31 am Post subject: Quickly hide trayicons, taskbar and quicklaunch |
|
|
Hi,
From the Tips N Tricks topic I learned how to quickly hide the tasbar items. Can something similar be done to quickly hide/show the tray icons and the quicklaunch area?
Thanks.
[ Moderator!: Bad link rectified ] _________________ AHK is perfect. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Thu Feb 28, 2008 10:17 am Post subject: |
|
|
So... you want to hide everything except for the start button and clock? Or did you want to hide the taskbar itself?
| Code: | ; Use the Last Found Window feature instead of appending this to every line.
WinExist("ahk_class Shell_TrayWnd")
Control, Hide,, Quick Launch
Control, Hide,, Running Applications
Control, Hide,, SysPager1 ; tray, at least on Vista
Sleep, 2000
WinHide
Sleep, 2000
WinShow
Control, Show,, Quick Launch
Control, Show,, Running Applications
Control, Show,, SysPager1
| You may also hide the whole tray or all toolbars:
| Code: | WinExist("ahk_class Shell_TrayWnd")
Control, Hide,, TrayNotifyWnd1
Sleep, 2000
Control, Show,, TrayNotifyWnd1
Control, Hide,, ReBarWindow321
Sleep, 2000
Control, Show,, ReBarWindow321 |
|
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Thu Feb 28, 2008 5:25 pm Post subject: |
|
|
Thanks a lot sir!
I make a little modification in your code so it could run smooth in here. The result was:
| Code: |
; OCULTAR / MOSTRAR ITENS DA BARRA DE TAREFAS
^+WheelDown::
WinHide, % "ahk_id " DllCall("GetTaskmanWindow")
return
^+WheelUp::
WinShow, % "ahk_id " DllCall("GetTaskmanWindow")
return
; OCULTAR / MOSTRAR QUICKLAUNCH
; Alt+Shift+WheelDown::
!+Wheeldown::
WinExist("ahk_class Shell_TrayWnd")
Control, Hide,, Quick Launch
return
; Alt+Shift+Wheelup
!+Wheelup::
WinExist("ahk_class Shell_TrayWnd")
Control, Show,, Quick Launch
return
; OCULTAR / MOSTRAR BANDEJA, RELÓGIO FICA ISENTO
; Ctrl+Alt+WheelDown/Up
^!Wheeldown::
WinExist("ahk_class Shell_TrayWnd")
Control, Hide,, SysPager1
return
^!Wheelup::
WinExist("ahk_class Shell_TrayWnd")
Control, Show,, SysPager1
return |
respectívely for taskbar, quicklaunch and tray.
However, when it comes to hidding the entire downbar (containing the tray, quicklaunch, taskbar and starmenu), I tried this and messed everything up:
| Code: | ; OCULTAR / MOSTRAR A BARRA COMPLETAMENTE A BARRA INFERIOR
; Ctrl+Alt+Shift+Wheeldown/up
^!+Wheeldown::
WinExist("ahk_class Shell_TrayWnd")
WinHide
return
^!+Wheelup::
Sleep, 2000
WinShow
return |
I hide the bar and it won't come back. What's wrong?
 _________________ AHK is perfect. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri Feb 29, 2008 1:43 am Post subject: |
|
|
The Last Found Window is set only until the end of the thread (hotkey, timer subroutine, etc.) Use these:
| Code: | | WinHide, ahk_class Shell_TrayWnd |
| Code: | WinShow, ahk_class Shell_TrayWnd
| (Sleep, 2000 isn't necessary; I only put it in for demonstration...) |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Fri Feb 29, 2008 10:23 pm Post subject: |
|
|
| lexiKos wrote: | The Last Found Window is set only until the end of the thread (hotkey, timer subroutine, etc.) Use these:
| Code: | | WinHide, ahk_class Shell_TrayWnd |
| Code: | WinShow, ahk_class Shell_TrayWnd
| (Sleep, 2000 isn't necessary; I only put it in for demonstration...) |
Sorry for being so n00b, but where exactly should I past that line? I replaced the
(under the) | Code: | | WinExist("ahk_class Shell_TrayWnd") |
With
| Code: | | WinHide, ahk_class Shell_TrayWnd |
And didn't work.  _________________ AHK is perfect. |
|
| Back to top |
|
 |
Erittaf
Joined: 03 Nov 2007 Posts: 182
|
Posted: Fri Feb 29, 2008 11:05 pm Post subject: |
|
|
| lexiKos wrote: | The Last Found Window is set only until the end of the thread (hotkey, timer subroutine, etc.) Use these:
| Code: | | WinHide, ahk_class Shell_TrayWnd |
| Code: | WinShow, ahk_class Shell_TrayWnd
| (Sleep, 2000 isn't necessary; I only put it in for demonstration...) |
hrm... this nukes the entire taskbar except the start button on vista!  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Sat Mar 01, 2008 1:48 am Post subject: |
|
|
The start button is a separate window. There's actually a smaller, clipped button under it.
| Code: | WinHide, Start ahk_class Button
Sleep, 2000
WinShow, Start ahk_class Button |
|
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Mon Mar 10, 2008 6:28 pm Post subject: |
|
|
Didn't work, lex..
However what did you mean by | Quote: | | There's actually a smaller, clipped button under it. | ? _________________ AHK is perfect. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Mon Mar 10, 2008 9:50 pm Post subject: |
|
|
| In Vista, the start button is a window floating over the taskbar. Once you hide it, you can see a smaller start button which is actually a control on the taskbar. The text ("Start") may depend on language selections. Use Window Spy to find out what it is... |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Tue Mar 11, 2008 4:07 am Post subject: |
|
|
Yeah right but I don't have Vista yet.. I'm still with XP  _________________ AHK is perfect. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Tue Mar 11, 2008 5:14 am Post subject: |
|
|
The code was a reply to Erittaf:
| Erittaf wrote: | | hrm... this nukes the entire taskbar except the start button on vista! |
If you want to hide the Start button on older versions of Windows, this might work:
| Code: | ; to hide:
Control, Hide,, Button1, ahk_class Shell_TrayWnd
; to show:
Control, Show,, Button1, ahk_class Shell_TrayWnd |
|
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Tue Mar 11, 2008 1:02 pm Post subject: |
|
|
Oops sorrry, thanks!  _________________ AHK is perfect. |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Thu Mar 20, 2008 6:25 pm Post subject: |
|
|
One more thing:
it would be very nice if we could quickly activate the taskbar objects without having to click them, like pressing "ALT+1, 2, 3" to activate the taskbar minimized windows. I believe there is already something similar to it but I don't know what...
Also, what about a script that could easily kill the processes associated with the tray objects, so we could close them without having to right-click then "exit" or "close", depending on the application? The logic would be like the one in this picture:
 _________________ AHK is perfect. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Fri Mar 21, 2008 1:16 am Post subject: |
|
|
Toolbar messages can be used to determine which window belongs to which button. Once you know that, you can simply activate the corresponding window. I use the following to cycle through the buttons using the tilt of my mouse wheel:
| Code: | TaskSwitchDelta(delta, wrap=true) ; delta = typically -1 or +1
{
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
} | You may adapt and/or use it however you like. It is based on Sean's TaskButton.ahk.
Killing taskbar buttons typically leaves the tray icon in the tray until you hover over it with the mouse. You may be able to close the window associated with the tray icon, but I'm not sure how consistently that will work. See TrayIcon.ahk. |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 174
|
Posted: Fri Mar 21, 2008 4:25 pm Post subject: |
|
|
Oh GOd
I've never seen such an obscure code
I tried in here, first as a separate script, nothing happened... the ahk tray icon showed up for about half a second in the tray then vanished. Then I tried appending the code to my main script, nothing different happened, I don't even know where do I start from...
I'm aware of the task button and trayicon.ahk scripts, look at a shot of mine:
However, what are the relevant values and what do I do with those numbers? _________________ AHK is perfect. |
|
| 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
|