最新消息:

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

nsis 永恒心锁 1538浏览 0评论
/*
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
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » NsScreenshot是NSIS获取屏幕快照截图并保存成bmp格式的插件

您必须 登录 才能发表评论!