Hi guys
I need to launch notepad.exe with a target file by pushing a button. It should look something like this I think:
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" "Field 19" "State" \
"notepad C:\windows\dmcl.ini"
or
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" "Field 19" "State" \
"notepad 'C:\windows\dmcl.ini'"
or
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" "Field 19" "State" \
"notepad $\"C:\windows\dmcl.ini$\""
or
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" "Field 19" "State" \
"notepad|C:\windows\dmcl.ini"
or
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" "Field 19" "State" \
"notepad,C:\windows\dmcl.ini"
Etc. Those are many ways of not doing it, is there a way TO do it? 🙂
Rob
How do I get a button to launch something useful? (Includes ways of how not to...)
11 posts
none of them will work, you're right 🙂
first, the button must have the NOTIFY flag.
Flags=NOTIFY|<other flags if you have some>
then, search the forums, the archive and the install options readme, there's sample-code there how to check for the button beeing pressed and execute script code then.
first, the button must have the NOTIFY flag.
Flags=NOTIFY|<other flags if you have some>
then, search the forums, the archive and the install options readme, there's sample-code there how to check for the button beeing pressed and execute script code then.
Yep. You need Flags=NOTIFY for your button.
Then, in your Custom page's Leave function you need to do this:
ReadINIStr $R0 "ioFile.ini" "Settings" "State"
StrCmp $R0 2 0 +3 ; 2 is Button Field num
ExecShell "open" "file.ini"
Abort ; go back to page
-Stu
Then, in your Custom page's Leave function you need to do this:
ReadINIStr $R0 "ioFile.ini" "Settings" "State"
StrCmp $R0 2 0 +3 ; 2 is Button Field num
ExecShell "open" "file.ini"
Abort ; go back to page
-Stu
OK cool thanks for the help so far guys, I was looking at NOTIFY not sure what to do with it 🙂
To make things a bit clearer, the ini file is detectenv.ini; the button is Field number 19.
The button starts off as Flags=READONLY; this is changed if the file I want to open with Notepad is detected.
So:
; Defined in the MUI section:
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "detectenv-Leave"
!insertmacro MUI_PAGE_DETECTENV
Function "detectenv"
...
; if file is detected at C:\Windows\dmcl.ini
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" \
"Field 19" "Flags" "NOTIFY"
...
FunctionEnd
Function "detectenv-Leave"
ReadINIStr $R0 "detectenv.ini" "Settings" "State"
StrCmp $R0 19 0 +3 ; 2 is Button Field num CHANGED TO 19
ExecShell "open" "C:\windows\dmcl.ini"
Abort ; go back to page
FunctionEnd
Does that look roughly right? It doesn't work straight off the bat but I will play...
And cheers again for help so far
-rob-
To make things a bit clearer, the ini file is detectenv.ini; the button is Field number 19.
The button starts off as Flags=READONLY; this is changed if the file I want to open with Notepad is detected.
So:
; Defined in the MUI section:
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "detectenv-Leave"
!insertmacro MUI_PAGE_DETECTENV
Function "detectenv"
...
; if file is detected at C:\Windows\dmcl.ini
!insertmacro MUI_INSTALLOPTIONS_WRITE "detectenv.ini" \
"Field 19" "Flags" "NOTIFY"
...
FunctionEnd
Function "detectenv-Leave"
ReadINIStr $R0 "detectenv.ini" "Settings" "State"
StrCmp $R0 19 0 +3 ; 2 is Button Field num CHANGED TO 19
ExecShell "open" "C:\windows\dmcl.ini"
Abort ; go back to page
FunctionEnd
Does that look roughly right? It doesn't work straight off the bat but I will play...
And cheers again for help so far
-rob-
Also it flicks to the next screen in the installer when I click the button, any chance of not making it do that? (Simply removing the Abort command does the obvious thing of quitting the installer 🙂
What's !insertmacro MUI_PAGE_DETECTENV? Have you created the macro yourself? If not then just use:
Page Custom detectenv detectenv-Leave
-Stu
Page Custom detectenv detectenv-Leave
-Stu
Ah yeah, makes sense, forgot I'd done that 🙂
Just used a macro there to make the MUI code look a bit tidier and more consistent.
Just used a macro there to make the MUI code look a bit tidier and more consistent.
Any help regarding my other questions would be great as it still isn't working and I could take all day randomly trying each combination 😛
Incidentally chucking a 'MessageBox MB_OK $R0' in after ' ReadINIStr $R0 "detectenv.ini" "Settings" "State"' shows that $R0 is set to nothing...
You should specify the full path to detectenv.ini.
e.g. "$PLUGINSDIR\detectenv.ini"
-Stu
e.g. "$PLUGINSDIR\detectenv.ini"
-Stu
Works perfectly now, thanks so much guys.