smdanjm
smdanjm

Reputation: 41

Why does switching desktops with AutoHotKey make my taskbar icons highlight orange?

I am yet to find a method to switch desktops that doesn't result in the taskbar icons highlighting orange.

e.g. the following script wreaks this havoc on my taskbar

^#Right::
send, ^#{Right}
return

^#Left::
send, ^#{Left}
return

What methods are there to get around this?

Upvotes: 4

Views: 786

Answers (1)

Mr. Doge
Mr. Doge

Reputation: 886

Sometimes when I switch desktop, the application that's focused on that desktop becomes highlighted in the task bar.

Example: On desktop A, I have Firefox:
untitled

On desktop B I have Steam (note that Firefox is pinned to my task bar, which is why it's visible on this desktop):
untitled2

When I switch from A to B, Steam becomes highlighted:
untitled3 (It's possible to stop the blinking by explicitly selecting the blinking window with the mouse or alt+tab.)

When I switch back to A, Firefox also becomes highlighted (and Steam stays visible in the taskbar because it is highlighted):
untitled4

This doesn't always happen; I'm not sure if it depends on the programs or where the mouse/keyboard focus is when switching desktops. That said, it happens far too often, to the point where it defeats the point of having multiple desktops at all.

(The problem isn't limited to Firefox and Steam, the same thing also happens with other programs like Explorer.)

https://github.com/FuPeiJiang/VD.ahk#cool-fixes

WinActivate taskbar before switching and WinMinimize taskbar after arriving

    ;activate taskbar before
    WinActivate, ahk_class Shell_TrayWnd
    WinWaitActive, ahk_class Shell_TrayWnd
    DllCall(SwitchDesktop, "ptr", IVirtualDesktopManagerInternal, "UPtr", IVirtualDesktop, "UInt")
    DllCall(SwitchDesktop, "ptr", IVirtualDesktopManagerInternal, "UPtr", IVirtualDesktop, "UInt")
    WinMinimize, ahk_class Shell_TrayWnd

https://github.com/FuPeiJiang/VD.ahk/blob/6fc1b2b7ff9ab53c8530c0d9a2e01a6617c064f4/VD.ahk#L555-L560

actual source: https://github.com/mzomparelli/zVirtualDesktop/issues/59#issuecomment-317613971

Upvotes: 1

Related Questions