Code Viewer

./screenshot_sender.js File Size: 18.32 KB

  1. /*
  2. * -----
  3. * Screenshot Sender - screenshot_sender.js
  4. * -----
  5. * Main script file for Screenshot Sender
  6. * -----
  7. */
  8.  
  9. /*
  10.         Name:   OnEvent_Initialize
  11.         Purpose:        The OnEvent_Initialize event is fired when the script is starting
  12.         Parameters:     None
  13.         Return: None
  14. */
  15.  
  16. function OnEvent_Initialize() {
  17.         /* Create the debug object */
  18.         _debug = new __debug();
  19.        
  20.         /* Display debug information about the function */
  21.         _debug.getfuncname(arguments);
  22.        
  23.         /* Check if a user is signed in */
  24.         if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
  25.        
  26.         /* Display the version information */
  27.         _debug.trace('Screenshot Sender: ' + CompileVersion());
  28.        
  29.         /* Load classes */
  30.         LoadClasses();
  31.                 /* Declare classes */
  32.                 _win32 = new __win32();
  33.                 _lang = new __language();
  34.        
  35.         /* Load preferences */
  36.         LoadPreferences();
  37.        
  38.         /* Check the current version */
  39.         if (CheckVersion(4.60) === false) return false;
  40.        
  41.         /* Check if Screenshot Sender 4 is running */
  42.         if (CheckForOldVersion() === true) return false;
  43.        
  44.         /* Create script icon */
  45.         hScriptIcon = LoadIcon();
  46.        
  47.         /* Load window handlers */
  48.         LoadWindowHandlers();
  49.  
  50.         /* Load hotkeys */
  51.         _hotkey = new Hotkeys();
  52.         _hotkey.Initialize();
  53.                 _hotkey.LoadHotkeys();
  54.        
  55.         /* Create session images object */
  56.         SessionImages = new SessionImage();
  57.        
  58.         /* Create default overlay font */
  59.         objOverlayDefaultFont = new Font({
  60.                 FaceName :      'Tahoma',
  61.                 ColorRef :      0x00000000,
  62.                 Height :        (8).toLogical(),
  63.                 Weight :        400,
  64.                 Italic :        0,
  65.                 Underline :     0,
  66.                 StrikeOut :     0
  67.         });
  68.        
  69.         // Adds wlm id to a database for usercounts.
  70.         UserCounter();
  71.  
  72.         // Creates events subclass window
  73.         LoadEventsSubclassWindow();
  74. }
  75.  
  76. /*
  77.         Name:   OnEvent_SigninReady
  78.         Purpose:        The OnEvent_SigninReady event is fired when the current Messenger user signs-in, after
  79.                         information about the contact's list has been received from the server.
  80.         Parameters:     sEmail - Email of the current Messenger user.
  81.         Return: None
  82. */
  83. function OnEvent_SigninReady(sEmail) {
  84.         _debug.getfuncname(arguments);
  85.         OnEvent_Initialize();
  86. }
  87.  
  88. /*
  89.         Name:   OnEvent_Uninitialize
  90.         Purpose:        The OnEvent_Uninitialize event is fired when the script is ending.
  91.         Parameters:     None
  92.         Return: None
  93. */
  94. function OnEvent_Uninitialize() {
  95.         _debug.getfuncname(arguments);
  96.         try {
  97.                 _hotkey.UnregisterHotkeys();
  98.         } catch (e) {}
  99.         try {
  100.                 if (typeof SessionImages === TYPE_OBJECT) SessionImages.DeleteSessionImages();
  101.         } catch (e) {}
  102.         try {
  103.                 for (var i in objBitmaps) _win32.DeleteObject(objBitmaps[i]);
  104.         } catch (e) {}
  105.         try {
  106.                 _win32.DestroyIcon(hScriptIcon);
  107.         } catch (e) {}
  108.         if (typeof objWindows['ScreenshotSender_Subclass'] === TYPE_OBJECT) {
  109.                 RegisterWindowHooks('ScreenshotSender_Subclass', [
  110.                         WM_CONTACTSIGNIN,
  111.                         WM_CONTACTSIGNOUT,
  112.                         WM_CONTACTSTATUSCHANGE,
  113.                         WM_CHATWNDOPEN,
  114.                         WM_CHATWNDCLOSED,
  115.                         WM_SCREENSHOTADDED,
  116.                         WM_IDLEUPLOAD
  117.                 ], false);
  118.                 CloseWindow('ScreenshotSender_Subclass');
  119.         }
  120. }
  121.  
  122. function OnEvent_Signout(sEmail) {
  123.         _debug.getfuncname(arguments);
  124.         OnEvent_Uninitialize();
  125. }
  126.  
  127. /*
  128.         Name:   OnEvent_ChatWndSendMessage
  129.         Purpose:        The OnEvent_ChatWndSendMessage event is fired every time the current user sends a message in a chat window.
  130.         Parameters:     oChatWnd - Reference to the ChatWnd oect attached to the chat generating the event.
  131.                                 sMessage - Message that's being sent to the chat's participants. Emoticons present in the
  132.                                                  message are converted back to their text code before the event is generated
  133.                                                  (when possible) and will be re-parsed before the message is actually sent to the server.
  134.         Return: A string containing the message to be sent instead of Message. If you do not want to modify the message,
  135.                         simply return Message without changing it. No size restriction applies to the new message except for the
  136.                         maximum size allowed by Messenger. If the event handler returns an empty string, the message is ignored
  137.                         and not sent to the server.
  138. */
  139. function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
  140.         var m = /^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage);
  141.         if (m) {
  142.                 _debug.getfuncname(arguments);
  143.                 var _command = m[1].toLowerCase();
  144.                 var _param = m[2];
  145.                 switch (_command) {
  146.                         case 'ssactive':
  147.                         case 'ssfullscreen':
  148.                         case 'ssclipboard':     
  149.                         case 'ssselect':
  150.                         case 'sspcc':
  151.                         case 'ssmonitor':
  152.                         case 'sswindow':
  153.                                 if (Messenger.MyStatus > STATUS_INVISIBLE) CommandToFunction(oChatWnd, false, _command, _param);
  154.                                 break;
  155.                         case 'sssactive':
  156.                         case 'sssfullscreen':
  157.                         case 'sssclipboard':
  158.                         case 'sssselect':
  159.                         case 'ssspcc':
  160.                         case 'sssmonitor':
  161.                         case 'ssswindow':
  162.                                 CommandToFunction(oChatWnd, true, _command, _param);
  163.                                 break;
  164.                         case 'ssconfig':
  165.                                 OpenPreferences();
  166.                                 break;
  167.                         case 'ssrecent':
  168.                                 if (Messenger.MyStatus > STATUS_INVISIBLE) RecentImages(oChatWnd);
  169.                                 break;
  170.                         case 'ssviewer':
  171.                                 LaunchScreenshotViewer();
  172.                                 break;
  173.                         case 'ssopendir':
  174.                                 _win32.ShellExecuteW(0, 'open', objPreferences['tSaveDirectory'], '', '', 1);
  175.                                 break;
  176.                         default:
  177.                                 return sMessage;
  178.                 }
  179.                 return '';
  180.         }       
  181.         return sMessage;
  182. }
  183.  
  184.  
  185. function OnEvent_ChatWndEditKeyDown(oChatWnd, vkKey, bCtrl, bShift) {
  186.         if (objPreferences['cOverrideCtrlV'] == true && bCtrl == true && vkKey === 0x56 /* VK_V */) {
  187.                 _debug.getfuncname(arguments);
  188.                 var bResult = false;
  189.                 try {
  190.                         _win32.OpenClipboard(0);
  191.                         if (_win32.IsClipboardFormatAvailable(_win32._const._CF_BITMAP)) {
  192.                                 var nImgPtr = _win32.GetClipboardData(_win32._const._CF_BITMAP);
  193.                                 if (nImgPtr !== 0) {
  194.                                         CommandToFunction(oChatWnd, false, 'ssclipboard');
  195.                                         bResult = true;
  196.                                 }
  197.                         } else if (_win32.IsClipboardFormatAvailable(_win32._const._CF_HDROP)) {
  198.                                 var cb_hdrop = _win32.GetClipboardData(_win32._const._CF_HDROP);
  199.                                 var iFile = _win32.DragQueryFileW(cb_hdrop, 0xffffffff, 0, 0);
  200.                                 var CLSID; var ppsz; var lpsz;
  201.                                 for (var i = 0; i <= iFile; ++i) {
  202.                                         CLSID = Interop.Allocate(16);
  203.                                         ppsz = Interop.Allocate(512);
  204.                                         lpsz = Interop.Allocate(512);
  205.                                         _win32.DragQueryFileW(cb_hdrop, i, lpsz, 512);
  206.                                         _win32.GetClassFile(lpsz, CLSID);
  207.                                         _win32.StringFromGUID2(CLSID, ppsz, 512);
  208.                                         if (ppsz.ReadString(0).toLowerCase() === Image_CLSID)
  209.                                                 _debug.trace('Clipboard file: ' + lpsz.ReadString(0));
  210.                                 }
  211.                         }
  212.                 } catch (e) {
  213.                         _debug.error(e, 'OnEvent_ChatWndEditKeyDown');
  214.                 } finally {
  215.                         _win32.CloseClipboard();
  216.                 }
  217.                 return bResult;
  218.         }
  219. }
  220.  
  221. /*
  222.         Name:   CommandToFunction
  223.         Purpose:        Perform specific functions based on the command entered
  224.         Parameters:     oChatWnd - ChatWindow object
  225.                         SaveImage - Whether the image is to be sent(false), or saved(true)
  226.                         Command - The command the user enetered
  227.                         Param - The parameter to the command
  228.         Return: None
  229. */
  230. function CommandToFunction(oChatWnd, SaveImage, Command, Param) {
  231.         _debug.getfuncname(arguments);
  232.         var oGdip = new Gdip(SaveImage);
  233.         oGdip.Initialize();
  234.         if (Param === '<' + _lang.text['CommandDelay'] + '>' || Param <= 1 || typeof Param === TYPE_UNDEFINED) {
  235.                 if (oGdip.Initialized == true) {
  236.                         switch (Command) {
  237.                                 case 'ssactive':
  238.                                 case 'sssactive':
  239.                                         oGdip.SaveImage(oGdip.CaptureWindow_Active(), SessionImages.CreateTempImage());
  240.                                         break;
  241.                                 case 'sssfullscreen':  
  242.                                 case 'ssfullscreen':
  243.                                         oGdip.SaveImage(oGdip.CaptureWindow_Fullscreen(), SessionImages.CreateTempImage());
  244.                                         break;
  245.                                 case 'sssclipboard':    
  246.                                 case 'ssclipboard':
  247.                                         oGdip.SaveImage(oGdip.CaptureWindow_Clipboard(), SessionImages.CreateTempImage());
  248.                                         break;
  249.                                 case 'sssselect':
  250.                                 case 'ssselect':
  251.                                         SelectedArea(oChatWnd, Command, Param, SaveImage);
  252.                                         break;
  253.                                 case 'ssspcc' :
  254.                                 case 'sspcc' :
  255.                                         PointClickCapture(oChatWnd, Command, Param, SaveImage)
  256.                                         break;
  257.                                 case 'sssmonitor' :
  258.                                 case 'ssmonitor' :
  259.                                         SelectedMonitor(oChatWnd, Command, Param, SaveImage, false);
  260.                                         break;
  261.                                 case 'ssswindow' :
  262.                                 case 'sswindow' :
  263.                                         SelectedWindow(oChatWnd, Command, Param, SaveImage);
  264.                                         break;
  265.                         }
  266.                 }
  267.                 CommandToFunction_Cleanup(oGdip, oChatWnd, SaveImage);
  268.         }
  269.         else CheckTimer(oChatWnd, Command, Param, SaveImage);
  270.         oGdip.Uninitialize();
  271. }
  272.  
  273. function CommandToFunction_Cleanup(oGdip, oChatWnd, SaveImage) {
  274.         _debug.getfuncname(arguments);
  275.         if (oGdip.SaveSuccessful == true /*[Ok]*/) {
  276.                 if (SaveImage == false) {
  277.                         if (objPreferences['cPreviews'] == true)
  278.                                 Preview(oChatWnd, oGdip.ImageLocation, SaveImage);     
  279.                         else {
  280.                                 if (oChatWnd.Contacts.Count === 1)
  281.                                         oChatWnd_SendFile(oChatWnd, SessionImages.MoveTempImage(oGdip.ImageLocation, SessionImages.CreateImagePath()));
  282.                                 else
  283.                                         ContactSelector(oChatWnd.Contacts);
  284.                         }
  285.                 }
  286.                 else {
  287.                         if (objPreferences['cPreviews'] == true) Preview(oChatWnd, oGdip.ImageLocation, SaveImage);     
  288.                         else {
  289.                                 sImagePath = SaveFileAs(oChatWnd.Handle);
  290.                                 if (sImagePath == false)
  291.                                         _win32.DeleteFileW(oGdip.ImageLocation);
  292.                                 else {
  293.                                         SessionImages.MoveTempImage(oGdip.ImageLocation, sImagePath);
  294.                                         if ((objPreferences['cUploadScreenshots'] == true && objPreferences['cUploadOptions'] === 0) ||
  295.                                                 (SaveImage === false && objPreferences['cUploadOptions'] === 1) ||
  296.                                                 (SaveImage === true && objPreferences['cUploadOptions'] === 2)) {
  297.                                                 Ftp_UploadFile(sImagePath, false, oChatWnd, true);
  298.                                         }
  299.                                 }
  300.                         }                            
  301.                 }
  302.         }
  303. }

Version

  • 5.0.0070_20100325_publicbeta1

Developers

Project Details

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

User Count

  • 162