Code Viewer

./functions.js File Size: 46.12 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - functions.js
  4. * -----
  5. * Common functions for Screenshot Sender
  6. * -----
  7. */
  8.  
  9. /*
  10.         Name:   CheckVersion
  11.         Purpose:        Compare the parameter to the Messenger Plus! Live version
  12.         Parameters:     _version - Version to compare to Messenger Plus! Live
  13.         Return: True if Plus! version is Greater or Equal to the Parameter / False if it isn't
  14. */
  15. function CheckVersion(_version) {
  16.         _debug.getfuncname(arguments);
  17.         var ret = MsgPlus.Version >= _version;
  18.         if (ret === false)
  19.                 _win32.MessageBoxW(0, _lang.text['MsgBoxPlusVersionError'], _lang.text['MsgBoxError_Title'], 32);
  20.         return ret;
  21. }
  22.  
  23. /*
  24.         Name:   GetDirectoryStructure
  25.         Purpose:        Create a list of all the files from a given location on the disc
  26.         Parameters:     sPath - Path to get all the files from
  27.                         includePath - If true, will include the full path to the filename, if false will only display the filename
  28.         Return: An array of the files from the path
  29. */
  30. function GetDirectoryStructure(sPath, sPattern, IncludePath) {
  31.         _debug.getfuncname(arguments);
  32.         var aFileNames = [];
  33.         var Win32_Find_Data = Interop.Allocate(592);
  34.         var hSearch = Interop.Call('kernel32', 'FindFirstFileW', '\\\\?\\' + sPath + sPattern, Win32_Find_Data);
  35.         var hResult;
  36.         while (hResult !== 0) {
  37.                 if (!(Win32_Find_Data.ReadDWORD(0) & 0x10 /* FILE_ATTRIBUTE_DIRECTORY */ & 0x4 /* FILE_ATTRIBUTE_SYSTEM */) &&
  38.                                  Win32_Find_Data.ReadString(44).charAt(0) !== '.') {
  39.                         aFileNames.push((IncludePath ? sPath : '') + Win32_Find_Data.ReadString(44));
  40.                 }
  41.                 hResult = Interop.Call('kernel32', 'FindNextFileW', hSearch, Win32_Find_Data)
  42.         }
  43.         Interop.Call('kernel32', 'FindClose', hSearch);
  44.         return aFileNames;
  45. }
  46.  
  47. /*
  48.         Name:   ClearListView
  49.         Purpose:        Clears a specified listview of all it's contents
  50.         Parameters:     hWnd - The handle of the listview
  51.         Return: None
  52. */
  53. function ClearListView(hWnd) {
  54.         _debug.getfuncname(arguments);
  55.         _win32.SendMessageW(hWnd, _win32._const._LVM_DELETEALLITEMS, 0, 0);
  56. }
  57.  
  58. /*
  59.         Name:   CheckForOldVersion
  60.         Purpose:        Check if Screenshot Sender 4 is installed and enabled
  61.         Parameters:     None
  62.         Return: True if SS4 is enabled / False if it isn't
  63. */
  64. function CheckForOldVersion() {
  65.         _debug.getfuncname(arguments);
  66.         if (Registry_GetKeyValue(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\GlobalSettings\\Scripts\\Screenshot Sender 4', 'Enabled')) {
  67.                 if (_win32.MessageBoxW(0, _lang.text['MsgBoxPreviousVersion'], _lang.text['MsgBoxPreviousVersion_Title'], _win32._const._MB_ICONEXCLAMATION | _win32._const._MB_YESNO) === 6) {
  68.                         Registry_SetKeyValue(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\GlobalSettings\\Scripts\\Screenshot Sender 4', 'Enabled', 0, REG_DWORD);
  69.                         _win32.ShellExecuteW(0, 'open', Registry_GetKeyValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\\Patchou\\Messenger Plus! Live', 'AppDir') + '\\MPTools.exe', '/restartmessenger', '', _win32._const._SW_HIDE);
  70.                 }
  71.         }
  72.         return false;
  73. }
  74.  
  75. /*
  76.         Name:   ContactSelector
  77.         Purpose:        Launch the contact selector to choose the contact(s) to send the screenshot to
  78.         Parameters:     oEnum - Enumerator object(ex: Messenger.MyContacts)
  79.         Return: PlusWnd of the Contact Selector window
  80. */
  81. function ContactSelector(oEnum) {
  82.         _debug.getfuncname(arguments);
  83.         var Wnd = OpenWindow('ContactSelector', 0, true), nIndex = 0, o;
  84.         for (var e = new Enumerator(oEnum); !e.atEnd(); e.moveNext()) {
  85.                 var o = e.item();
  86.                 if (o.Status > 2 && o.Blocked == false && o.Network === 1 && o.Email.indexOf(':') === -1) {
  87.                         nIndex = Wnd.LstView_AddItem('LvContacts', RemovePlusCodes(e.item().Name));
  88.                         Wnd.LstView_SetItemText('LvContacts', nIndex, 1, e.item().Email);
  89.                         Wnd.LstView_SetItemIcon('LvContacts', nIndex, oStatus[e.item().Status], true);
  90.                 }
  91.         }
  92.         return Wnd;
  93. }
  94.  
  95. /*
  96.         Name:   Preview
  97.         Purpose:        Launches the preview window for screenshots
  98.         Parameters:     oChatWnd - [OBJ] Chat window object
  99.                         sImage - [STR] Location of image to be sent
  100.                         bSave - [BOOL] If the image is to be saved or not
  101.                         bViewer - [BOOL] If the screenshot viewer window is the "parent"
  102.         Return: None
  103. */
  104. function Preview(oChatWnd, sImage, bSave, bViewer) {
  105.         _debug.getfuncname(arguments);
  106.         if (typeof bSave === TYPE_UNDEFINED) bSave = false;
  107.         if (typeof bViewer === TYPE_UNDEFINED) bViewer = false;
  108.        
  109.         var PreviewWnd = OpenWindow('Preview', 1, true);
  110.         objChatWnds[PreviewWnd.Handle] = {};
  111.                 objChatWnds[PreviewWnd.Handle].ChatWnd = oChatWnd;
  112.                 objChatWnds[PreviewWnd.Handle].Image = sImage;
  113.                 objChatWnds[PreviewWnd.Handle].IsViewer = bViewer;
  114.                
  115.         if (bSave === true) {
  116.                 _win32.ShowWindow(objWindows['Preview'].GetControlHandle('lnkSaveImage'), _win32._const._SW_SHOW);
  117.                 _win32.ShowWindow(objWindows['Preview'].GetControlHandle('lnkSendImage'), _win32._const._SW_HIDE);
  118.         }
  119.        
  120.         var oGdip = new Gdip();
  121.         oGdip.Initialize();
  122.         PreviewWnd.SetControlText('lblImageName', SessionImages.GetFilename(sImage));
  123.         PreviewWnd.SetControlText('lblImageSize', _lang.text['ScreenshotViewer_Size'] + ' ' + oGdip.FormatFileSize(oGdip.GetImageSizeInBytes(sImage)));
  124.         PreviewWnd.SetControlText('lblImageDimensions', _lang.text['ScreenshotViewer_Dimensions'] + ' ' + oGdip.GetImageDimensions(sImage));
  125.         PreviewWnd.SetControlText('lblImageCreated', _lang.text['ScreenshotViewer_DateCreated'] + ' ' + oGdip.GetDateCreated(sImage));
  126.         oGdip.Uninitialize();
  127.         if (typeof objPictures[SessionImages.GetFilename(sImage)] === TYPE_OBJECT) {
  128.                 if (SessionImages.GetExtension(sImage).toLowerCase() === 'jpg') {
  129.                         _win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), true);
  130.                         PreviewWnd.SendControlMessage('sldrQuality', _win32._const._TBM_SETPOS, true, objPictures[SessionImages.GetFilename(sImage)].Quality);
  131.                 } else {
  132.                         _win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), false);
  133.                         _win32.EnableWindow(PreviewWnd.GetControlHandle('lblJpgQuality'), false);
  134.                         PreviewWnd.ImageElmt_SetImageFile('ImgJpg', '\\' + MsgPlus.ScriptFilesPath + '\\Images\\jpg_disabled.png');
  135.                 }
  136.         } else {
  137.                 _win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), false);
  138.                 _win32.EnableWindow(PreviewWnd.GetControlHandle('lblJpgQuality'), false);
  139.                 PreviewWnd.ImageElmt_SetImageFile('ImgJpg', '\\' + MsgPlus.ScriptFilesPath + '\\Images\\jpg_disabled.png');
  140.         }
  141.         var nHooks = [
  142.                 _win32._const._WM_PARENTNOTIFY,
  143.                 _win32._const._WM_NOTIFY
  144.         ];
  145.         if (IsWinVista() === false)
  146.                 nHooks.push(_win32._const._WM_SIZE);
  147.         RegisterWindowHooks( PreviewWnd, nHooks );
  148.        
  149.         PreviewWnd.ImageElmt_SetImageFile('ImgPreview', '\\' + sImage);
  150.         _win32.ShowWindow(objWindows['Preview'].Handle, _win32._const._SW_SHOW);
  151. }
  152.  
  153. /*
  154.         Name:   SetTransparency
  155.         Purpose:        Set transparency level of a window
  156.         Parameters:     hWnd - Handle to the window to set the transparency
  157.                         lLevel - Level of opacity
  158.                         bSelect - True if the window is for the select area function
  159.         Return: None
  160. */
  161. function SetTransparency(hWnd, lLevel, bSelect, nRemoveStyle) {
  162.         _debug.getfuncname(arguments);
  163.         if (typeof bSelect === TYPE_UNDEFINED) var bSelect = false;
  164.         if (typeof nRemoveStyle === TYPE_UNDEFINED) nRemoveStyle = 0;
  165.         var nMsg = _win32.GetWindowLongW(hWnd, _win32._const._GWL_EXSTYLE) & ~nRemoveStyle;
  166.         nMsg = nMsg | _win32._const._WS_EX_LAYERED | (bSelect ? 0 : _win32._const._WS_EX_TRANSPARENT);
  167.         _win32.SetWindowLongW(hWnd, _win32._const._GWL_EXSTYLE, nMsg);
  168.         _win32.SetLayeredWindowAttributes(hWnd, 0, lLevel, _win32._const._LWA_ALPHA);
  169. }
  170.  
  171. /*
  172.         Name:   ChooseColor
  173.         Purpose:        Opens the color picker dialog
  174.         Parameters:     hWnd - Handle to the window to set the transparency
  175.                         clrColor - Currently selected color
  176.         Return: The newly selected color
  177. */
  178. function ChooseColor(hWnd, clrColor) {
  179.         _debug.getfuncname(arguments);
  180.         var CHOOSECOLOR = Interop.Allocate(36);
  181.         var CustColors = Interop.Allocate(64);
  182.         for (var i = 0; i < 16; ++i) CustColors.WriteDWORD(i * 4, 0x00ffffff); //Set all custom colors to white
  183.         with (CHOOSECOLOR) {
  184.                 WriteDWORD(0, Size);
  185.                 WriteDWORD(4, hWnd);
  186.                 WriteDWORD(12, clrColor);
  187.                 WriteDWORD(16, CustColors.DataPtr);
  188.                 WriteDWORD(20, _win32._const._CC_FULLOPEN | _win32._const._CC_RGBINIT);
  189.         }
  190.         //Open the dialog box
  191.         if (_win32.ChooseColorW(CHOOSECOLOR) === 0) {
  192.                 CHOOSECOLOR.Size = 0;
  193.                 CustColors.Size = 0;
  194.                 return false;
  195.         }
  196.         clrColor = CHOOSECOLOR.ReadDWORD(12);
  197.         CHOOSECOLOR.Size = 0;
  198.         CustColors.Size = 0;
  199.         return clrColor;
  200. }
  201.  
  202. /*
  203.         Name:   LaunchScreenshotViewer
  204.         Purpose:        Opens the Screenshot Viewer Window
  205.         Parameters:     None
  206.         Return: None
  207. */
  208. function LaunchScreenshotViewer() {
  209.         _debug.getfuncname(arguments);
  210.         OpenWindow('ScreenshotViewer', 0, true);
  211.        
  212.         _win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkSendImage'), false);
  213.         _win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkUploadImage'), false);
  214.         _win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkConvertImage'), false);
  215.         _win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkEditImage'), false);
  216.         _win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkDeleteImage'), false);
  217.        
  218.         var nHooks = [
  219.                 _win32._const._WM_NOTIFY
  220.         ];
  221.         if (IsWinVista() === false)
  222.                 nHooks.push(_win32._const._WM_SIZE);
  223.         RegisterWindowHooks( 'ScreenshotViewer', nHooks );
  224.  
  225.         RefreshScreenshotViewerList()
  226. }
  227.  
  228. /*
  229.         Name:   RefreshScreenshotViewerList
  230.         Purpose:        Reloads the list of Screenshots to be displayed in the viewer
  231.         Parameters:     None
  232.         Return: None
  233. */
  234. function RefreshScreenshotViewerList() {
  235.         _debug.getfuncname(arguments);
  236.         if (typeof objWindows['ScreenshotViewer'] !== TYPE_OBJECT) return false;
  237.        
  238.         try { ClearListView(objWindows['ScreenshotViewer'].GetControlHandle('LvFiles')); } catch (e) {}
  239.  
  240.         _debug.trace('LOADING ' + objPreferences['tSaveDirectory']);
  241.         var aFiles = GetDirectoryStructure(objPreferences['tSaveDirectory'], '*.*', false),
  242.                 sFile = '', sFilePath = '', nIndex = 0, pPlusWnd = objWindows['ScreenshotViewer'];
  243.         var oGdip = new Gdip();
  244.         oGdip.Initialize();
  245.         /*var CLSID = Interop.Allocate(16);
  246.         var ppsz = Interop.Allocate(512);*/
  247.         for (var i=0, len=aFiles.length; i<len; ++i) {
  248.                 sFile = aFiles[i], sFilePath = objPreferences['tSaveDirectory'] + '\\' + sFile;
  249.                 /*_win32.GetClassFile(sFilePath, CLSID);
  250.                 _win32.StringFromGUID2(CLSID, ppsz, 512);
  251.                 if (ppsz.ReadString(0).toLowerCase() === Image_CLSID) {*/
  252.                 if (Image_Regex.test(sFile)) {
  253.                         nIndex = pPlusWnd.LstView_AddItem('LvFiles', sFile);
  254.                         pPlusWnd.LstView_SetItemText('LvFiles', nIndex, 1, oGdip.FormatFileSize(oGdip.GetImageSizeInBytes(sFilePath)));
  255.                         pPlusWnd.LstView_SetItemText('LvFiles', nIndex, 2, oGdip.GetDateCreated(sFilePath));
  256.                         pPlusWnd.LstView_SetItemIcon('LvFiles', nIndex, SessionImages.GetExtension(sFilePath).toLowerCase(), true);
  257.                 }
  258.         }
  259.         oGdip.Uninitialize();
  260. }
  261.  
  262. /*
  263.         Name:   BrowserForFolder
  264.         Purpose:        Opens the Folder Browser dialog
  265.         Parameters:     hWnd - Handle to the window to set as the parent
  266.         Return: The path selected in the dialog box
  267. */
  268. function BrowseForFolder(hWnd) {
  269.         _debug.getfuncname(arguments);
  270.         var BrowseInfo = Interop.Allocate(32);
  271.         var foldertitle = Interop.Allocate(512);
  272.         BrowseInfo.WriteDWORD(8, foldertitle.DataPtr);
  273.         var sTitle = _lang.text['BrowseForFolder_Title'];
  274.         var pTitle = Interop.Allocate((sTitle.length + 1) * 2);
  275.         pTitle.WriteString(0, sTitle);
  276.         BrowseInfo.WriteDWORD(0, hWnd);
  277.         BrowseInfo.WriteDWORD(12, pTitle.DataPtr);
  278.         BrowseInfo.WriteDWORD(16, _win32._const._BIF_USENEWUI | _win32._const._BIF_DONTGOBELOWDOMAIN | _win32._const._BIF_RETURNONLYFSDIRS);
  279.         var pidl = _win32.SHBrowseForFolderW(BrowseInfo);
  280.         var folderpath = Interop.Allocate(512);
  281.         _win32.SHGetPathFromIDListW(pidl, folderpath);
  282.         return ( folderpath.ReadString(0) === '' ? objPreferences['tSaveDirectory'] : folderpath.ReadString(0) + '\\' );
  283. }
  284.  
  285. /*
  286.         Name:   SaveFileAs
  287.         Purpose:        Opens the Save File As dialog box
  288.         Parameters:     None
  289.         Return: Returns the path or false if the user cancel's the dialog box
  290. */
  291. function SaveFileAs() {
  292.         _debug.getfuncname(arguments);
  293.         var OpenFileName = Interop.Allocate(88);
  294.         var ext = aImageFormats[objPreferences['cFileType']].toLowerCase();
  295.         var s_filter;
  296.         var s_file;
  297.         var title;
  298.         var s_title;
  299.         var sSave = Interop.Allocate(512);
  300.         _win32.SHGetSpecialFolderPathW(0, sSave, _win32._const._CLSID_PERSONAL, false);
  301.         var s_initdir = Interop.Allocate(sSave.ReadString(0).length*2 + 2);
  302.         s_initdir.WriteString(0, sSave.ReadString(0));
  303.  
  304.         with (OpenFileName) {
  305.                 WriteDWORD(0, Size);
  306.                 s_filter = Interop.Allocate(8);
  307.                         s_filter.WriteString(0, ext + (!IsWinVista() ?'\0':''));
  308.                 WriteDWORD(12, s_filter.DataPtr);
  309.                 WriteDWORD(24, 0);
  310.                 s_file = Interop.Allocate(512);
  311.                         s_file.WriteString(0, '*.' + ext);
  312.                 WriteDWORD(28, s_file.DataPtr);
  313.                 WriteDWORD(32, 255);
  314.                 WriteDWORD(44, s_initdir.DataPtr);
  315.                 title = _lang.text['SaveFileAs_Title'];
  316.                 s_title = Interop.Allocate((title.length + 1) *2);
  317.                 WriteDWORD(48, s_title.DataPtr);
  318.                 WriteDWORD(52, _win32._const._OFN_COMMON_FLAGS);
  319.         }
  320.         if (_win32.GetSaveFileNameW(OpenFileName) !== 0) {
  321.                 var s = s_file.ReadString(0);
  322.                 var mext = SessionImages.GetExtension(s);
  323.                 return s + (mext !== ext ? ext : '');
  324.         }
  325.         return false;
  326. }
  327.  
  328. /*
  329.         Name:   GetTaskbarRect
  330.         Purpose:        Gets the RECT of the taskbar
  331.         Parameters:     None
  332.         Return: RECT structure
  333. */
  334. function GetTaskbarRect() {
  335.         _debug.getfuncname(arguments);
  336.         var lRect = Interop.Allocate(16);
  337.         _win32.GetWindowRect(_win32.FindWindowW('shell_traywnd', ''), lRect);
  338.         return lRect;
  339. }
  340.  
  341. /*
  342.         Name:   PositionCountdownWnd
  343.         Purpose:        Positions the countdown window based on preferences
  344.         Parameters:     hWnd - Handle to the countdown window
  345.         Return: None
  346. */
  347. function PositionCoundownWnd(hWnd) {
  348.         _debug.getfuncname(arguments);
  349.         var wndRect = Interop.Allocate(16);
  350.         var TBarRect = Interop.Allocate(16);
  351.  
  352.         var SystemArea = GetSystemArea();
  353.  
  354.         _win32.GetWindowRect(hWnd, wndRect);
  355.         TBarRect = GetTaskbarRect();
  356.  
  357.         var iWidth = (wndRect.ReadDWORD(8) - wndRect.ReadDWORD(0));
  358.         var iHeight = (wndRect.ReadDWORD(12) - wndRect.ReadDWORD(4));
  359.  
  360.         if (TBarRect.ReadDWORD(0) === 0 && TBarRect.ReadDWORD(4) === 0 && TBarRect.ReadDWORD(8) === _win32.GetSystemMetrics(0)) SystemArea.Top = TBarRect.ReadDWORD(12);
  361.         else if (TBarRect.ReadDWORD(0) === 0 && TBarRect.ReadDWORD(4) === 0) SystemArea.Left = TBarRect.ReadDWORD(8);
  362.         else if (TBarRect.ReadDWORD(0) != 0 && TBarRect.ReadDWORD(4) === 0) SystemArea.Width = TBarRect.ReadDWORD(0);
  363.         else SystemArea.Height = TBarRect.ReadDWORD(4);
  364.  
  365.         switch (objPreferences['cCountdownPos']) {
  366.                 case 0 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Left, SystemArea.Top, iWidth, iHeight, 0); break;
  367.                 case 1 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Width - iWidth, SystemArea.Top, iWidth, iHeight, 0); break;
  368.                 case 2 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Left, SystemArea.Height - iHeight, iWidth, iHeight, 0); break;
  369.                 case 3 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Width - iWidth, SystemArea.Height - iHeight, iWidth, iHeight, 0); break;
  370.                 case 4 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, (_win32.GetSystemMetrics(0) /2) - (iWidth/2), (_win32.GetSystemMetrics(1) /2) - (iHeight/2), iWidth, iHeight, 0); break;
  371.         }
  372. }
  373.  
  374. /*
  375.         Name:   oChatWnd_SendFile
  376.         Purpose:        Sends a file the default way or using an alternate command
  377.         Parameters:     oChatWnd - Chat Window Oject
  378.                         sImage - Path to the image to send
  379.         Return: None
  380. */
  381. function oChatWnd_SendFile(oChatWnd, sImage) {
  382.         _debug.getfuncname(arguments);
  383.         if (objPreferences['cAltSending'] === 1) oChatWnd.SendMessage('/' + objPreferences['tAltSending']+ ' ' + sImage);
  384.         else oChatWnd.SendFile(sImage);
  385. }
  386.  
  387. /*
  388.         Name:   LstView_GetSelectedCount
  389.         Purpose:        Counts the number of selected items from a List View
  390.         Parameters:     pPlusWnd - Window object
  391.                         oLstView - String name of the List View
  392.         Return: The number of selected items
  393. */
  394. function LstView_GetSelectedCount(pPlusWnd, oLstView) {
  395.         _debug.getfuncname(arguments);
  396.         var selCount = 0;
  397.         for (var i = 0; i<pPlusWnd.LstView_GetCount(oLstView); ++i) if (pPlusWnd.LstView_GetSelectedState(oLstView, i) === true) ++selCount;
  398.         return selCount;
  399. }
  400.  
  401. /*
  402.         Name:   createXml
  403.         Purpose:        Creates an XML object
  404.         Parameters:     None
  405.         Return: The XML object or false if it fails
  406. */
  407. function createXml() {
  408.         _debug.getfuncname(arguments);
  409.         try { var xml = new ActiveXObject('Microsoft.XMLDOM'); xml.async = false; }
  410.                 catch (e) {
  411.         try { var xml = new ActiveXObject('MSXML2.DOMDocument'); xml.async = false; }
  412.                 catch (e) { return false; } };
  413.         return xml;
  414. }
  415.  
  416. /*
  417.         Name:   UserCounter
  418.         Purpose:        Adds an MD5 hash of the WLM User ID to a database
  419.         Parameters:     None
  420.         Return: None
  421. */
  422. function UserCounter() {
  423.         _debug.getfuncname(arguments);
  424.         var xml = createXml();
  425.         if (xml !== false) {
  426.                 xml.async = true;
  427.                 xml.load('http://screenshotsender.com/usercounter.php?id=' + hex_md5(Messenger.MyUserId));
  428.         }
  429. }
  430.  
  431. /*
  432.         Name:   RecentImages
  433.         Purpose:        Displays the Recent Images dialog and populates the images
  434.         Parameters:     oChatWnd - Chat Window object
  435.         Return: None
  436. */
  437. function RecentImages(oChatWnd) {
  438.         _debug.getfuncname(arguments);
  439.         var oWindow = OpenWindow('RecentImages', 0, true);
  440.         RegisterWindowHooks(oWindow, _win32._const._WM_ACTIVATE);
  441.        
  442.         objCWindows[objWindows['RecentImages'].Handle] = {}
  443.                 objCWindows[objWindows['RecentImages'].Handle].ChatWnd = oChatWnd;
  444.         var arraylength = SessionImages.Images.length-1;
  445.         var imagepos = 0;
  446.         while (imagepos < 8) {
  447.                 if (arraylength > -1) {
  448.                         objWindows['RecentImages'].ImageElmt_SetImageFile(
  449.                                 'Img' + imagepos,
  450.                                 '\\' + SessionImages.Images[arraylength]
  451.                         );
  452.                 } else {
  453.                         _win32.ShowWindow(objWindows['RecentImages'].GetControlHandle(imagepos), _win32._const._SW_HIDE);
  454.                 }
  455.                 ++imagepos;
  456.                 --arraylength;
  457.         }
  458. }
  459.  
  460. /*
  461.         Name:   SelectedArea
  462.         Purpose:        Defines Variabiles for the Overlay Window for Selected Area
  463.         Parameters:     oChatWnd - Chat Window Object
  464.                         Command - Command sent in the chat window
  465.                         Param - Params of the command
  466.                         Save Image - True/False if image is saved or sent
  467.         Return: The newly selected color
  468. */
  469. function SelectedArea(oChatWnd, Command, Param, SaveImage) {
  470.         _debug.getfuncname(arguments);
  471.         FocusRect = Interop.Allocate(16);
  472.         with (_win32._const) { var nMessages = [ _WM_MOUSEMOVE, _WM_LBUTTONDOWN, _WM_LBUTTONUP ]; }
  473.         OverlayWindowHelper('SelectArea', 0x100, 100, nMessages, arguments);
  474. }
  475.  
  476. /*
  477.         Name:   PointClickCapture
  478.         Purpose:        Defines Variabiles for the Overlay Window for PointClickCapture
  479.         Parameters:     oChatWnd - Chat Window Object
  480.                         Command - Command sent in the chat window
  481.                         Param - Params of the command
  482.                         Save Image - True/False if image is saved or sent
  483.         Return: The newly selected color
  484. */
  485. function PointClickCapture(oChatWnd, Command, Param, SaveImage) {
  486.         _debug.getfuncname(arguments);
  487.         with (_win32._const) { var nMessages = [ _WM_MOUSEMOVE, _WM_LBUTTONDOWN, _WM_LBUTTONUP ]; }
  488.         OverlayWindowHelper('PointClickCapture', 0x101, 1, nMessages, arguments);
  489. }
  490.  
  491. /*
  492.         Name:   OverlayWindowHelper
  493.         Purpose:        Defines Variabiles for the Overlay Window
  494.         Parameters:     sWindowName - Name of the window
  495.                                 lWindowOpt - Window options
  496.                                 lTransparency - Transparency Level for the Window
  497.                                 nMessages - Messeges to hook
  498.                                 args - Arguments of the calling function
  499.         Return: The newly selected color
  500. */
  501. function OverlayWindowHelper(sWindowName, lWindowOpt, lTransparency, nMessages, args) {
  502.         var SystemArea = GetSystemArea();
  503.         OpenWindow(sWindowName, lWindowOpt, false);
  504.         var hWnd = objWindows[sWindowName].Handle;
  505.  
  506.         objCWindows[hWnd] = {
  507.                 'ChatWnd' :          args[0],
  508.                 'Command' :          args[1],
  509.                 'Param' :              args[2],
  510.                 'SaveImage' :   args[3],
  511.                 'DC' :      _win32.GetWindowDC(hWnd)
  512.         };
  513.  
  514.         SetTransparency(hWnd, lTransparency, true);
  515.         _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST,
  516.                 SystemArea.Left-1, SystemArea.Top-1, SystemArea.Width + 2, SystemArea.Height + 2, 0);
  517.         _win32.ShowWindow(hWnd, _win32._const._SW_SHOW);
  518.  
  519.         RegisterWindowHooks(objWindows[sWindowName], nMessages);
  520. }
  521.  
  522. /*
  523.         Name:   GetSystemArea
  524.         Purpose:        Gets the virtual screen size
  525.         Parameters:     None
  526.         Return: Object similar to RECT build with virtual screen size
  527. */
  528.  
  529. function GetSystemArea() {
  530.         return {
  531.                 Left :    _win32.GetSystemMetrics(_win32._const._SM_XVIRTUALSCREEN),
  532.                 Top :      _win32.GetSystemMetrics(_win32._const._SM_YVIRTUALSCREEN),
  533.                 Width :  _win32.GetSystemMetrics(_win32._const._SM_CXVIRTUALSCREEN),
  534.                 Height :        _win32.GetSystemMetrics(_win32._const._SM_CYVIRTUALSCREEN)
  535.         };
  536. }
  537.  
  538. /*
  539.         Name:   CheckTimer
  540.         Purpose:        Checks to see if a timer is running, if not will create the object and display the timer
  541.         Parameters:     oChatWnd - ChatWindow object
  542.                         Command - The command the user enetered
  543.                         Param - The parameter to the command
  544.                         SaveImage - Whether the image is to be sent(false), or saved(true)
  545.         Return: False if the timer exists already / true if it was created
  546. */
  547. function CheckTimer(oChatWnd, Command, Param, SaveImage) {
  548.         _debug.getfuncname(arguments);
  549.         if (IsTimerActive === true) return false;
  550.         IsTimerActive = true;
  551.         if (Param > 99) Param = 99;
  552.         OpenWindow('Countdown', 0x101, false).SetControlText('lblTimer', (Param < 10 ? '0' + Param : Param));
  553.         SetTransparency(objWindows['Countdown'].Handle, 100);
  554.         objCWindows[objWindows['Countdown'].Handle] = {
  555.                 'ChatWnd' :          oChatWnd,
  556.                 'Command' :          Command,
  557.                 'Param' :              Param,
  558.                 'SaveImage' :   SaveImage
  559.         };
  560.        
  561.         PositionCoundownWnd(objWindows['Countdown'].Handle);
  562.         _win32.ShowWindow(objWindows['Countdown'].Handle, _win32._const._SW_SHOW);
  563.         TimerValue = (parseInt(Param)) -1;
  564.         MsgPlus.AddTimer('Countdown', 1000);
  565.         return true;
  566. }
  567.  
  568. /*
  569.                 Name:   Email2MSNId
  570.                 Purpose:        Convert email to MSN ID
  571.                 Parameters:     sEmail - The users email
  572.                 Return: Numerical representation of the email
  573. */
  574. function Email2MSNId(sEmail) {
  575.         _debug.getfuncname(arguments);
  576.         sEmail = sEmail.toLowerCase();
  577.         for (var x = 0, i = 0; i < sEmail.length; ++i) {
  578.                 x *= 101; x += sEmail.charCodeAt(i);
  579.                 while (x >= Math.pow(2, 32)) { x -= Math.pow(2, 32); }
  580.         }
  581.         return x;
  582. }
  583.  
  584. /*
  585.                 Name:   sReplace
  586.                 Purpose:        Will replace variables in a string
  587.                 Parameters:     sString - string containing variables(%1, %2, etc)
  588.                                         sArray - array of text to replace variables
  589.                 Return: String with variable place holders replaced
  590. */
  591. function sReplace(sString, aArray) {
  592.         _debug.getfuncname(arguments);
  593.         for (var i = 1; i <= aArray.length; ++i) { sString=sString.replace('%' + i, aArray[i-1]); }
  594.         return sString;
  595. }
  596.  
  597. /*
  598.                 Name:   RemovePlusCodes
  599.                 Purpose:        Will strip all Plus! formatting
  600.                 Parameters:     sText - The text to remove Plus! formatting from
  601.                 Return: Text without Plus! formatting
  602. */
  603. function RemovePlusCodes(s) {
  604.         _debug.getfuncname(arguments);
  605.         return MsgPlus.RemoveFormatCodes(s);
  606. }
  607.  
  608. /*
  609.                 Name:   CompileVersion
  610.                 Purpose:        Creates a nice readable string of the current version
  611.                 Parameters:     None
  612.                 Return: Current Version
  613. */
  614. function CompileVersion() {
  615.         _debug.getfuncname(arguments);
  616.         var xml = createXml();
  617.         xml.load(MsgPlus.ScriptFilesPath + '\\ScriptInfo.xml');
  618.         var VersionInfo = xml.selectSingleNode('//ScriptInfo/BuildInfo/Major').text;
  619.         VersionInfo += '.' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Minor').text;
  620.         VersionInfo += '.' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Build').text;
  621.         VersionInfo += '_' + xml.selectSingleNode('//ScriptInfo/BuildInfo/CompileDate').text;
  622.         VersionInfo += '_' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Tag').text;
  623.         if (_debug.enabled === true) VersionInfo += '_DEBUG';
  624.         return VersionInfo;
  625. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

  • Folders8
  • Files122
  • Total Lines11,867
  • Repository Version70

User Count

  • 162