Advertisement
metalx1000

Basic Web Screen Saver

Jul 7th, 2014
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Basic Web Browser screensaver in PowerShell
  3. that closes when mouse is moved
  4. you need to start power shell like this:
  5. PowerShell -ExecutionPolicy Bypass -STA
  6. #>
  7.  
  8. #$URL = "http://filmsbykris.com"   
  9.  
  10. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  11. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  12.  
  13. $oY = ([System.Windows.Forms.Cursor]::Position.Y )#original Mouse Y
  14. $oX = ([System.Windows.Forms.Cursor]::Position.X )#original Mouse X
  15.  
  16. function watch_mouse(){
  17.  
  18.     $mY = ([System.Windows.Forms.Cursor]::Position.Y )#Mouse Y
  19.     $mX = ([System.Windows.Forms.Cursor]::Position.X )#Mouse X
  20.     #Write-Host $mX,$mY    
  21.    
  22.     #if mouse is moved
  23.     if($oX -ne $mX)
  24.     {
  25.        Write-Host "Mouse Moved on X!"
  26.        $Form.close()   
  27.     }
  28.          
  29. }
  30.  
  31. function GUI(){
  32.    
  33.     $Form = New-Object System.Windows.Forms.Form
  34.     $Form.FormBorderStyle = "None"
  35.     $Form.Text = "www.FilmsByKris.com"
  36.     $Form.Size = New-Object System.Drawing.Size(800,600)
  37.     $Form.StartPosition = "CenterScreen"
  38.     $Form.WindowState= "Maximized"
  39.    
  40.     #$Form.AutoSize = $True
  41.     #$Form.AutoSizeMode = "GrowAndShrink"
  42.    
  43.    
  44.     # Main Browser
  45.     $webBrowser = New-Object System.Windows.Forms.WebBrowser
  46.     $webBrowser.IsWebBrowserContextMenuEnabled = $true
  47.     $webBrowser.ScrollBarsEnabled = $false
  48.  
  49.     $html_code='<style>img, body, html {        width: 100%;        height: 100%;        padding: 0;        margin: 0;        overflow: hidden;}</style><body>  <img src="http://www.changethethought.com/wp-content/tumblr_lad3eouzez1qzt4vjo1_500.gif">   </body>'
  50.     #$webBrowser.Document.Open()
  51.     $webBrowser.Navigate("about:blank");
  52.     $webBrowser.Document.Write($html_code)
  53.     #$webBrowser.Document.Close()    
  54.    
  55.    
  56.     #$webBrowser.URL = $URL
  57.     $webBrowser.Width = 800
  58.     $webBrowser.Height = 600
  59.     $webBrowser.Location = "0, 0"
  60.     $webBrowser.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor
  61.         [System.Windows.Forms.AnchorStyles]::Right -bor
  62.         [System.Windows.Forms.AnchorStyles]::Top -bor
  63.         [System.Windows.Forms.AnchorStyles]::Left
  64.     $Form.Controls.Add($webBrowser)
  65.    
  66.     # Display Form
  67.     [void] $Form.ShowDialog()
  68. }
  69.            
  70. $timer = New-Object System.Windows.Forms.Timer
  71. $timer.Interval = 500
  72.  
  73. $timer.add_Tick({watch_mouse})
  74.  
  75. $timer.Enabled = $true
  76. $timer.Start()
  77.  
  78. GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement