Yo,
Puisque fat115 m'a lancé sur le lanceur de PortableSumatraPDF ce matin, je me suis mis en tête d'en refaire un lanceur. Puis ne connoissant pas la langage de NSIS, ça a relevé plus du défi.
Une nouvelle entrée est dispo dans le fichier ini, qui se présente maintenant de la forme
La clef est peut-être définie dans les fichiers ini, j'avoue n'avoir pas lu la doc.
Le peu de tests que j'ai effectué m'a semblé fonctionner. Je n'ai pas testé le splash screen car je n'ai pas le plugin kivabien.
Le script utilise presque 3 fois moins de lignes que la version originale.
Puisque fat115 m'a lancé sur le lanceur de PortableSumatraPDF ce matin, je me suis mis en tête d'en refaire un lanceur. Puis ne connoissant pas la langage de NSIS, ça a relevé plus du défi.

- Code: Tout sélectionner
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
; PortableSumatraPDF par Mimas
; Utilisant comme profonde inspiration un script de Simon Leblanc qui a utilisé comme base de travail les scripts de John T. Haller, Sarkos et pyg
!include "FileFunc.nsh"
!define APPLANG "Fr"
!define EXECNAME "SumatraPDF.exe"
!define APPNAME "SumatraPDF"
!define PORTABLEAPPNAME "Portable${APPNAME}"
!define FULLNAME "Lecteur de fichier PDF SumatraPDF"
!define VER "0.6.0.0"
!define WEBSITE "http://www.framakey.org"
!define MUTEX_NAME "${APPNAME}_${VER}"
Caption "${PORTABLEAPPNAME} - Enfin un lecteur de PDF libre."
; Var
Var AppDirectory
Var AppExecutable
Var DisableSplashScreen
Var AdditionalParameters
Var ExecString
Var SingleInstance
; Nsis Config
RequestExecutionLevel user
Icon "${PORTABLEAPPNAME}.ico"
OutFile "${PORTABLEAPPNAME}.exe"
LoadLanguageFile "${NSISDIR}\Contrib\Language Files\French.nlf"
; Runtime Switches
SetDateSave on
SetDatablockOptimize on
CRCCheck On
SilentInstall Silent
AutoCloseWindow True
; Launcher exec info
VIProductVersion "${VER}"
VIAddVersionKey FileDescription "${FULLNAME} pour Windows"
VIAddVersionKey LegalCopyright "GPL"
VIAddVersionKey Comments "Permet de lancer ${APPNAME} (${APPLANG}) depuis un disque amovible. Pour plus de détails, visitez ${WEBSITE}"
VIAddVersionKey CompanyName "Framakey"
VIAddVersionKey OriginalFilename "${PORTABLEAPPNAME}.exe"
VIAddVersionKey FileVersion "${VER}"
Section Main
IfFileExists "$EXEDIR\${APPNAME}.ini" 0 _SetDefaultConfig
; On récupère les paramètres du fichier ini.
IfErrors _SetDefaultConfig
ReadINIStr "$AppDirectory" "$EXEDIR\${APPNAME}.ini" "${APPNAME}" "${APPNAME}Directory"
ReadINIStr "$AdditionalParameters" "$EXEDIR\${APPNAME}.ini" "${APPNAME}" "AdditionalParameters"
ReadINIStr "$AppExecutable" "$EXEDIR\${APPNAME}.ini" "${APPNAME}" "${APPNAME}Executable"
ReadINIStr "$SingleInstance" "$EXEDIR\${APPNAME}.ini" "${APPNAME}" "SingleInstance"
ReadINIStr "$DisableSplashScreen" "$EXEDIR\${APPNAME}.ini" "SplashScreen" "DisableSplashScreen"
ClearErrors
Goto _CheckExec
_SetDefaultConfig:
; On récupère les paramètres par défaut.
StrCpy "$AppDirectory" "$EXEDIR\${APPNAME}"
StrCpy "$AdditionalParameters" ""
StrCpy "$AppExecutable" "${EXECNAME}"
StrCpy "$DisableSplashScreen" "false"
StrCpy "$SingleInstance" "false"
_CheckExec:
IfFileExists "$AppDirectory\${EXECNAME}" _CheckInstance
MessageBox MB_OK|MB_ICONEXCLAMATION `$AppExecutable est introuvable. Vérifiez votre configuration`
Abort
_CheckInstance:
; Prévenir plusieurs Instances
; Sources : http://www.veekee.net/wikinsis/docs/AppendiceC.html#C.11
StrCmp "$SingleInstance" "true" 0 _CheckSplash
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${MUTEX_NAME}") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "${EXECNAME} est déjà lancé."
Abort
_CheckSplash:
StrCmp $DisableSplashScreen "true" _CheckParams
InitPluginsDir
File /oname=$PLUGINSDIR\splash.jpg "${PORTABLEAPPNAME}_splash.jpg"
newadvsplash::show /NOUNLOAD 3000 200 200 -1 /L $PLUGINSDIR\splash.jpg
_CheckParams:
${GetParameters} $R0
StrCmp "$R0" "" _WithoutParams
StrCpy "$ExecString" `"$AppDirectory\$AppExecutable" $R0`
Goto _CheckAdditionalParams
_WithoutParams:
StrCpy "$ExecString" `"$AppDirectory\$AppExecutable"`
_CheckAdditionalParams:
StrCmp $AdditionalParameters "" _LaunchIt
StrCpy $ExecString `$ExecString $AdditionalParameters`
_LaunchIt:
;MessageBox MB_OK "$ExecString"
ExecWait "$ExecString"
SectionEnd
Une nouvelle entrée est dispo dans le fichier ini, qui se présente maintenant de la forme
- Code: Tout sélectionner
[SumatraPDF]
AdditionalParameters=-bgcolor 0xB3CCFF
SumatraPDFDirectory=SumatraPDF
SumatraPDFExecutable=SumatraPDF.exe
SingleInstance=true
[SplashScreen]
DisableSplashScreen=false
La clef est peut-être définie dans les fichiers ini, j'avoue n'avoir pas lu la doc.

Le peu de tests que j'ai effectué m'a semblé fonctionner. Je n'ai pas testé le splash screen car je n'ai pas le plugin kivabien.
Le script utilise presque 3 fois moins de lignes que la version originale.
Attentyon, ponaytte maychante !
-
Téthis
- Messages : 3895
- Géo : De passage chez les cathares