dialog boxes - 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: dialog boxes (/showthread.php?tid=62947)
dialog boxes by teddytim on 07-10-2006 at 01:34 AM
is it possible to open up dialog boxes (Open, SaveAs, Choose Folder... etc) using this scripting system?
RE: dialog boxes by matty on 07-10-2006 at 01:43 AM
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;
}
quote: Originally posted by Choli
yeah, that's it
you can change the filter and put, for example:
"Text files|*.txt|All files|*.*||"
For more help, read this: GetOpenFileName and OPENFILENAME.
RE: dialog boxes by DeBiese on 09-13-2006 at 06:10 PM
I tried this code, but i always get 'ret = 1'...
WriteDWORD(84, 0); // FlagsEx
} with OpenFileName
I had to remove the with OpenFileName at the end. Otherwise my script wouldn't even start...
Now, can anyone tell me if there's an error on this page?
And if this should work, how do i obtain the path to the file when i click open in the dialog box?
[EDIT]
Never mind i found it:
ret = 0 => Cancel is clicked
ret = 1 => Open is clicked
var file = s_file.ReadString(0) => the full path to the chosen file
[/EDIT]
RE: dialog boxes by Dempsey on 09-13-2006 at 06:23 PM
Browse for Folder, Pick Font and Pick Colour
|