Jump to content

Spotify Windows 11 taskbar info bar


nend
 Share

Recommended Posts

Hi
I made a program which get the artist – title information from the Windows Spotify program and shows it on the Windows taskbar (not working from the web version).
It’s shows the Artist – Title information on the right side on the Windows taskbar.
You can change the text colour by clicking on the icon in the icon in the systray.

image.png.ffb08dab1312bd35151be2533a9d478f.png


Can you give me feedback please?

Thanks for testing it.

Only for Windows 11 !!!!

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>
#include <Array.au3>
#include <Include/StringSize.au3>
#include <TrayConstants.au3>
#include <String.au3>
#include <Misc.au3>

Opt("TrayMenuMode", 3)

Global $program_name = "Spotibar"
Global $program_version = "V0.1"

Global $hGraphic_object_controls, $Hbitmap_controls, $nowplaying
Global $strip_extra
Local $tmr_loop = TimerInit()

_GDIPlus_Startup()

TraySetToolTip($program_name & " " & $program_version)

Local $tray_config_menu = TrayCreateMenu("Config")
Local $tray_config_strip = TrayCreateItem("Strip extra information", $tray_config_menu)
Local $tray_config_colour = TrayCreateItem("Text colour", $tray_config_menu)
Local $tray_config_autostart = TrayCreateItem("Auto start with Windows", $tray_config_menu)
TrayCreateItem("")
Local $tray_exit = TrayCreateItem("Exit")

If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "" Or RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "1" Then
    TrayItemSetState($tray_config_strip, $TRAY_CHECKED)
    $strip_extra = True
Else
    TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED)
    $strip_extra = False
EndIf

If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") = "" Then
    Global $text_colour = "0xFF009B00"
Else
    Global $text_colour = "0xFF" & StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour"), 6)
EndIf

$var = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
If Not @error Then
    TrayItemSetState($tray_config_autostart, $GUI_CHECKED)
EndIf

Local $h_win_infobar = _Infobar_start()

While 1
    Local $tray = TrayGetMsg()

    Switch $tray
        Case $tray_config_strip
            If BitAND(TrayItemGetState($tray_config_strip), $TRAY_UNCHECKED) Then
                TrayItemSetState($tray_config_strip, $TRAY_CHECKED)
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 1)
                $strip_extra = True
            Else
                TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED)
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 0)
                $strip_extra = False
            EndIf
        Case $tray_config_colour
            TrayItemSetState($tray_config_colour, $TRAY_CHECKED)
            Local $colourinfo = RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour")
            If $colourinfo = "" Then
                $colourinfo = "0x009B00"
            EndIf
            $colourinfo = _ChooseColor(2, $colourinfo, 2)
            If Not (@error) Then
                If $colourinfo > "" Then
                    RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour", "REG_SZ", $colourinfo)
                    $text_colour = "0xFF" & StringRight($colourinfo, 6)
                    _Infobar_set_text($h_win_infobar)
                EndIf
            EndIf
            TrayItemSetState($tray_config_colour, $TRAY_UNCHECKED)
        Case $tray_config_autostart
            If BitAND(TrayItemGetState($tray_config_autostart), $TRAY_UNCHECKED) Then
                RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar", "REG_SZ", '"' & @ScriptDir & '\Spotibar.exe"')
                TrayItemSetState($tray_config_autostart, $TRAY_CHECKED)
            Else
                RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
                TrayItemSetState($tray_config_autostart, $TRAY_UNCHECKED)
            EndIf
        Case $tray_exit
            _GDIPlus_Shutdown()
            Exit
    EndSwitch

    If TimerDiff($tmr_loop) > 1000 Then
        _TMR_get_title()
        $tmr_loop = TimerInit()
    EndIf

    Sleep(10)
WEnd

