Skip to content
Snippets Groups Projects

setWal.ps1

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Matěj Smyčka
    Edited
    setWal.ps1 2.35 KiB
    Function Set-WallPaper {
     
    param (
        [parameter(Mandatory=$True)]
        # Provide path to image
        [string]$Image,
        # Provide wallpaper style that you would like applied
        [parameter(Mandatory=$False)]
        [ValidateSet('Fill', 'Fit', 'Stretch', 'Tile', 'Center', 'Span')]
        [string]$Style
    )
     
    $WallpaperStyle = Switch ($Style) {
      
        "Fill" {"10"}
        "Fit" {"6"}
        "Stretch" {"2"}
        "Tile" {"0"}
        "Center" {"0"}
        "Span" {"22"}
      
    }
     
    If($Style -eq "Tile") {
     
        New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force
        New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 1 -Force
     
    }
    Else {
     
        New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force
        New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 0 -Force
     
    }
     
    Add-Type -TypeDefinition @" 
    using System; 
    using System.Runtime.InteropServices;
      
    public class Params
    { 
        [DllImport("User32.dll",CharSet=CharSet.Unicode)] 
        public static extern int SystemParametersInfo (Int32 uAction, 
                                                       Int32 uParam, 
                                                       String lpvParam, 
                                                       Int32 fuWinIni);
    }
    "@ 
      
        $SPI_SETDESKWALLPAPER = 0x0014
        $UpdateIniFile = 0x01
        $SendChangeEvent = 0x02
      
        $fWinIni = $UpdateIniFile -bor $SendChangeEvent
      
        $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
    }
    $d = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Desktop)
    cd $d
    $url = "https://i.imgflip.com/84hf2w.jpg"
    $outputPath = "wallpaper.jpg"
    Invoke-WebRequest -Uri $url -OutFile $outputPath
    Set-WallPaper -Image $pwd"\wallpaper.jpg" -Style fit
    
    $outputPath2 = "beruska.mp4"
    $url2 = "https://i.imgur.com/oiEEkl1.mp4"
    
    Invoke-WebRequest -Uri $url2 -OutFile $outputPath2
    
    $numberOfOpens = 100
    Function Set-Speaker($Volume){$wshShell = new-object -com wscript.shell;1..50 | % {$wshShell.SendKeys([char]174)};1..$Volume | % {$wshShell.SendKeys([char]175)}}
    Set-Speaker -Volume 100
    for ($i = 1; $i -le $numberOfOpens; $i++) {
        Start-Process $outputPath2 -WindowStyle Maximized
    }
    
    Write-Host "Video opened $numberOfOpens times."
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment