Shoutbox

Auto Web Address Opener - 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: Auto Web Address Opener (/showthread.php?tid=90004)

Auto Web Address Opener by Barneyvxd on 03-31-2009 at 10:29 PM

Hey,
I have pretty little Javascript knowledge and well i was just wondering if it's possible to have a web address that's sent to you open immediately instead of having to press the link. Like incase you're busy, and they urgently need to show you something, this is kind of a request and i really hope that someone can help me...

Thanks  (:


RE: Auto Web Address Opener by rtsfg on 04-01-2009 at 10:56 AM

Be, careful, you're using Jscript, which is not JavaScript.

You could use this:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  //find out if its a web address...
  if (Message.substr(0,4) == "www." || Message.substr(0,7) == "http://")
   new ActiveXObject("WScript.Shell").run(Message);
}


The "find out" part should work with some substr...

edit: like this, for example.

btw, I would never use a script like this, who knows what kind of addresses you'll recieve :S
RE: Auto Web Address Opener by James Potter on 04-01-2009 at 11:19 AM

quote:
Originally posted by rtsfg
Btw, I would never use a script like this, who knows what kind of addresses you'll recieve :S
How about adding a "filter" that has arrays for each contact (the person who requested the script should be smart enough to know how to duplicate arrays and add contacts that will be "filtered" out... Or wouldn't he? ;)
RE: Auto Web Address Opener by Spunky on 04-01-2009 at 12:18 PM

quote:
Originally posted by rtsfg
Be, careful, you're using Jscript, which is not JavaScript.

You could use this:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
  //find out if its a web address...
  if (Message.substr(0,4) == "www." || Message.substr(0,7) == "http://")
   new ActiveXObject("WScript.Shell").run(Message);
}


The "find out" part should work with some substr...

edit: like this, for example.

btw, I would never use a script like this, who knows what kind of addresses you'll recieve :S

That only finds addresses at the start of a message and could open a webpage called "www.google.com <-- Check this out" which wouldn't work

Best option is to use string.search and a RegExp
RE: Auto Web Address Opener by matty on 04-01-2009 at 01:12 PM

Javascript code:
var oChatWnds = {}
 
function OnEvent_ChatWndSendMessage( pChatWnd, sMessage ){
    oChatWnds[ pChatWnd.Handle ] = sMessage;
}
 
 
function OnEvent_ChatWndReceiveMessage( pChatWnd, sOrigin, sMessage, nMessageKind ){
    if ( oChatWnds[ pChatWnd.Handle ] === sMessage ) return;
    var regexp = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
    var urls = sMessage.match(regexp);
   
    if ( urls.length === 0 ) return;
   
    var oWnd = MsgPlus.CreateWnd( 'wUrlOpener', 'Window.xml' );
    for ( var url in urls ) oWnd.LstView_AddItem( 'LvUrls', urls[url] );
}
 
function OnEvent_ChatWndDestroyed( pChatWnd ){
    delete oChatWnds[ pChatWnd.Handle ];
}
 
function OnwUrlOpenerEvent_CtrlClicked( pPlusWnd, sControlId ){
    if(sControlId.match(/^BaseBtn/)) return;
   
    for (var j=0; j<pPlusWnd.LstView_GetCount('LvUrls'); j++){
            if (pPlusWnd.LstView_GetCheckedState('LvUrls', j)){
                Debug.Trace( pPlusWnd.LstView_GetItemText('LvUrls', j , 0) );
               
                /**
                    Open the windows here
                **/

            }
        }
       
    }
}


XML code:
<?xml version="1.0" encoding="UTF-16"?>
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd" Name="urlOpener">
    <Window Id="wUrlOpener" Version="1">
        <Attributes>
            <Caption>URL Opener</Caption>
        </Attributes>
        <TitleBar>
            <Title><Text></Text></Title>
        </TitleBar>
        <Position Width="350" Height="213">
            <Resizeable Allowed="BothSides">
                <MinWidth>250</MinWidth>
                <MinHeight>158</MinHeight>
            </Resizeable>
        </Position>
        <DialogTmpl>
            <BottomBar Style="Plain">
                <LeftControls>
                    <Control xsi:type="ButtonControl" Id="BtnCancel">
                        <Position Left="0" Top="0" Width="50"/>
                        <Caption>&amp;Cancel</Caption>
                    </Control>
                </LeftControls>
                <RightControls>
                    <Control xsi:type="ButtonControl" Id="BtnSend">
                        <Position Left="0" Top="0" Width="75"/>
                        <Caption>&amp;Open URL(s)</Caption>
                    </Control>
                </RightControls>
            </BottomBar>
        </DialogTmpl>
        <Controls>
            <Control xsi:type="StaticControl" Id="lblTitle">
                <Position Top="3" Left="5" Width="210" Height="10"/>
                <Caption>Select a URL to open</Caption>
                <Attributes>
                    <AutoAdjustWidth>true</AutoAdjustWidth>
                </Attributes>
            </Control>
            <Control xsi:type="ListViewControl" Id="LvUrls">
                <Position Top="15" Left="5" Width="330" Height="126">
                    <Anchor Horizontal="LeftRightFixed" Vertical="TopBottomFixed"/>
                </Position>
                <Attributes>
                    <AutoTip>true</AutoTip>
                    <AlwaysShowSelection>True</AlwaysShowSelection>
                </Attributes>
                <ReportView>
                    <FullRowSelect>True</FullRowSelect>
                    <HasCheckboxes>True</HasCheckboxes>
                </ReportView>
                <Images>
                <Columns WidthFormat="Absolute">
                    <Column>
                        <ColumnId>ColUrl</ColumnId>
                        <Label>URLs</Label>
                        <Width>250</Width>
                    </Column>
                </Columns>
            </Control>
        </Controls>
    </Window>
</Interfaces>


Clearly I was bored...