Func _TMR_get_title()
    Local Static $nowplaying_old

    $nowplaying = _Get_NowPlaying()

    If $nowplaying = "0" Then
        $nowplaying = ""
    EndIf

    If $strip_extra Then
        $nowplaying = StringRegExpReplace($nowplaying, "\([^)]*\)|\[[^)]*\]", "", 0); strip everything between ( ) and [ ]
        $nowplaying = StringStripWS($nowplaying, 3); strip leading and trealing whitespace

        Local $array_strip = StringRegExp($nowplaying, "(.*?\s-\s.*?)\s-\s.*", $STR_REGEXPARRAYGLOBALMATCH, 1); strip everything after the second dash character
        If Not @error Then
            $nowplaying = $array_strip[0]
        EndIf
    EndIf

    If $nowplaying <> $nowplaying_old Then
        TraySetToolTip($program_name & " " & $program_version & @CRLF & @CRLF & $nowplaying)

        ConsoleWrite($nowplaying & @CRLF)

        _Infobar_set_text($h_win_infobar)
        $nowplaying_old = $nowplaying
    EndIf
    _Infobar_Calc_Position($h_win_infobar)
    WinSetOnTop($h_win_infobar, "", 1)
EndFunc

Func _Get_NowPlaying()
    Local $aWinLis

    For $i = 0 To 15
        $aWinList = WinList("[Class:Chrome_WidgetWin_0; INSTANCE:" & $i & "]")
        If UBound($aWinList) > 1 Then
            If $aWinList[1][0] > "" Then
                Return $aWinList[1][0]
                ExitLoop
            EndIf
        EndIf
    Next
EndFunc

Func _Infobar_start()
    $Hbitmap_controls = _GDIPlus_BitmapCreateFromScan0(800, 25)
    $hGraphic_object_controls = _GDIPlus_ImageGetGraphicsContext($Hbitmap_controls)

    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic_object_controls, 4)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic_object_controls, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)

    Local $fullscreencontrolgui = GUICreate("", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW))

    _SetBitmap($fullscreencontrolgui, $Hbitmap_controls, 255, 1000, 25)
    GUISetState(@SW_SHOW, $fullscreencontrolgui)
    WinSetOnTop($fullscreencontrolgui, "", 1)

    Return $fullscreencontrolgui
EndFunc

Func _Infobar_set_text($h_win)
    Local Static $pos_array[2]

    If NOT _Infobar_visible() Then
        $nowplaying = ""
    EndIf

    For $i = 255 To 0 Step -15
        _SetBitmap($h_win, $Hbitmap_controls, $i, $pos_array[0], $pos_array[1])
        Sleep(7)
    Next

    _GDIPlus_GraphicsClear($hGraphic_object_controls, 0x00000000)

    Local $hBrush = _GDIPlus_BrushCreateSolid($text_colour)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 1000, 100)

    _GDIPlus_GraphicsDrawStringEx($hGraphic_object_controls, $nowplaying, $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)

    Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1")
    If Not @error Then
        Local $a_info = _StringSize($nowplaying, 12, 600, 0, "Segoe UI")

        $pos_array[0] = $a_info[2]
        $pos_array[1] = $a_info[3]

        WinMove($h_win, "", ($a_pos[0] - $a_info[2]) - 10, @DesktopHeight - ($a_pos[3] / 2) - 12, $a_info[2] + 20, $a_info[3])

        For $i = 0 To 255 Step 15
            _SetBitmap($h_win, $Hbitmap_controls, $i, $a_info[2], $a_info[3])
            Sleep(7)
        Next

        _SetBitmap($h_win, $Hbitmap_controls, 255, $a_info[2], $a_info[3])

        _Infobar_Calc_Position($h_win_infobar)
    EndIf
EndFunc

Func _Infobar_Calc_Position($h_win)
    Local Static $nowplaying_len, $start_cord_check_old

    If NOT _Infobar_visible() Then
        $nowplaying = ""
    EndIf

    Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1")
    If Not @error Then
        Local $a_info = _StringSize($nowplaying, 12, 600, 0, "Segoe UI")

        If Stringlen($nowplaying) <> $nowplaying_len Then
            _SetBitmap($h_win, $Hbitmap_controls, 255, $a_info[2] + 20, $a_info[3])
            $nowplaying_len = Stringlen($nowplaying)
        EndIf
        Local $start_cord_check = ($a_pos[0] - $a_info[2]) - 10
        If ($a_pos[0] - $a_info[2]) - 15 <> $start_cord_check_old Then
            WinMove($h_win, "", $start_cord_check, (@DesktopHeight - ($a_pos[3] / 2)) - 12, $a_info[2] + 20, $a_info[3])
            $start_cord_check_old = $start_cord_check
        EndIf
    EndIf
