Push Winkey to show autohidden taskbar

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Push Winkey to show autohidden taskbar

15 May 2017, 16:24

Fairly simple idea, I just want the taskbar to activate while the Windows key is pressed, and then hide when released. What am I getting wrong here?

Code: Select all

~LWin::
WinGetTitle, window, A
WinShow, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
return

~LWin Up::
WinActivate, %window%
Sleep 1000
WinHide, ahk_class Shell_TrayWnd
return
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Push Winkey to show autohidden taskbar

16 May 2017, 02:14

Hallo,
this works, no problem!
Windows 7 64bit Enterprise
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

16 May 2017, 17:33

For some reason that method wasn't working for me, so I used KeyWait instead.

Code: Select all

$LWin::
WinGetTitle, title, A
WinShow, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
KeyWait, LWin
Sleep 100
WinActivate, %title%
Sleep 1000
WinHide, ahk_class Shell_TrayWnd
return
I'm thinking of implementing a double-press LWin to keep the taskbar activated without holding LWin down. This isn't working for me though, I can't see why not...

Code: Select all

$LWin::
WinGetTitle, title, A
if (A_PriorHotkey <> "$LWin" or A_TimeSincePriorHotkey > 400)
{
WinShow, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
KeyWait, LWin
Sleep 100
WinActivate, %title%
Sleep 750
WinHide, ahk_class Shell_TrayWnd
return
}
WinShow, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
return
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

25 May 2017, 15:40

I ended up preferring this method. It just activates the taskbar with one press, and then opens the start menu with a second press while active.

Code: Select all

~LWin Up::
KeyWait, LAlt, D T0.1 ; wait for 0.1s for other hotkey combos used with LAlt
If ErrorLevel ; LAlt was not pressed in time
{
IfWinNotActive, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
Else
Send, {Lwin} ; open start menu
}
return
One tiny cosmetic issue I'm running into now though... Whenever I use my other hotkey combos with the winkey, like #!d to dim the screen for example, it still activates the taskbar unnecessarily. I tried $LWin::, which works if I press LAlt first, and then LWin plus d, but just wondering if there's a way to escape activation with a simultaneous press?
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Push Winkey to show autohidden taskbar

26 May 2017, 00:32

Hallo,
I use modifier keys, mouse buttons and wheel only in combination with other keys as hotkeys.
Brings really more problems than benefits!
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

26 May 2017, 18:17

Agreed, that's certainly an option to think about going forward; however, even with the native Windows function of LWin & e to launch an explorer window, it still activates the taskbar unnecessarily.
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

30 May 2017, 19:23

Restructured everything. Now it works they way it's supposed to without the unnecessary activations.

Code: Select all

~LWin::
keyPressed := 0 ; initialize check variable
KeyWait, LAlt, D T0.1 ; wait for 0.1s for other hotkeys with LAlt
If ErrorLevel = 0 ; LAlt was pressed in time
{
keyPressed := 1
}
Else
{
WinGet, originalID, ID, A ; get current window ID
Loop
{
WinGet, winID, ID, A
Sleep 50
If (winID = originalID) ; no new window opened
  continue
Else ; window was opened
  keyPressed := 1
  break
}
}
return

LWin Up::
If (keyPressed = 0)
{
IfWinNotActive, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
Else
Send, {Lwin}
}
return
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

23 Oct 2017, 12:48

I found that I could use GetKeyState instead of the KeyWait from before, that way I have as much time as my fingertips desire to press the other button. It's also a much cleaner code. Unfortunately, this isn't working correctly. Only about half the time does it actually activate the task bar, and then the other half it just does nothing at all. Can someone point out what I might be missing?

Code: Select all

~LWin::
keyPressed := 0
WinGet, lastID, ID, A
While GetKeyState("LWin", "P")
{
WinGet, nextID, ID, A
Sleep 50
If GetKeyState("LAlt", "P")
keyPressed := 1
}
If (nextID != lastID)
keyPressed := 1
return

LWin Up::
If (keyPressed = 0)
{
IfWinNotActive, ahk_class Shell_TrayWnd
WinActivate, ahk_class Shell_TrayWnd
Else
Send, {Lwin}
}
return
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

17 Nov 2018, 19:00

I never posted an update to the final working code. This works perfectly, albeit forcing LWin Up to do nothing.

Code: Select all

~LWin::
IfWinActive, ahk_class Shell_TrayWnd
Send, {Lwin} ; opens start menu
Else
  {
  keyPressed := 0
  WinGet, lastID, ID, A ; stores window ID to anticipate window change
  While GetKeyState("LWin", "P")
    {
    WinGet, nextID, ID, A ; checks for window change
    Sleep 50
    If GetKeyState("LAlt", "P") ; used for combo hotkeys "#!s" etc
    keyPressed := 1
    }
  WinGet, IDProcess, ProcessName, ahk_id %nextID%
  If (nextID != lastID) ; window changed
    {
    keyPressed := 1
    }
  If (keyPressed = 0)
  WinActivate, ahk_class Shell_TrayWnd
  }
return

LWin Up::
return
I've been toying with a more streamlined version, using A_ThisHotKey or A_PriorHotKey, but I can't seem to get it to work the same. A_ThisHotKey is showing "LWin Up" when LWin is pressed, oddly enough.

Code: Select all

~LWin::
IfWinActive, ahk_class Shell_TrayWnd
Send, {Lwin} ; opens start menu
Else
  {
  keyPressed := 0
  While GetKeyState("LWin", "P")
    {
    Sleep 50
    If (A_ThisHotKey != "~LWin") ; supposed to check if any other key was pressed
      {
      ToolTip, %A_ThisHotKey%`n%A_PriorHotKey%`n%keyPressed% ; for testing
      keyPressed := 1
      }
    }
  If (keyPressed = 0)
  WinActivate, ahk_class Shell_TrayWnd
  }
return

LWin Up::
return
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Push Winkey to show autohidden taskbar

18 Nov 2018, 04:12

Hallo,
switch the taskbar to permanent display and try this:

Code: Select all

#Persistent
SetTimer, LWin, 250
LWin:
CoordMode, Mouse
MouseGetPos,, MY
If GetKeyState("LWin","P") Or MY > A_ScreenHeight - 40
	WinShow, ahk_class Shell_TrayWnd
Else
	WinHide, ahk_class Shell_TrayWnd
Return
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

Re: Push Winkey to show autohidden taskbar

20 Nov 2018, 17:30

That's more similar to my first post, rather than my updated code, but thank you.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, mcd, rubeusmalfoy, ShatterCoder and 82 guests