It is currently December 14th, 2018, 8:22 pm

Function for sensing taskbar state when in autohide

General topics related to Rainmeter.
User avatar
Active Colors
Moderator
Posts: 498
Joined: February 16th, 2012, 3:32 am

Re: Function for sensing taskbar state when in autohide

Active Colors » November 7th, 2018, 1:28 pm

kyriakos876 wrote:
November 7th, 2018, 9:39 am
That's different from what the op wants... This probably reads and translates the registry value I mentioned above, which does not provide the information needed. Unless the size includes the current width and height whose height you can use to know if the taskbars currently hidden. (But I highly doubtful Windows shares this information)
balala wrote:
November 7th, 2018, 11:51 am
That AutoIt addon probably shows, as you said, the position, size and if it has auto-hiding option, but not if the auto-hidden taskbar is up or down.
In fact, I'd say that what Slim08 asked initially is probably not possible: https://forum.rainmeter.net/viewtopic.php?f=4&t=30007#p154684
I am not sure what you mean together since both of you say different things. Anyways, replying to both, with this addon it is possible to see both: where is the taskbar (top, bottom, left, right), and if it is shown or hidden now using provided by the addon x, y, w, h of the taskbar.

From those values you can logically conclude with simple math the state of the taskbar.
My example.
I have my taskbar at top and it is set to auto-hiding. According to that addon, my taskbar has 30px height. When it is hidden its Y is -28, which means (and really is) my taskbar shows only two pixels from the top in the hidden state. When I hover the taskbar and make it visible the addon shows that the Y position is 0.
  • if the taskbar is hidden on the Top, the Y value will be negative.
  • if the taskbar is hidden on the Left, the X value will be negative.
  • if the taskbar is hidden on the Right, the X value will be almost the same as the SCREENAREAWIDTH (recall my example when my taskbar was showing couple of pixels in the hidden mode)
  • if the taskbar is hidden on the Bottom, the Y value will be almost the same as the SCREENAREAHEIGHT (again, recall my example when my taskbar was showing couple of pixels in the hidden mode)
It might be a bit confusing since ~Faradey~ made it in Russian language, I am attaching the translation.
Capture.PNG
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 7191
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Function for sensing taskbar state when in autohide

balala » November 7th, 2018, 1:35 pm

Active Colors wrote:
November 7th, 2018, 1:28 pm
I am not sure what you mean together since both of you say different things. Anyways, replying to both, with this addon it is possible to see both: where is the taskbar (top, bottom, left, right), and if it is shown or hidden now using provided by the addon x, y, w, h of the taskbar.
I'm not sure, I just concluded what jsmorley said, about the fact that if the taskbar is set to auto-hide, you're not able to check if at a given moment it is visible or not. I'm not sure if this is true, but I'd think it is. Sorry if I'm mistaken...
User avatar
Active Colors
Moderator
Posts: 498
Joined: February 16th, 2012, 3:32 am

Re: Function for sensing taskbar state when in autohide

Active Colors » November 7th, 2018, 1:38 pm

balala wrote:
November 7th, 2018, 1:35 pm
I'm not sure, I just concluded what jsmorley said, about the fact that if the taskbar is set to auto-hide, you're not able to check if at a given moment it is visible or not. I'm not sure if this is true, but I'd think it is. Sorry if I'm mistaken...
I have just answered that it is possible to see if it is hidden considering that auto-hiding feature is on.
User avatar
balala
Rainmeter Sage
Posts: 7191
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Function for sensing taskbar state when in autohide

balala » November 7th, 2018, 1:45 pm

Active Colors wrote:
November 7th, 2018, 1:38 pm
I have just answered that it is possible to see if it is hidden considering that auto-hiding feature is on.
As I said, probably I was wrong. Although using Windows's tool this can't be known, probably using Faradey's SuperbarInfo tool it can be (however I didn't test it yet).
And again: sorry if I was mistaken.
User avatar
kyriakos876
Posts: 887
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

kyriakos876 » November 7th, 2018, 1:54 pm

Yes, I said the same I just thought that the height was decreasing. Instead the y is, pretty much the same. So it's possible indeed. I'mma decompile it later and check what API it uses to retrieve the info.
User avatar
kyriakos876
Posts: 887
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

kyriakos876 » November 7th, 2018, 2:15 pm

Any chance you remember what language it was written in?
User avatar
Active Colors
Moderator
Posts: 498
Joined: February 16th, 2012, 3:32 am

Re: Function for sensing taskbar state when in autohide

Active Colors » November 7th, 2018, 3:53 pm

Hey, no problems. It was written with AutoIT and I believe for one of his Rainmeter skins. He probably could explain it better but he was not active on the forum since January. I would also take a look at his Rainmeter skins specifically Kotoko for which he made lots of custom addons.
User avatar
balala
Rainmeter Sage
Posts: 7191
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Function for sensing taskbar state when in autohide

balala » November 7th, 2018, 4:14 pm

Active Colors wrote:
November 7th, 2018, 3:53 pm
He probably could explain it better but he was not active on the forum since January.
Probably kyriakos876, you could send a PM, asking him to help you. Here is his profile: https://forum.rainmeter.net/memberlist.php?mode=viewprofile&u=2226
User avatar
kyriakos876
Posts: 887
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

kyriakos876 » November 7th, 2018, 7:09 pm

Okay so, I decompiled the script and this is a simplified translated version of it:

Code: Select all

#Region
#AutoIt3Wrapper_UseUpx=n
#EndRegion
GLOBAL $SUPERBARPOS
$SUPERBARPOS=WINGETPOS("[CLASS:Shell_TrayWnd]")
MSGBOX(0,"Testing...","Taskbar's attributes: x:"&$SUPERBARPOS[0]&" y:"&$SUPERBARPOS[1]&" w:"&$SUPERBARPOS[2]&" h:"&$SUPERBARPOS[3]&@CRLF&"Superbar condition: "&_TASKBARHIDDEN())
FUNC _TASKBARHIDDEN()
LOCAL CONST $ABM_GETSTATE=4,$ABS_AUTOHIDE=1,$ABS_ONTOP=2
LOCAL $ARETURN
$ARETURN=DLLCALL("shell32.dll","uint","SHAppBarMessage","dword",$ABM_GETSTATE,"ptr*",0)
IF @ERROR THEN
RETURN SETERROR(1,0,0)
ENDIF
IF BITAND($ARETURN[0],$ABS_AUTOHIDE)THEN
RETURN "Auto hide is enabled"
ELSE
RETURN "Auto hide is disabled"
ENDIF
ENDFUNC
FUNC _GETSUPERBARPOS2()
LOCAL CONST $ABM_GETTASKBARPOS=5
LOCAL CONST $ABE_LEFT=0
LOCAL CONST $ABE_TOP=1
LOCAL CONST $ABE_RIGHT=2
LOCAL CONST $ABE_BOTTOM=3
LOCAL $ARETURN
GLOBAL $_POSITIONS[4]=["Left","Top","Right","Bottom"]
GLOBAL $TAG_APPBARDATA="LONG;HWND;INT;INT;STRUCT;INT;INT;INT;INT;ENDSTRUCT"
LOCAL $PDATA=DLLSTRUCTCREATE($TAG_APPBARDATA)
DLLSTRUCTSETDATA($PDATA,1,DLLSTRUCTGETSIZE($PDATA))
DLLSTRUCTSETDATA($PDATA,2,WINGETHANDLE("[CLASS:Shell_TrayWnd]",""))
LOCAL $ARESULT=DLLCALL("Shell32.dll","BOOL","SHAppBarMessage","DWORD",$ABM_GETTASKBARPOS,"ptr",DLLSTRUCTGETPTR($PDATA))
IF @ERROR THEN RETURN SETERROR(@ERROR,0,-1)
IF NOT $ARESULT[0]THEN RETURN SETERROR($ARESULT[0],0,-2)
RETURN $_POSITIONS[DLLSTRUCTGETDATA($PDATA,4)]
ENDFUNC
Preview.png
I'm not autoit expert tho but whatever you wish to do requires the script to be run again and again all the time, because it doesn't show real time position of the taskbar.
And there's probably a Rainmeter plugin somewhere but I've never needed to use it before so someone else could take it from here.

