Skip to content
⌘ NSIS Forum Archive

Link who opens a text file

9 posts

Sp33dy G0nz4l3s#

Link who opens a text file

Hi,
I've created a custom page. Now I would add a function:

At the bottom is a link "Hier". Is it possible when the user clicks on "Hier" that a text file e.g. "$INSTDIR\Infos\Textfile.txt" opens?

Thanks for your help.
- Marc

Here is a screenshot:
Sp33dy G0nz4l3s#
Oh very easy 🙂

THANKS

Edit:
One question: When I choose the path: C:\... it works perfect but when I use State=$INSTDIR\Infos\Tasten.txt it doesn't work.

Is there a way that it works?
Red Wine#
You may add constants though the directory must exists, you're receiving this error because the $INSTDIR yet is not created since your section would be executed later on InstFiles page 🙂
Sp33dy G0nz4l3s#
I thought this to but this is my sequence:

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Page custom ConfigPage PageLeaveConfig
...

The ConfigPage is the page with the link. So it should work?

Have you an idea what I could trying?
Red Wine#
Let's make it clear, if the $INSTDIR is created and all files are in tact, you need to add this line to the custom ini within the ConfigPage function e.g.
Function ConfigPage
WriteINIStr "$PLUGINSDIR\<ini_file_name>" "field #" "State" "$INSTDIR\Infos\Tasten.txt"

..............
..............
..............
FunctioEnd
Sp33dy G0nz4l3s#
Thanks Red Wine for your help. I've make it now like you've said.

This is the ConfigPage Function Code:

Function ConfigPage
!insertmacro SectionFlagIsSet ${SectionConfig} ${SF_SELECTED} ShowPage SkipPage
ShowPage:

GetDlgItem $R0 $HWNDPARENT 2
EnableWindow $R0 0|1 # 0=hide, 1=show
GetDlgItem $R0 $HWNDPARENT 3
EnableWindow $R0 0|1 # 0=hide, 1=show
!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Legen Sie die Tasten für die Config fest."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "config.ini"

WriteINIStr "$PLUGINSDIR\config.ini" "field 9" "State" "$INSTDIR\Infos\Tasten.txt"

SkipPage:

FunctionEnd

This is the Code from the link in the config.ini:

[Field 9]
Type=Link
Text=Hier
Left=28
Right=42
Top=118
Bottom=126
TxtColor=0x0080FF
State=$INSTDIR\Infos\Tasten.txt

Is this right so? Unfotunately it doesn't work.

Can you say me what's wrong?
Thank you!!
Red Wine#
The wrong is that you first display the page then write to ini.
WriteINIStr "$PLUGINSDIR\config.ini" "field 9" "State" "$INSTDIR\Infos\Tasten.txt"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "config.ini"