标题: [转载代码] [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.- function Lock-Screen([ScriptBlock] $Payload={Start-Sleep -Seconds 5}, $Title='Busy, go away.')
- {
- try
- {
- $window = New-Object Windows.Window
- $label = New-Object Windows.Controls.Label
-
- $label.Content = $Title
- $label.FontSize = 60
- $label.FontFamily = 'Consolas'
- $label.Background = 'Transparent'
- $label.Foreground = 'Red'
- $label.HorizontalAlignment = 'Center'
- $label.VerticalAlignment = 'Center'
-
- $Window.AllowsTransparency = $True
- $Window.Opacity = .7
- $window.WindowStyle = 'None'
- $window.Content = $label
- $window.Left = $window.Top = 0
- $window.WindowState = 'Maximized'
- $window.Topmost = $true
-
- $null = $window.Show()
- Invoke-Command -ScriptBlock $Payload
- }
- finally { $window.Close() }
- }
-
- $job =
- {
- Get-ChildItem c:\windows -Recurse -ErrorAction SilentlyContinue
- }
-
- 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://www.bathome.net/) |
Powered by Discuz! 7.2 |