notes/Display Webpage Form and close when mouse moves-g3JVwEcv.sh
<#
Basic Web Browser 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.AutoSize = $True
#$Form.AutoSizeMode = "GrowAndShrink"
# Main Browser
$webBrowser = New-Object System.Windows.Forms.WebBrowser
$webBrowser.IsWebBrowserContextMenuEnabled = $true
$webBrowser.ScrollBarsEnabled = $false
$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 = 1000
$timer.add_Tick({watch_mouse})
$timer.Enabled = $true
$timer.Start()
GUI
syntax highlighted by Code2HTML, v. 0.9.1