26 lines
1,015 B
Lua
26 lines
1,015 B
Lua
|
|
-- Capture full screen → put PNG into clipboard via PowerShell.
|
|||
|
|
-- One-liner with System.Drawing + System.Windows.Forms.Clipboard.SetImage.
|
|||
|
|
|
|||
|
|
local ps = [[
|
|||
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|||
|
|
Add-Type -AssemblyName System.Drawing
|
|||
|
|
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
|
|||
|
|
$bmp = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
|
|||
|
|
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
|||
|
|
$g.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
|
|||
|
|
[System.Windows.Forms.Clipboard]::SetImage($bmp)
|
|||
|
|
$g.Dispose(); $bmp.Dispose()
|
|||
|
|
]]
|
|||
|
|
|
|||
|
|
local res = jarvis.system.exec(string.format(
|
|||
|
|
'powershell -NoProfile -ExecutionPolicy Bypass -Command "%s"',
|
|||
|
|
ps:gsub('"', '\\"'):gsub("\r?\n", "; ")
|
|||
|
|
))
|
|||
|
|
|
|||
|
|
if not res.success then
|
|||
|
|
jarvis.log("warn", "screenshot to clipboard failed: " .. tostring(res.stderr):sub(1, 200))
|
|||
|
|
return jarvis.cmd.error("Не получилось сделать скриншот.")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return jarvis.cmd.ok("Скриншот в буфере.")
|