Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- Basic Web Browser screensaver in PowerShell
- that closes when mouse is moved
- you need to start power shell like this:
- PowerShell -ExecutionPolicy Bypass -STA
- #>
- #$URL = "http://filmsbykris.com"
- [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
- [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
- $oY = ([System.Windows.Forms.Cursor]::Position.Y )#original Mouse Y
- $oX = ([System.Windows.Forms.Cursor]::Position.X )#original Mouse X
- function watch_mouse(){
- $mY = ([System.Windows.Forms.Cursor]::Position.Y )#Mouse Y
- $mX = ([System.Windows.Forms.Cursor]::Position.X )#Mouse X
- #Write-Host $mX,$mY
- #if mouse is moved
- if($oX -ne $mX)
- {
- Write-Host "Mouse Moved on X!"
- $Form.close()
- }
- }
- function GUI(){
- $Form = New-Object System.Windows.Forms.Form
- $Form.FormBorderStyle = "None"
- $Form.Text = "www.FilmsByKris.com"
- $Form.Size = New-Object System.Drawing.Size(800,600)
- $Form.StartPosition = "CenterScreen"
- $Form.WindowState= "Maximized"
- #$Form.AutoSize = $True
- #$Form.AutoSizeMode = "GrowAndShrink"
- # Main Browser
- $webBrowser = New-Object System.Windows.Forms.WebBrowser
- $webBrowser.IsWebBrowserContextMenuEnabled = $true
- $webBrowser.ScrollBarsEnabled = $false
- $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>'
- #$webBrowser.Document.Open()
- $webBrowser.Navigate("about:blank");
- $webBrowser.Document.Write($html_code)
- #$webBrowser.Document.Close()
- #$webBrowser.URL = $URL
- $webBrowser.Width = 800
- $webBrowser.Height = 600
- $webBrowser.Location = "0, 0"
- $webBrowser.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor
- [System.Windows.Forms.AnchorStyles]::Right -bor
- [System.Windows.Forms.AnchorStyles]::Top -bor
- [System.Windows.Forms.AnchorStyles]::Left
- $Form.Controls.Add($webBrowser)
- # Display Form
- [void] $Form.ShowDialog()
- }
- $timer = New-Object System.Windows.Forms.Timer
- $timer.Interval = 500
- $timer.add_Tick({watch_mouse})
- $timer.Enabled = $true
- $timer.Start()
- GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement