It is currently April 18th, 2024, 9:09 am

Function for sensing taskbar state when in autohide

General topics related to Rainmeter.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

Post by kyriakos876 »

Slim08 wrote: 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:



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.
Oh okay, I see you.... Let me do this for you. First I need you to confirm that your main monitor is 2560*1080 and that it's the middle one of the three. Is that correct?
User avatar
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

Re: Function for sensing taskbar state when in autohide

Post by Slim08 »

Screen 1 Left 1920*1080 secondary
Screen 2 Center 2560*1080 primary
Screen 3 Right 1920*1080 secondary
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

Post by kyriakos876 »

Slim08 wrote: November 7th, 2018, 7:57 pm Screen 1 Left 1920*1080 secondary
Screen 2 Center 2560*1080 primary
Screen 3 Right 1920*1080 secondary
Ok cool, try this and let me know:

Code: Select all

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

[Variables]
DefaultColorRGB=1,164,239,242,80,34,127,186,0
Check1=
Check2=
Check3=

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

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

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

[CalcY3]
Measure=Calc
Formula=(#ScreenAreaHeight#-15)
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=#Check1#,#Check2#,#Check3#
IfMatch=^#DefaultColorRGB#$
IfTrueAction=[!SetOption MeterStatus Text "Taskbar is showing"][!Update]
IfFalseAction=[!SetOption MeterStatus Text "Taskbar is hidden"][!Update]
DynamicVariables=1
User avatar
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

Re: Function for sensing taskbar state when in autohide

Post by Slim08 »

Doesn't show up at all but I can't see why...
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Function for sensing taskbar state when in autohide

Post by Active Colors »

kyriakos876 wrote: 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
This is great! I don't see taskbar placement though (top bottom left right)?
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

Post by kyriakos876 »

Active Colors wrote: November 7th, 2018, 10:37 pm This is great! I don't see taskbar placement though (top bottom left right)?
Well, here's the original (I removed everything almost so that whoever decides to use it for X,Y,W,H will have less code to deal with):

Code: Select all

#Region
#AutoIt3Wrapper_UseUpx=n
#EndRegion
GLOBAL $SUPERBARPOS
$SUPERBARPOS=WINGETPOS("[CLASS:Shell_TrayWnd]")
MSGBOX(0,"Testing...","OS: "&@OSTYPE&"|"&@OSVERSION&"|"&@OSARCH&"|"&@OSBUILD&"|"&@OSSERVICEPACK&"|"&@OSLANG&@CRLF&"HWD: "&WINGETHANDLE("[CLASS:Shell_TrayWnd]","")&@CRLF&"Супербар находится: "&_GETSUPERBARPOS2()&@CRLF&"Его атрибуты: x:"&$SUPERBARPOS[0]&" y:"&$SUPERBARPOS[1]&" w:"&$SUPERBARPOS[2]&" h:"&$SUPERBARPOS[3]&@CRLF&"Состояние супербара: "&_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 "автоскрытие включено"
ELSE
RETURN "автоскрытие отключено"
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
FUNC _GETSUPERBARPOS()
$SUPPOS=0
$SUPERBARPOS=WINGETPOS("[CLASS:Shell_TrayWnd]")
IF $SUPERBARPOS[0]=0 AND $SUPERBARPOS[1]=(@DESKTOPHEIGHT-$SUPERBARPOS[3])AND $SUPERBARPOS[2]=@DESKTOPWIDTH THEN
$SUPPOS=1
ELSEIF $SUPERBARPOS[0]=0 AND $SUPERBARPOS[1]=0 AND $SUPERBARPOS[2]=@DESKTOPWIDTH THEN
$SUPPOS=2
ELSEIF $SUPERBARPOS[0]=0 AND $SUPERBARPOS[3]=@DESKTOPHEIGHT THEN
$SUPPOS=3
ELSEIF $SUPERBARPOS[0]=(@DESKTOPWIDTH-$SUPERBARPOS[2])AND $SUPERBARPOS[3]=@DESKTOPHEIGHT THEN
$SUPPOS=4
ENDIF
RETURN $SUPPOS
ENDFUNC
FUNC _GETWINDOWBORDERWIDTH()
$ISDUMMYWINDOW=WINEXISTS("dummy_gui_1445998717")
IF $ISDUMMYWINDOW=0 THEN
$DUMMYGUI=GUICREATE("dummy_gui_1445998717",200,200,-1,-1,BITOR(13565952,16777216),BITOR(128,32))
WINSETTRANS($DUMMYGUI,"",0)
GUISETSTATE(@SW_SHOW,$DUMMYGUI)
$DWINPOS=WINGETPOS($DUMMYGUI)
$ISDUMMYWINDOW=1
ELSE
$DWINPOS=WINGETPOS("dummy_gui_1445998717")
$ISDUMMYWINDOW=1
ENDIF
IF $ISDUMMYWINDOW=10 THEN
GUIDELETE(WINGETHANDLE("dummy_gui_1445998717"))
ENDIF
IF ISARRAY($DWINPOS)THEN
IF SQRT($DWINPOS[0]^2)>10 THEN
RETURN 10
ELSE
RETURN SQRT($DWINPOS[0]^2)
ENDIF
ELSE
RETURN 0
ENDIF
ENDFUNC

User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Function for sensing taskbar state when in autohide

Post by kyriakos876 »

Slim08 wrote: November 7th, 2018, 8:26 pm Doesn't show up at all but I can't see why...
oops, I had a typo....

try this :Whistle :

Code: Select all

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

[Variables]
DefaultColorRGB=1,164,239,242,80,34,127,186,0
Check1=
Check2=
Check3=

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

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

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

[CalcY3]
Measure=Calc
Formula=(#ScreenAreaHeight#-15)
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=#Check1#,#Check2#,#Check3#
IfMatch=^#DefaultColorRGB#$
IfMatchAction=[!SetOption MeterStatus Text "Taskbar is showing"][!Update]
IfNotMatchAction=[!SetOption MeterStatus Text "Taskbar is hidden"][!Update]
DynamicVariables=1