Shoutbox

Browse Help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Browse Help (/showthread.php?tid=67358)

Browse Help by TYL3R on 10-15-2006 at 07:03 PM

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 :D

Press F5 or /mp3 to get into the mp3 player


RE: Browse Help by matty on 10-15-2006 at 09:37 PM

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'));

RE: Browse Help by TYL3R on 10-15-2006 at 10:23 PM

thanks, but is there a way to get a specific file like if you were to do a windows live messenger file transfer?


RE: Browse Help by deAd on 10-15-2006 at 10:54 PM

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.


RE: Browse Help by Ezra on 10-15-2006 at 11:08 PM

Nah, that one looks for a folder, he doesn't want the folder but the file.


RE: Browse Help by TYL3R on 10-15-2006 at 11:18 PM

Also is there a way to get the file path into the EditControl?


RE: Browse Help by matty on 10-15-2006 at 11:25 PM

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');

RE: Browse Help by TYL3R on 10-15-2006 at 11:31 PM

im gonna test it


RE: Browse Help by matty on 10-15-2006 at 11:36 PM

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'));

RE: Browse Help by TYL3R on 10-16-2006 at 01:03 AM

got it to work


RE: Browse Help by deAd on 10-16-2006 at 02:15 AM

(1) Please don't double post :)
(2) Matty, you should probably post code for the Open File dialog instead of the Save File dialog. Tylertyler, once the Open dialog is used instead of Save, it will not prompt to overwrite files. I would modify Matty's code but I do not know the differences needed (is it just a change to the API call? Probably not :P)


RE: Browse Help by matty on 10-16-2006 at 03:45 AM

Matty's reply to Browse For File


RE: Browse Help by TYL3R on 10-16-2006 at 04:05 AM

The mp3 player is working without all that confusing code


RE: Browse Help by roflmao456 on 01-18-2007 at 01:08 PM

BUG

i play a song then close the window and open it again. shows BLANK in the box but still playing music?? hmm is it supposed to do that lol

good script though..


RE: Browse Help by TYL3R on 01-19-2007 at 03:36 AM

yup


RE: Browse Help by Felu on 01-19-2007 at 10:27 AM

quote:
Originally posted by roflmao456
BUG

i play a song then close the window and open it again. shows BLANK in the box but still playing music?? hmm is it supposed to do that lol

good script though..
Its a browse dialog [Image: dodgy.gif]. It doesn't need to have the file path when reloaded.