mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
Add Overlay to Taskbaritem (#2196)
* Add taskbaritemoverlay * remove old commented code
This commit is contained in:
parent
0c841f98e8
commit
f6af93afbd
@ -287,19 +287,37 @@ Add-Type @"
|
||||
}
|
||||
}
|
||||
|
||||
# need to experiemnt more
|
||||
# setting icon for the windows is still not working
|
||||
# $pngUrl = "https://christitus.com/images/logo-full.png"
|
||||
# $pngPath = "$env:TEMP\cttlogo.png"
|
||||
# $iconPath = "$env:TEMP\cttlogo.ico"
|
||||
# # Download the PNG file
|
||||
# Invoke-WebRequest -Uri $pngUrl -OutFile $pngPath
|
||||
# if (Test-Path -Path $pngPath) {
|
||||
# ConvertTo-Icon -bitmapPath $pngPath -iconPath $iconPath
|
||||
# }
|
||||
# $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($iconPath)
|
||||
# Write-Host $icon.Handle
|
||||
# [Window]::SendMessage($windowHandle, 0x80, [IntPtr]::Zero, $icon.Handle)
|
||||
|
||||
# Using a TaskbarItem Overlay until someone figures out how to replace the icon correctly
|
||||
|
||||
# URL of the image
|
||||
$imageUrl = "https://christitus.com/images/logo-full.png"
|
||||
|
||||
# Download the image
|
||||
$imagePath = "$env:TEMP\logo-full.png"
|
||||
Invoke-WebRequest -Uri $imageUrl -OutFile $imagePath
|
||||
|
||||
# Read the image file as a byte array
|
||||
$imageBytes = [System.IO.File]::ReadAllBytes($imagePath)
|
||||
|
||||
# Convert the byte array to a Base64 string
|
||||
$base64String = [System.Convert]::ToBase64String($imageBytes)
|
||||
|
||||
# Create a streaming image by streaming the base64 string to a bitmap streamsource
|
||||
$bitmap = New-Object System.Windows.Media.Imaging.BitmapImage
|
||||
$bitmap.BeginInit()
|
||||
$bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64String)
|
||||
$bitmap.EndInit()
|
||||
$bitmap.Freeze()
|
||||
|
||||
# Ensure TaskbarItemInfo is created if not already
|
||||
if (-not $sync["Form"].TaskbarItemInfo) {
|
||||
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
|
||||
}
|
||||
|
||||
# Set the overlay icon for the taskbar
|
||||
$sync["Form"].TaskbarItemInfo.Overlay = $bitmap
|
||||
|
||||
|
||||
$rect = New-Object RECT
|
||||
[Window]::GetWindowRect($windowHandle, [ref]$rect)
|
||||
|
Loading…
Reference in New Issue
Block a user