Archive: Script not working...


Script not working...


; OpenFileName defenition
!define stOPENFILENAME '(&l4, i, i 0, i, i 0, i 0, i 0, t, i \
${NSIS_MAX_STRLEN}, t, i ${NSIS_MAX_STRLEN}, t, t, i, \
&i2, &i2, t, i 0, i 0, i 0) i'

; Prepare filter sting
System::Call '*(&t19 "Zip files", &t6 "*.zip", &t16 \
"Zip files", &t4 "*.zip", &i1 0) i.r0'
; Prepare OpenFileName structure with other options
System::Call '*${stOPENFILENAME}(, $HWNDPARENT,, r0,,,,"",,"",, \
i 0, "Select zip file to install", 0xA01800,,,,,,) .r1'

; OpenFileName Dialog
System::Call 'comdlg32::GetOpenFileNameA(i r1) i .r2'
; You could check r2 for zero value - this will indicate
; the user pressed the cancel button

; Retrieve selected file path
System::Call '*$1${stOPENFILENAME}(,,,,,,,.r3)'
; just a demo
MessageBox MB_OK 'Result $2, Filename "$3"'

; Free used memory
System::Free $1
System::Free $0


This is a script that brainsucker made for me, but it isn't working quite right.
The "*.zip" bit that is meant to show only zip files is not working - *.* show instead.

Can anyone fix this for me?

Thanks

-Stu

Have you considered using InstallOptions2 with a FileRequest control using a filter to restrict the FileOpen window to only showing Zip files ("Filter=ZIP Files|*.zip") ?


The whole perpose of this script is to open the dialog in a Section.

-Stu


Sorry my answer was of no use to you: your original message did not mention how the script fragment was being used.


Try replacing:

System::Call '*(&t19 "Zip files", &t6 "*.zip", &t16 "Zip files", &t4 "*.zip", &i1 0) i.r0'


with:

System::Call '*(&t10 "Zip files", &t6 "*.zip", &t10 "Zip files", &t6 "*.zip", &i1 0) i.r0'

Notice that I have changed the number after every &t to match the number of the characters in the string + 1.

If that doesn't work try removing the second pair of "Zip files", "*.zip". Maybe Windows doesn't like it when you specify the same thing twice.


I put it in twice because the first pair didn't do anything (original script).

I will check this new one out, thanks.

-Stu


I have made a function out of this, which can be found here:
http://nsis.sourceforge.net/archive/...ances=0,11,211

I have allowed users to Push different Flags for use, but I'm not sure what the different flags need to be seperated with.

Anyone know?

Thanks

-Stu


Now, here is the DirRequest function by brainsucker:


Function DirRequest
System::Store "s r8r9"

; Get callback
System::Get '(i.s, i.s, i.s, i.s) i ss'
pop $0

; BrowseInfo structure
System::Call '*(i $HWNDPARENT, i 0, t "", t r9, i 0x45, k r0, i, i) i.r1'
System::Call 'shell32::SHBrowseForFolderA(i r1) i.s'
ShBrowse:
Pop $2
StrCmp $2 "callback1" 0 ExitBrowse

System::Store "s r3r4r5r6"
; BFMM_INITIALIZED ?
IntCmp $4 1 0 exit exit
; yes, set the starting dir
System::Call 'user32::SendMessageA(i $3, i 1126, i 1, t r8) i'
System::Store "r2r3r4r5r6"
System::Call "$0" 0
exit:
; Restore
System::Store "l"
System::Call "$0" 0
Goto ShBrowse

ExitBrowse:
; free used resources
System::Free $0
System::Free $1

; now we should determine folder name from given PIDL
System::Call 'shell32::SHGetPathFromIDListA(i $2, t "" r3)'

; IMalloc->Free work
; Get the pointer to interface
System::Call 'shell32::SHGetMalloc(*i . r4)'
; Get the pointer to interface VTABLE
System::Call '*$4(i.r7)'
; Get the pointer to IMalloc->Free
System::Call '*$7(&t20, i.r5)'
; Call Free method
System::Call '::$5(i r2)'

System::Store "p3 l"
FunctionEnd


The line...
System::Call 'shell32::SHBrowseForFolderA(i r1) i.s'
...crashes the installer everytime.

-Stu

Afrow UK: have you solved you problem with dirrequest?
updated versions included. BrowseForFolderNew - no startup folder.
Source - attached. You'll probably need updated exehead to use them.
Use:

push "Select folder Demo"
push "d:\Program files" ; startup folder
call BrowseForFolder
pop $0
MessageBox MB_OK "Selected folder '$0'"

push "Select folder Demo small"
call BrowseForFolderNew
pop $0
MessageBox MB_OK "Selected folder '$0'"


The new script also crashes; after clicking OK after selecting the folder.
This happens on my Windows XP system, not sure about Windows 98 (not able to test).

-Stu


Ok, I'll need latest CVS first...

Thanks

-Stu


Sorry Afrow. I don't think the latest CVS will help. No one of NSIS developers updated NSIS exehead code yet (as I know). If it will became critical for you I can send you updated makensis compiled from latest CVS and my changes.


One heck of an old thread - perhaps FileRequest doesn't work under XP? Not sure.

Basically I was hoping to make use of this function to pop up a file browsing dialog that would show hidden files/folders. (DialogsEx doesn't support it - d'oh) But even the sample code in the WiKi seems to do zilch and returns a null value.

I get the following values for the usual variables just before the function starts popping the originals:


$0 = <null>
$1 = 1430240
$2 = error
$3 = <null>
$4 = (&l4, i, i 0, i, i 0, i 0, i 0, t, i 1024, t, i 1024, t, t, i, &i2, &i2, t, i 0, i 0, i 0) i
$5 = Zip Files (*.zip)
$6 = *.zip
$7 = All Files (*.*)
$8 = *.*
$9 = Select Zip file to install

$R0 = 18
$R1 = 6
$R2 = 16
$R3 = 4
$R4 = open
$R5 = 0xA01800
$R6 = <null>
$R7 = <null>
$R8 = <null>
$R9 = <null>


Any clues or "oops - silly us, change 'this' to 'that'" would be appreciated.

nevermind - the first thing I tried was getting rid of the $R4 in the call to comdlg32 and, out of habit more than anything, spelled it "GetOpenFileName". Immediately, things worked.

Then I thought "well why wouldn't that $R4 insert?" before I realized that it did. Except it inserted "open" and thus the call was "GetopenFileName".

Oops? :P

I'll adjust the wiki in a moment.


Only to hit the next problem - it's not showing me the hidden files/folders. :(

I tried passing...


Push "0xA01800,0x10000000"

and

Push "0x10000000"


Neither worked. Am I missing something else?

Edit:

I also tried the flag "0x00000200" for multi-select, and it fails to work if passed as:

Push "0xA01800,0x00000200"


but works when using:


Push "0x00000200"


So double-checked with the hidden files one - but still no luck.

I believe that the flags should be OR'ed together, not listed with commas between them: 0x10A01800. (And for multiselect, 0xA01A00). My commdlg.h file (From Visual C++, 6.0) doesn't show a flag for hidden files, are you sure the 0x10000000 is correct?

When I open a dialog for files with my editor (Crimson Editor) or with Firefox, it automatically includes hidden files. I can see 'thumbs.db' which has 'HSA' attributes. Did you try changing the dialog view type to 'detail' and adding the attribute column to the view? (right click on the detail view column header and select the columns you want).

Don


Originally posted by demiller9
I believe that the flags should be OR'ed together, not listed with commas between them: 0x10A01800.
I had tried that as well, to no avail.

Originally posted by demiller9 My commdlg.h file (From Visual C++, 6.0) doesn't show a flag for hidden files, are you sure the 0x10000000 is correct?[/B]
As sure as I can be.. The flags are listed in the WiKi page on this. A quick Google search I had done at the time just in case that hex code was incorrect seemed to confirm it should be fine (MSDN lists it at... http://msdn2.microsoft.com/en-us/library/ms646839.aspx )

Originally posted by demiller9
When I open a dialog for files with my editor (Crimson Editor) or with Firefox, it automatically includes hidden files.
Are you sure that is not because you have explorer set to show hidden folders/files by default?
FireFox 1.5 isn't showing me the hidden file either. Perhaps its location is important..
c:\documents and settings\myUsername\My Documents\somefile.jpg

somefile.jpg as the attributes: archive, hidden

Originally posted by demiller9
Did you try changing the dialog view type to 'detail' and adding the attribute column to the view?
Yeah, that does nothing either. That just changes how things are displayed, not what files are displayed, I'm afraid.