EndFunc

Func _Infobar_visible()
    If WinActive("[CLASS:WorkerW]") Or WinActive("[CLASS:Progman]") Then
        Return True
    Else
        Local $aPos = WinGetPos("[ACTIVE]")
        If Not @error Then
            If IsArray($aPos) Then
                If UBound($aPos) < 5 Then
                    If $aPos[2] >= @DesktopWidth And $aPos[3] >= @DesktopHeight Then
                        Return False
                    Else
                        Return True
                    EndIf
                EndIf
            Else
                Return True
            EndIf
            SetError(1)
        EndIf
    EndIf
EndFunc

Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width = 200, $n_height = 200)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $n_width)
    DllStructSetData($tSize, "Y", $n_height)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc

 

Edited by nend
Link to comment
Share on other sites

  • 3 months later...

Just run the script or compiled to a exe file
You have to run the Spotify Windows app to get it to work, it won't work with the web browser version of Spotify.

I made a update of this program, if there is any interest in the update please let me know and I will update the source code.

Edited by nend
Link to comment
Share on other sites

  • 10 months later...

Hello,

I have just downloaded the Zip file and run the script.

I have not encountered any problem for the moment.

I have a really basic knowledge of coding, is there any way to set the font and or if the text is bold or not?
I find that compared to the other texts on the spot bar, the titles displayed are slightly too thick.

But in any case thank you for this script, very simple and very well done

Link to comment
Share on other sites

This is the latest version I made.
You can change the Font type but you have to change a lot of calculations to make sure everything is on the right spot.
 

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPISysWin.au3>
#include <TrayConstants.au3>
#include <Misc.au3>

Opt("TrayMenuMode", 3)

Global $program_name = "Spotibar"
Global $program_version = "0.2"

Global $hGraphic_object_controls, $Hbitmap_controls, $nowplaying
Global $strip_extra, $tray_toolTip, $Gui_notification, $a_text_size[2]

$list = ProcessList(@ScriptName)
If $list[0][0] > 1 Then
    Exit
EndIf

_GDIPlus_Startup()

TraySetToolTip($program_name & " V" & $program_version)

Local $tray_config_menu = TrayCreateMenu("Config")
Local $tray_config_colour = TrayCreateItem("Text colour", $tray_config_menu)
Local $tray_config_strip = TrayCreateItem("Strip extra information", $tray_config_menu)
Local $tray_screensaver = TrayCreateItem("Keep screen always on", $tray_config_menu)
Local $tray_config_autostart = TrayCreateItem("Auto start with Windows", $tray_config_menu)
TrayCreateItem("")
Local $tray_exit = TrayCreateItem("Exit")

If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "" Or RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip") = "1" Then
    TrayItemSetState($tray_config_strip, $TRAY_CHECKED)
    $strip_extra = True
Else
    TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED)
    $strip_extra = False
EndIf

If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock") = "1" Then
    TrayItemSetState($tray_screensaver, $TRAY_CHECKED)
    DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001)) ; stops screensaver timer
EndIf

If RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour") = "" Then
    Global $text_colour = "0xFF009B00"
Else
    Global $text_colour = "0xFF" & StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour"), 6)
EndIf

RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
If Not @error Then
    TrayItemSetState($tray_config_autostart, $GUI_CHECKED)
EndIf

OnAutoItExitRegister("_Exit_SP")

Local $tmr_loop
Local $h_win_infobar = _Infobar_start()

