需要修改版的插件(支持timer功能):
MUI:InstallOptions.dll
MUI2:nsDialogs.dll
以及system插件,(受api限制)只能运行于2k或者更高的平台之上。
说明:
请在相应目录下建立transparent.ini文件。
/*
<a href="http://www.yhxs3344.net" target="_blank">www.yhxs3344.net</a>
*/
!AddPluginDir .
;--------------------------------
!define MUI2 ;定义UI版本(MUI,MUI2)
!define iTransparentPercent 90 ;定义透明度
Var DIALOG
var iTransparent
var bTransparent
Name "Transparent Example"
SetCompressor /SOLID lzma
InstallDir $ExeDir
OutFile transparent_nsis.exe
!ifdef MUI2
!include MUI2.nsh
Var TIMERID
!else
!include MUI.nsh
;定义INI文件
!define INI $PLUGINSDIRtransparent.ini
!endif
!include LogicLib.nsh
!ifndef GWL_EXSTYLE
!define GWL_EXSTYLE -20
!endif
!ifndef WS_EX_LAYERED
!define WS_EX_LAYERED 0x80000
!endif
!ifndef LWA_ALPHA
!define LWA_ALPHA 2
!endif
!define MUI_CUSTOMFUNCTION_ABORT UserAbort
!ifdef MUI2
Page custom nsDialogsPage
!else
page custom InstallOptionsPage
!endif
!define MUI_PAGE_CUSTOMFUNCTION_SHOW welcome_PageShow
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
;--------------------------------
!insertmacro MUI_LANGUAGE "SimpChinese"
Section -Nil
SectionEnd
Function welcome_PageShow
!ifdef MUI2
Pop $0
nsDialogs::KillTimer /NOUNLOAD $TIMERID
!endif
GetDlgItem $0 $hwndparent 3
ShowWindow $0 0
${if} $bTransparent == 0
${For} $R0 0 $iTransparent
system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i R0, i ${LWA_ALPHA}) .iR1'
sleep 1
${Next}
${endif}
StrCpy $bTransparent 1
FunctionEnd
Function Exit
${ForEach} $R0 $iTransparent 0 - 1
system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i R0, i ${LWA_ALPHA}) .iR1'
sleep 1
${Next}
FunctionEnd
Function UserAbort
Messagebox MB_YESNO|MB_ICONQUESTION "Are Sure you want to cancel?" IDYES +2
Abort
call Exit
FunctionEnd
Function .onInstSuccess
Messagebox MB_OK|MB_ICONINFORMATION "Install Success!"
call Exit
FunctionEnd
Function SetWindowAttrib
${if} $bTransparent == 0
system::call 'user32::GetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}) .iR0'
;messagebox mb_ok $R0
IntOp $R0 $R0 + ${WS_EX_LAYERED}
system::call 'user32::SetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}, i R0) .iR1'
system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i 0, i ${LWA_ALPHA}) .iR2'
Pop $R2
Pop $R1
Pop $R0
${endif}
FunctionEnd
!ifndef MUI2
Function InstallOptionsPage
Call SetWindowAttrib
InstallOptions::initDialog /NOUNLOAD ${INI}
Pop $DIALOG
;如果你想做的更逼真一些,请把它仿成欢迎页面(你的初始页面)一样的
InstallOptions::Show
FunctionEnd
!endif
!ifdef MUI2
Function OnTimer
Pop $0 ;Free Timer id
GetDlgItem $1 $HWNDPARENT 1
SendMessage $1 ${BM_CLICK} 0 1
FunctionEnd
Function nsDialogsPage
Call SetWindowAttrib
nsDialogs::Create /NOUNLOAD 1018
Pop $DIALOG
;如果你想做的更逼真一些,请把它仿成欢迎页面(你的初始页面)一样的
GetFunctionAddress $0 OnTimer
nsDialogs::CreateTimer /NOUNLOAD $0 10
Pop $TIMERID
nsDialogs::Show
FunctionEnd
!endif
Function .OnInit
InitPluginsDir
!ifndef MUI2
File /oname=${INI} "transparent.ini"
!endif
IntOp $iTransparent ${iTransparentPercent} * 255
IntOp $iTransparent $iTransparent / 100
StrCpy $bTransparent 0
FunctionEnd
© 版权声明
THE END
暂无评论内容