And that's the script in a file:
SuperbarInfo_restore.rar
You do not have the required permissions to view the files attached to this post.
User avatar
Slim08
Posts: 22
Joined: October 8th, 2018, 4:38 pm

Re: Function for sensing taskbar state when in autohide

Slim08 » November 7th, 2018, 7:41 pm

Boy this thread took off the last couple of hours O.O Thank you all for your contributions :thumbup:
kyriakos876 wrote:
November 7th, 2018, 6:58 am
Oh okay.... I thought you had a simple desktop... I suppose the 3 monitors and you are using translucent taskbar? Can't help you there ... I could do something similar if you have something pinned to your taskbar that you don't plan on changing the position of. For example if you have pinned the file explorer it could work but I would need a screenshot of your desktop with the file explorer, or whatever it is, showing. This obviously can't be used by someone else but if you won't it for yourself, be sure to send that screenshot if you have anything pinned there :)
(That doesn't look like window's taskbar... the start button's missing + the stuff on the right that displays the time, notifications etc.)
I tried your way and ended up with this:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
BackgroundMode=2
SolidColor=40,40,40
DynamicWindowSize=1

[Variables]
;Red
DefaultColorRGB1=242,80,34
;Blue
DefaultColorRGB2=1,164,239
;Green
DefaultColorRGB3=127,186,0
Check1=
Check2=
Check3=
Passed=
Passed2=

[MeterStatus]
Meter=String
Text=
FontSize=15
FontColor=255,255,255
AntiAlias=1
DynamicVariables=1

[CalcY1]
Measure=Calc
Formula=(#ScreenAreaHeight#-25)
DynamicVariables=1

[CalcY2]
Measure=Calc
Formula=(#ScreenAreaHeight#-15)
DynamicVariables=1

[CalcY3]
Measure=Calc
Formula=(#ScreenAreaHeight#-25)
DynamicVariables=1

[MeasurePixels]
Measure=Plugin
Plugin=PixelColor
OnUpdateAction=[!SetVariable Check1 "[&MeasurePixels:PixelRGB(15, [&CalcY1])]"][!SetVariable Check2 "[&MeasurePixels:PixelRGB(15, [&CalcY2])]"][!SetVariable Check3 "[&MeasurePixels:PixelRGB(25, [&CalcY3])]"]
DynamicVariables=1

[Controller]
Measure=String
String=#Check2#
IfMatch=^((?!#DefaultColorRGB1#).)*$
IfMatchAction=[!SetVariable Passed "1"][!Update]
IfNotMatchAction=[!SetVariable Passed "0"][!Update]
DynamicVariables=1

[Controller2]
Measure=String
String=#Check1#,#Check3#
IfMatch=#DefaultColorRGB2#,#DefaultColorRGB3#
IfMatchAction=[!SetVariable Passed2 "1"][!Update]
IfNotMatchAction=[!SetVariable Passed2 "0"][!Update]
DynamicVariables=1

[Main]
Measure=Calc
Formula=1
IfCondition=(#Passed2# + #Passed# = 2)
IfTrueAction=[!SetOption MeterStatus Text "Taskbar is showing"][!Update]
IfFalseAction=[!SetOption MeterStatus Text "Taskbar is hidden"][!Update]
DynamicVariables=1
With this screen:
Image

I was thinking that the start orb would make for a good target but for some reason I don't get it to work. The four dots of the orb are consistent at any point and as far as I can tell is the center screen (set as primary) x=0 in the left corner but I also tried all x axis +1920px with no result.