While 1
    Local $tray = TrayGetMsg()

    Switch $tray
        Case $tray_config_strip
            If BitAND(TrayItemGetState($tray_config_strip), $TRAY_UNCHECKED) Then
                TrayItemSetState($tray_config_strip, $TRAY_CHECKED)
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 1)
                $strip_extra = True
            Else
                TrayItemSetState($tray_config_strip, $TRAY_UNCHECKED)
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Strip", "REG_SZ", 0)
                $strip_extra = False
            EndIf
        Case $tray_config_colour
            TrayItemSetState($tray_config_colour, $TRAY_CHECKED)
            Local $colourinfo = RegRead("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour")
            If $colourinfo = "" Then
                $colourinfo = "0x009B00"
            EndIf
            $colourinfo = _ChooseColor(2, $colourinfo, 2)
            If Not (@error) Then
                If $colourinfo > "" Then
                    RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Text_colour", "REG_SZ", $colourinfo)
                    $text_colour = "0xFF" & StringRight($colourinfo, 6)
                    _Infobar_set_text($h_win_infobar)
                EndIf
            EndIf
            TrayItemSetState($tray_config_colour, $TRAY_UNCHECKED)
        Case $tray_config_autostart
            If BitAND(TrayItemGetState($tray_config_autostart), $TRAY_UNCHECKED) Then
                RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar", "REG_SZ", '"' & @ScriptDir & '\Spotibar.exe"')
                TrayItemSetState($tray_config_autostart, $TRAY_CHECKED)
            Else
                RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Spotibar")
                TrayItemSetState($tray_config_autostart, $TRAY_UNCHECKED)
            EndIf
        Case $tray_screensaver
            If BitAND(TrayItemGetState($tray_screensaver), $TRAY_UNCHECKED) Then
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock", "REG_SZ", 1)
                DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001)) ; stops screensaver timer
                TrayItemSetState($tray_screensaver, $TRAY_CHECKED)
            Else
                RegWrite("HKEY_CURRENT_USER\SOFTWARE\Nend Software\Spotibar\Config", "Screen lock", "REG_SZ", 0)
                DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', 0x80000000) ; start screensaver timer
                TrayItemSetState($tray_screensaver, $TRAY_UNCHECKED)
            EndIf
        Case $tray_exit
            _Exit_SP()
    EndSwitch

    If TimerDiff($tmr_loop) > 1000 Then
        _TMR_get_title()
        $tmr_loop = TimerInit()
    EndIf

    Sleep(10)
WEnd

Func _TMR_get_title()
    Local Static $nowplaying_old

    $nowplaying = _Get_NowPlaying()

    If $nowplaying = "0" Then
        $nowplaying = ""
    EndIf


    $nowplaying = StringReplace($nowplaying, "/", Chr ( 47 ))

    If $strip_extra Then
        $nowplaying = StringRegExpReplace($nowplaying, ":(.*)", "", 0); strips everything after :
        $nowplaying = StringRegExpReplace($nowplaying, "\([^)]*\)|\[[^)]*\]", "", 0); strip everything between ( ) and [ ]
        $nowplaying = StringStripWS($nowplaying, 3); strip leading and trealing whitespace

        Local $array_strip = StringRegExp($nowplaying, "(.*?\s-\s.*?)\s-\s.*", $STR_REGEXPARRAYGLOBALMATCH, 1); strip everything after the second dash character
        If Not @error Then
            $nowplaying = $array_strip[0]
        EndIf
    EndIf

    If $nowplaying <> $nowplaying_old Then
        $tray_toolTip = $nowplaying
        TraySetToolTip($program_name & " V" & $program_version & @CRLF & @CRLF & $nowplaying)

         _Infobar_set_text($h_win_infobar)
        $nowplaying_old = $nowplaying
     EndIf
    _Infobar_Calc_Position($h_win_infobar)
EndFunc

Func _Get_NowPlaying()
    Local $aWinLis

    For $i = 0 To 15
        $aWinList = WinList("[Class:Chrome_WidgetWin_0; INSTANCE:" & $i & "]")
        If UBound($aWinList) > 1 Then
            If $aWinList[1][0] > "" Then
                Return $aWinList[1][0]
                ExitLoop
            EndIf
        EndIf
    Next
EndFunc

#Region Infobar

Func _Infobar_start()
    $Hbitmap_controls = _GDIPlus_BitmapCreateFromScan0(800, 25)
    $hGraphic_object_controls = _GDIPlus_ImageGetGraphicsContext($Hbitmap_controls)

    Local $fullscreencontrolgui = GUICreate("", 0, 0, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW))

    _SetBitmap($fullscreencontrolgui, $Hbitmap_controls, 255, 1000, 25)
    GUISetState(@SW_SHOW, $fullscreencontrolgui)
    WinSetOnTop($fullscreencontrolgui, "", 1)

    Return $fullscreencontrolgui
EndFunc

