Board logo

标题: [转载代码] [PowerShell每日技巧]“锁定”屏幕(禁止鼠标点击)(20131212) [打印本页]

作者: DAIC    时间: 2013-12-23 11:30     标题: [PowerShell每日技巧]“锁定”屏幕(禁止鼠标点击)(20131212)

With WPF, PowerShell can create windows in just a couple of lines of code. Here's a funny example of a transparent screen overlay.

You can call Lock-Screen and submit a script block and a title. PowerShell will then lock the screen with its overlay, execute the code and remove the lock screen again.
  1. function Lock-Screen([ScriptBlock] $Payload={Start-Sleep -Seconds 5}, $Title='Busy, go away.')
  2. {
  3.     try
  4.     {
  5.       $window = New-Object Windows.Window
  6.       $label = New-Object Windows.Controls.Label
  7.       $label.Content = $Title
  8.       $label.FontSize = 60
  9.       $label.FontFamily = 'Consolas'
  10.       $label.Background = 'Transparent'
  11.       $label.Foreground = 'Red'
  12.       $label.HorizontalAlignment = 'Center'
  13.       $label.VerticalAlignment = 'Center'
  14.       $Window.AllowsTransparency = $True
  15.       $Window.Opacity = .7
  16.       $window.WindowStyle = 'None'
  17.       $window.Content = $label
  18.       $window.Left = $window.Top = 0
  19.       $window.WindowState = 'Maximized'
  20.       $window.Topmost = $true
  21.       $null = $window.Show()
  22.       Invoke-Command -ScriptBlock $Payload
  23.     }
  24.     finally { $window.Close() }
  25. }
  26. $job =
  27. {
  28.   Get-ChildItem c:\windows -Recurse -ErrorAction SilentlyContinue
  29. }
  30. Lock-Screen -Payload $job -Title 'I am busy, go away and grab a coffee...'
复制代码
As you will soon discover, the look screen does protect against mouse clicks, but it won't shield the keyboard. It's just a fun technique, no security lock.

http://powershell.com/cs/blogs/tips/archive/2013/12/12/use-a-lock-screen.aspx




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2