NsScreenshot是NSIS获取屏幕快照截图并保存成bmp格式的插件

/*
NsScreenshot是NSIS获取屏幕快照截图并保存成bmp格式的插件
NsScreenshot提供两个方式的截屏操作,一是全屏幕截取,二是截取指定的窗口,比如Push $HWNDPARENT进栈就可以截取当前安装程序的画面.
*/
!AddPluginDir "."
Name "nsScreenshot Test"
OutFile "nsScreenshot Test.exe"
ShowInstDetails show
Section "Make Screenshot"
 DetailPrint "nsScreenshot example by Leon Zandman"
 DetailPrint "------------------------------------"
 ; ----------- Full-screen screenshot ----------------
 ; Put filename of screenshot onto stack
 StrCpy $0 "$EXEDIRFullscreen_Screenshot.bmp"
 Push $0
; Capture full screen
 nsScreenshot::Grab_FullScreen
 ; $1 contains "ok" if the screenshot was taken
 ; $1 contains "error" if something went wrong
 Pop $1
 StrCmp $1 "ok" ok1 0
 DetailPrint "FullScreen screenshot error"
 Goto next1
ok1:
 ; Pop image dimensions from stack (only available when plugin returned "ok")
 Pop $R1
 Pop $R2
 DetailPrint "Fullscreen screenshot saved as: $0"
 DetailPrint " Dimensions: ($R1x$R2)"
next1:
 ; ----------- NSIS window screenshot ----------------
 ; Put window handle of NSIS screen onto stack
 Push $HWNDPARENT
 ; Put filename of screenshot onto stack
 StrCpy $0 "$EXEDIRNSIS_Screenshot.bmp"
 Push $0
 ; Capture NSIS window
 nsScreenshot::Grab
 Pop $1
 ; $1 contains "ok" if the screenshot was taken
 ; $1 contains "error" if something went wrong
 StrCmp $1 "ok" ok2 0
 DetailPrint "NSIS screenshot error"
 Goto next2
ok2:
 ; Pop image dimensions from stack (only available when plugin returned "ok")
 Pop $R1
 Pop $R2
 DetailPrint "NSIS screenshot saved as: $0"
 DetailPrint " Dimensions: ($R1x$R2)"
next2:
 ; ----------- Taskbar screenshot ----------------
 ; Put window handle of taskbar window onto stack
 FindWindow $R0 "Shell_TrayWnd"
 Push $R0
 ; Put filename of screenshot onto stack
 StrCpy $0 "$EXEDIRTaskbar_Screenshot.bmp"
 Push $0
; Capture Taskbar window
nsScreenshot::Grab
 Pop $1
 ; $1 contains "ok" if the screenshot was taken
 ; $1 contains "error" if something went wrong
 StrCmp $1 "ok" ok3 0
 DetailPrint "System Tray screenshot error"
 Goto next3
ok3:
 ; Pop image dimensions from stack (only available when plugin returned "ok")
 Pop $R1
 Pop $R2
 DetailPrint "Taskbar screenshot saved as: $0"
 DetailPrint " Dimensions: ($R1x$R2)"
next3:
 ; ----------- Tray screenshot ----------------
 ; Put window handle of taskbar window onto stack
 ; Notice the second call to FindWindow, needed because it's a child window
 FindWindow $R0 "Shell_TrayWnd"
 FindWindow $R0 "TrayNotifyWnd" "" $R0
 Push $R0
 ; Put filename of screenshot onto stack
 StrCpy $0 "$EXEDIRTray_Screenshot.bmp"
 Push $0
; Capture Taskbar window
nsScreenshot::Grab
 Pop $1
 ; $1 contains "ok" if the screenshot was taken
 ; $1 contains "error" if something went wrong
 StrCmp $1 "ok" ok4 0
 DetailPrint "Tray screenshot error"
 Goto next4
ok4:
 ; Pop image dimensions from stack (only available when plugin returned "ok")
 Pop $R1
 Pop $R2
 DetailPrint "Tray screenshot saved as: $0"
 DetailPrint " Dimensions: ($R1x$R2)"
next4:
SectionEnd
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容