Browse Help |
Author: |
Message: |
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
O.P. Browse Help
Can someone help me create a file browser button so the people can enter in their file path easily instead of typing it out. I just can't figure it out
Help would be greatly appreciated, thanks
Update: done, check out the mp3 player
Press F5 or /mp3 to get into the mp3 player
Attachment: MP3 Player.plsc (2.68 KB)
This file has been downloaded 304 time(s).
This post was edited on 01-19-2007 at 03:39 AM by WDZ.
|
|
10-15-2006 07:03 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Browse Help
This is the code I used for Screenshot Sender 4
code: function BrowseForFolder(sTitle){
var BrowseInfo = Interop.Allocate(32);
var foldertitle = Interop.Allocate((255+1) * 2);
BrowseInfo.WriteDWORD(8, foldertitle.DataPtr);
var pTitle = Interop.Allocate((sTitle.length+1) * 2);
pTitle.WriteString(0, sTitle, false);
BrowseInfo.WriteDWORD(12, pTitle.DataPtr);
BrowseInfo.WriteDWORD(16, 1);
var pidl = Interop.Call('shell32', 'SHBrowseForFolder', BrowseInfo);
var folderpath = Interop.Allocate((255+1) * 2);
Interop.Call('shell32', 'SHGetPathFromIDList', pidl, folderpath);
return folderpath.ReadString(0, false)+'\\';
}
//Usage
Debug.Trace(BrowseForFolder('Pick a Folder'));
|
|
10-15-2006 09:37 PM |
|
|
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
O.P. RE: Browse Help
thanks, but is there a way to get a specific file like if you were to do a windows live messenger file transfer?
|
|
10-15-2006 10:23 PM |
|
|
deAd
Scripting Contest Winner
Posts: 1060 Reputation: 28
– / /
Joined: Jan 2006
|
RE: Browse Help
That looks like it does...haven't tested it though so maybe not. I think it returns a string with the path you've selected.
|
|
10-15-2006 10:54 PM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: Browse Help
Nah, that one looks for a folder, he doesn't want the folder but the file.
|
|
10-15-2006 11:08 PM |
|
|
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
O.P. RE: Browse Help
Also is there a way to get the file path into the EditControl?
|
|
10-15-2006 11:18 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Browse Help
code: var OFN_ENABLESIZING = 0x800000;
var OFN_EXPLORER = 0x80000;
var OFN_FILEMUSTEXIST = 0x1000;
var OFN_HIDEREADONLY = 0x4;
var OFN_LONGNAMES = 0x200000;
var OFN_PATHMUSTEXIST = 0x800;
var OFN_OVERWRITEPROMPT = 0x00000002;
function BrowseForFile(sTitle){
var OpenFileName = Interop.Allocate(88);
var filter = '*';
var s_filter;
var s_file;
var file = '*.*';
var title;
var s_title;
var ret;
var initdir = 'c:\\';
var s_initdir = Interop.Allocate((initdir.length+1)*2);
s_initdir.WriteString(0, initdir);
with (OpenFileName){
WriteDWORD(0, Size);
s_filter = Interop.Allocate((filter.length+1)*2);
s_filter.WriteString(0, filter);
WriteDWORD(12, s_filter.DataPtr);
WriteDWORD(24, 1);
s_file = Interop.Allocate((255+1)*2);
s_file.WriteString(0, file)
WriteDWORD(28, s_file.DataPtr);
WriteDWORD(32, 255);
var sTmp = Interop.Allocate((254+1)*2);
WriteDWORD(36, sTmp.DataPtr);
WriteDWORD(40, 255);
WriteDWORD(44, s_initdir.DataPtr);
s_title = Interop.Allocate((sTitle.length+1)*2);
WriteDWORD(48, s_title.DataPtr);
WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT);
}
ret = Interop.Call('comdlg32.dll', 'GetSaveFileNameW', OpenFileName);
if (ret != 0) {
return s_file.ReadString(0);
}
}
//Usage
Debug.Trace(BrowseForFolder('Pick a file'));
quote: Originally posted by tylertyler
Also is there a way to get the file path into the EditControl?
Use the SetControlText function of the Window. So when you create the window you use the code
code: var mWnd = MsgPlus.CreateWnd('...', '...');
To set the controltext you use code: mWnd.SetControlText('EditControlName', 'New Text');
This post was edited on 10-15-2006 at 11:37 PM by matty.
|
|
10-15-2006 11:25 PM |
|
|
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
O.P. RE: Browse Help
im gonna test it
This post was edited on 10-15-2006 at 11:34 PM by TYL3R.
|
|
10-15-2006 11:31 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Browse Help
Oops I made a mistake!
code: var OFN_ENABLESIZING = 0x800000;
var OFN_EXPLORER = 0x80000;
var OFN_FILEMUSTEXIST = 0x1000;
var OFN_HIDEREADONLY = 0x4;
var OFN_LONGNAMES = 0x200000;
var OFN_PATHMUSTEXIST = 0x800;
var OFN_OVERWRITEPROMPT = 0x00000002;
function BrowseForFile(sTitle){
var OpenFileName = Interop.Allocate(88);
var filter = '*';
var s_filter;
var s_file;
var file = '*.*';
var title;
var s_title;
var ret;
var initdir = 'c:\\';
var s_initdir = Interop.Allocate((initdir.length+1)*2);
s_initdir.WriteString(0, initdir);
with (OpenFileName){
WriteDWORD(0, Size);
s_filter = Interop.Allocate((filter.length+1)*2);
s_filter.WriteString(0, filter);
WriteDWORD(12, s_filter.DataPtr);
WriteDWORD(24, 1);
s_file = Interop.Allocate((255+1)*2);
s_file.WriteString(0, file)
WriteDWORD(28, s_file.DataPtr);
WriteDWORD(32, 255);
var sTmp = Interop.Allocate((254+1)*2);
WriteDWORD(36, sTmp.DataPtr);
WriteDWORD(40, 255);
WriteDWORD(44, s_initdir.DataPtr);
s_title = Interop.Allocate((sTitle.length+1)*2);
WriteDWORD(48, s_title.DataPtr);
WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT);
}
ret = Interop.Call('comdlg32.dll', 'GetSaveFileNameW', OpenFileName);
if (ret != 0) {
return s_file.ReadString(0);
}
}
//Usage
Debug.Trace(BrowseForFolder('Pick a file'));
|
|
10-15-2006 11:36 PM |
|
|
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
O.P. RE: Browse Help
got it to work
This post was edited on 10-16-2006 at 04:06 AM by TYL3R.
|
|
10-16-2006 01:03 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|