; 保存之前确定剪切板中是否有图片(先截图到剪切板) path := A_desktop "\demo.png" MsgBox % path SavePic(path) ; 保存【剪切板】图片到指定位置,当图片width<minW 或者 height<minH时就会缩放图片 ,默认不缩放 SavePic(path, minW:=0, minH:=0, scale:=1, imageType:="Png") { try { ps1= (LTrim ` % Add-Type -AssemblyName System.Windows.Forms; $image = [System.Windows.Forms.Clipboard]::GetImage(); $width = $image.Width; $height = $image.Height; if ($width -lt {2} -or $height -lt {3}) {$width=$width *{4}; $height=$height *{4};}; [System.Drawing.Image+GetThumbnailImageAbort] $callback = { return $false }; $resizedImage=$image.GetThumbnailImage($width, $height, $callback, [System.IntPtr]::Zero); $resizedImage.Save('{1}', [System.Drawing.Imaging.ImageFormat]::{5}); $resizedImage.Dispose(); $image.Dispose(); ) ps1:=Format(ps1,path,minW,minH,scale,imageType) shellExcuter(Format("powershell.exe -Command ""{1}""",ps1)) } catch e { MsgBox % "执行powershell异常:" e.Message() return } return 1 } ;Func 静默执行cmd命令,返回0 就是成功! shellExcuter(str) { return DllCall("shell32\ShellExecute", "uint", 0, "str","open","str", "cmd","str",Format("/c{1}",str), "uint", 0, "int", 0) }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)