Func _Infobar_set_text($h_win, $fade = True)
    Local Static $pos_array[2]

    If NOT _Infobar_visible() Then
        $nowplaying = ""
    EndIf

    If $fade Then
        For $i = 255 To 0 Step -15
            _SetBitmap($h_win, $Hbitmap_controls, $i, $pos_array[0] + 10, $pos_array[1])
            Sleep(7)
        Next
    EndIf

    _GDIPlus_GraphicsClear($hGraphic_object_controls, 0x00000000)

    Local $hBrush = _GDIPlus_BrushCreateSolid($text_colour)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)

    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nowplaying, $hFont, $tLayout, $hFormat)
    $a_text_size[0] = Round($aInfo[0].Width, 0)
    $a_text_size[1] = Round($aInfo[0].Height, 0)

    _GDIPlus_GraphicsDrawStringEx($hGraphic_object_controls, $nowplaying, $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_GraphicsDispose($hGraphic)

    Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1")
    If Not @error Then
        $pos_array[0] = $a_text_size[0]
        $pos_array[1] = $a_text_size[1]

        WinMove($h_win, "", ($a_pos[0] - $a_text_size[0]) - 12, @DesktopHeight - ($a_pos[3] / 2) - 12, $a_text_size[0] + 20, $a_text_size[1])

        If $fade Then
            For $i = 0 To 255 Step 15
                _SetBitmap($h_win, $Hbitmap_controls, $i, $a_text_size[0] + 10, $a_text_size[1])
                Sleep(7)
            Next
        EndIf

        _SetBitmap($h_win, $Hbitmap_controls, 255, $a_text_size[0] + 10, $a_text_size[1])
    EndIf
EndFunc

Func _Infobar_Calc_Position($h_win)
    Local Static $nowplaying_change, $start_cord_check_old, $visible_change

    If NOT _Infobar_visible() Then
        $nowplaying = ""
        If $visible_change = True Then
            _Infobar_set_text($h_win, False)
        EndIf
        $visible_change = False
    Else
        If $visible_change = False Then
            _Infobar_set_text($h_win, False)
        EndIf
        $visible_change = True
    EndIf

    Local $a_pos = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "Windows.UI.Composition.DesktopWindowContentBridge1")
    If Not @error Then
        If $nowplaying <> $nowplaying_change Then
            _SetBitmap($h_win, $Hbitmap_controls, 255, $a_text_size[0] + 10, $a_text_size[1])
            $nowplaying_change = $nowplaying
        EndIf
        Local $start_cord_check = ($a_pos[0] - $a_text_size[0]) - 12
        If $start_cord_check <> $start_cord_check_old Then
            WinMove($h_win, "", $start_cord_check, (@DesktopHeight - ($a_pos[3] / 2)) - 12, $a_text_size[0] + 20, $a_text_size[1])
            $start_cord_check_old = $start_cord_check
        EndIf
    EndIf
    WinSetOnTop($h_win_infobar, "", 1)
EndFunc

Func _Infobar_visible()
    If WinActive("[CLASS:WorkerW]") Or WinActive("[CLASS:Progman]") Then
            Return True
    Else
        Local $aPos = WinGetPos("[ACTIVE]")
        If Not @error Then
            If IsArray($aPos) Then
                If UBound($aPos) < 5 Then
                    If $aPos[2] >= @DesktopWidth And $aPos[3] >= @DesktopHeight Then
                        Return False
                    Else
                        Return True
                    EndIf
                EndIf
            Else
                Return True
            EndIf
            SetError(1)
        EndIf
    EndIf
EndFunc

#EndRegion

Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width, $n_height)
    Local $hScrDC = _WinAPI_GetDC(0)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    Local $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    Local $tSize = DllStructCreate($tagSIZE)
    Local $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $n_width)
    DllStructSetData($tSize, "Y", $n_height)
    Local $tSource = DllStructCreate($tagPOINT)
    Local $pSource = DllStructGetPtr($tSource)
    Local $tBlend = DllStructCreate($tagBLENDFUNCTION)
    Local $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc

Func _Exit_SP()
    _GDIPlus_BitmapDispose($Hbitmap_controls)
    _GDIPlus_GraphicsDispose($hGraphic_object_controls)
    _GDIPlus_Shutdown()
    DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', BitOR(0x80000000, 0x00000002, 0x00000001))
    Exit
EndFunc

 

Edited by nend
Link to comment
Share on other sites

  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...