What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Open File Dialog

Open File Dialog
Author: Message:
Sh4wn
New Member
*


Posts: 14
Joined: Jul 2006
O.P. Open File Dialog
How can I create a 'Open file..' Dialog, so a user can select a file, and my script kan get the full path.

I'm sure it can be done with Interop, but which DLL do I have to use, and which function?

And how can I get the full path then?

07-14-2006 04:45 PM
Profile E-Mail PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Open File Dialog
Me to, I would like to know how this is done. I want to get the path to an EXE.
07-15-2006 01:07 PM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Open File Dialog
please read Browse For File
07-15-2006 01:15 PM
Profile PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Open File Dialog
You are either not logged in or do not have permission to view this page. :(
07-15-2006 01:16 PM
Profile E-Mail PM Web Find Quote Report
andrey
elite shoutboxer
****

Avatar

Posts: 795
Reputation: 48
– / Male / Flag
Joined: Aug 2004
RE: Open File Dialog
there's an example in this thread
dialog boxes

(is the quote actually taken from the thread Eljay linked to ?)
[Image: w2kzw8qp-sq2_dz_b_xmas.png]
07-15-2006 01:32 PM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Open File Dialog
oops :$

until its moved ill post the important bit here :P

quote:
Originally posted by Matty
This is taken from Choli's Translator, give all credits too him.

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;
   
function OnEvent_Initialize(MessengerStart)
{
    var OpenFileName = Interop.Allocate(88);
    var filter;
    var s_filter;
    var file;
    var s_file;
    var title;
    var s_title;
    var ret;
    var tdata;

     with (OpenFileName) {
        WriteDWORD(0, Size); // lStructSize
        WriteDWORD(4, 0); // hwndOwner
        WriteDWORD(8, 0); // hInstance
        filter = "Translation files (Lng_*.ini)|Lng_*.ini|All files (*.*)|*.*||";
        s_filter = Interop.Allocate(2 * (filter.length + 1));
        WriteMultiStringW(s_filter, filter);
        WriteDWORD(12, s_filter.DataPtr); // lpstrFilter
        WriteDWORD(16, 0); // lpstrCustomFilter
        WriteDWORD(20, 0); // nMaxCustomFilter
        WriteDWORD(24, 1); // nFilterIndex
        file = "Lng_*.ini" + Space(256);
        s_file = Interop.Allocate(2 * (file.length + 1));
        s_file.WriteString(0, file);
        WriteDWORD(28, s_file.DataPtr); // lpstrFile
        WriteDWORD(32, file.length); // nMaxFile
        WriteDWORD(36, 0); // lpstrFileTitle
        WriteDWORD(40, 0); // nMaxFileTitle
        WriteDWORD(44, 0); // lpstrInitialDir
        title = "Select original file";
        s_title = Interop.Allocate(2 * (title.length + 1));
        s_title.WriteString(0, title);
        WriteDWORD(48, s_title.DataPtr); // lpstrTitle
        WriteDWORD(52, OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST); // flags
        WriteWORD(56, 0); // nFileOffset
        WriteWORD(58, 0); // nFileExtension
        WriteDWORD(60, 0); // lpstrDefExt
        WriteDWORD(64, 0); // lCustData
        WriteDWORD(68, 0); // lpfnHook
        WriteDWORD(72, 0); // lpTemplateName
        WriteDWORD(76, 0); // pvReserved
        WriteDWORD(80, 0); // dwReserved
        WriteDWORD(84, 0); // FlagsEx
    } with OpenFileName
    ret = Interop.Call("comdlg32.dll", "GetOpenFileNameW", OpenFileName);
    if (ret == 0) {
        return;
    }
}
function WriteMultiStringW (datablock, string) {
    var pos = 0;
    datablock.WriteString(0, string);
    pos = string.indexOf("|", pos);
    while (pos != -1) {
        datablock.WriteWORD(2 * pos, 0);
        pos = string.indexOf("|", pos + 1);
    }
}
function Space (number) {
    var i;
    var s = "";
    for (i = 0; i < number; i++) {
        s += " ";
    }
    return s;
}


edit:
quote:
Originally posted by andrey
there's an example in this thread
dialog boxes

(is the quote actually taken from the thread Eljay linked to ?)

yes it is :P

This post was edited on 07-15-2006 at 01:34 PM by Eljay.
07-15-2006 01:33 PM
Profile PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Open File Dialog
Thanks :)
07-15-2006 02:08 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On