Get taskbar autohide state? Solved Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
theimmersion
Posts: 180
Joined: 09 Jul 2016, 08:34
Location: Serbia

Get taskbar autohide state? Solved

29 Oct 2017, 08:48

Im rather active lately here and im awefuly sorry if i ask too many questions, make posts but when i ask, means i couldnt figure it out myself nor was google any help.

So i have this to toggle autohide of taskbar that i found long ago on ahk forums but i actually need a way to get the state of it rather than to set it.
This is the code that toggles it:

Code: [Select all] [Download] GeSHi © Codebox Plus

	VarSetCapacity(APPBARDATA, A_PtrSize=4 ? 36:48)
NumPut(DllCall("Shell32\SHAppBarMessage", "UInt", 4 ; ABM_GETSTATE
, "Ptr", &APPBARDATA
, "Int")
? 2:1, APPBARDATA, A_PtrSize=4 ? 32:40) ; 2 - ABS_ALWAYSONTOP, 1 - ABS_AUTOHIDE
, DllCall("Shell32\SHAppBarMessage", "UInt", 10 ; ABM_SETSTATE
, "Ptr", &APPBARDATA)

How does one make this actually return a value of 1 for autohide enabled and 0 for auto hide disabled?
And in case i or anyone else could ever need that, can we also get the taskbar locked state and always on top as well?
I want to show a custom clock on my screen when taskbar is hidden and for that i need to know when its hidden or not.
Ill experiment still and post any new findings. :)
THANKS GUYS!
Last edited by theimmersion on 29 Oct 2017, 09:37, edited 1 time in total.
User avatar
theimmersion
Posts: 180
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Get taskbar autohide state?

29 Oct 2017, 09:15

Btw, this is what i use to determine the location of the taskbar.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 4511
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Get taskbar autohide state?  Topic is solved

29 Oct 2017, 09:17

This should do it.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



It appears you can't change the on-top status of the taskbar, at least by this method.

Code: [Select all] [Download] GeSHi © Codebox Plus

e:: ;attempt to toggle/turn off taskbar always-on-top (didn't work) (tested on Windows 7)
WinGet, vWinExStyle, ExStyle, ahk_class Shell_TrayWnd
MsgBox, % Format("0x{:08X}", vWinExStyle)
;WinSet, ExStyle, ^0x8, ahk_class Shell_TrayWnd
WinSet, ExStyle, 0x80, ahk_class Shell_TrayWnd
return


To lock the taskbar:
taskbar - Lock or disable resizing of task bar autohotkey - Stack Overflow
https://stackoverflow.com/questions/40765489/lock-or-disable-resizing-of-task-bar-autohotkey

[EDIT:] Here's some code to get/set the locked state:

Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;taskbar - toggle lock/unlock
PostMessage, 0x111, 424, 0,, ahk_class Shell_TrayWnd
return

w:: ;taskbar - get locked state
RegRead, vIsMovable, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove
MsgBox, % "taskbar is locked: " (vIsMovable ? "n" : "y")
return
Last edited by jeeswg on 06 Nov 2017, 02:01, edited 1 time in total.
User avatar
theimmersion
Posts: 180
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Get taskbar autohide state?

29 Oct 2017, 09:36

Some express reply, amazing. Thank you very much! This will be very handy.
User avatar
theimmersion
Posts: 180
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Get taskbar autohide state? Solved

29 Oct 2017, 09:51

One last thing, could someone test my code above and post the screen height with the task bar coords when its up and when down?
In my case, my monitors height is 768 and the taskbar coord is 738 when its poped up and 766 when its poped down.
Im interested if there is always a 2 pixel offset regardles of screen height. This way, could also do stuff when task bar is posped up and down independently. :)

EDIT - this makes the clock not only show when taskbar is on autohide but also, only when its down as well.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Happy coding! :)
User avatar
jeeswg
Posts: 4511
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Get taskbar autohide state? Solved

29 Oct 2017, 10:06

I tried your script and it returned 'Bottom' all the time. According to my script below, like you, the top of the taskbar was 2 pixels above the bottom of the screen when 'hidden'.

Code: [Select all] [Download] GeSHi © Codebox Plus

q:: ;taskbar get position
WinGetPos, vWinX, vWinY, vWinW, vWinH, ahk_class Shell_TrayWnd
MsgBox, % Clipboard := Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
MsgBox, % A_ScreenWidth " " A_ScreenHeight
return

;x0 y680 w1280 h40 ;shown
;x0 y718 w1280 h40 ;hidden
;w1280 h720 ;screen
User avatar
theimmersion
Posts: 180
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Get taskbar autohide state? Solved

29 Oct 2017, 10:27

Thank you very much. Alright then, i assume that the offsets arent being modified by different screen sizes so it should work on any screen resolution the same. :)
User avatar
jeeswg
Posts: 4511
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Get taskbar autohide state? Solved

06 Nov 2017, 02:02

I added some code above to get/set the locked state.

Return to “Ask For Help”

Who is online

Users browsing this forum: codeblue176, Google [Bot] and 11 guests