Sign in to follow this  
Followers 0
michcio

How do I acces "javascript links"?

25 posts in this topic

#1 ·  Posted (edited)

I'm makeing a script that opens up IE and I use a lot of _IE functions...now the problem is that the site I'm connected to uses javascript to create some links. How do I click a javascript link? Before, I have just used _IELinkClickByText to click a link but thoes were always made in HTML (i.e. had a proper name). How do I solve that? :)

regards

michcio

Edited by michcio

Share this post


Link to post
Share on other sites



Try _IEAction ($o_object, "click")

Share this post


Link to post
Share on other sites

Try _IEAction ($o_object, "click")

yeah but what should I enter as o_object?

Share this post


Link to post
Share on other sites

should I use _IEGetObjByName ( ByRef $o_object, $s_Id [, $i_index = 0] )?? then what do I enter as my ID?

Share this post


Link to post
Share on other sites

should I use _IEGetObjByName ( ByRef $o_object, $s_Id [, $i_index = 0] )?? then what do I enter as my ID?

The id is the id of the text element you want to click on. It would help if you posted the code for the link, not the full page but just that element.

Share this post


Link to post
Share on other sites

The id is the id of the text element you want to click on. It would help if you posted the code for the link, not the full page but just that element.

ok well..it's just hotmail and I want to access the send button...I don't know how javascript work so I really don't know which part I should post but here comes a random one :):

var domainLoweringIsDown = false;
        document.domain = "live.com";
        
        if (window.top != self)
        {
            var hostname = "";
            try
            {
                hostname = window.top.location.hostname;
            }
            catch(e)
            {
                hostname = "";
            }
 
            var mailUrlDomain = "mail.live.com";    
            var peopleUrlDomain = "people.live.com";
            var hasMailUrl = (hostname != "") &&
                (hostname.indexOf(mailUrlDomain) != -1) &&
                ((hostname.indexOf(mailUrlDomain) + mailUrlDomain.length) == hostname.length);
            var hasPeopleUrl = (hostname != "") &&
                (hostname.indexOf(peopleUrlDomain) != -1) &&
                ((hostname.indexOf(peopleUrlDomain) + peopleUrlDomain.length) == hostname.length);
            if (!hasMailUrl && !hasPeopleUrl)
            {
                window.top.location.href = self.location.href;
            }
            else
            {
                self.location.href = 'http\x3a\x2f\x2fmail.live.com\x2fmail\x2fEditMessageLight.aspx\x3fn\x3d1709465867';
            }
        }
        else if (domainLoweringIsDown) 
        {
            if (self.location.hostname.indexOf("mail.live.com") <= 0)
            {
                document.cookie = "afu=" + escape('http\x3a\x2f\x2fmail.live.com\x2fmail\x2fEditMessageLight.aspx\x3fn\x3d1709465867') + ";path=/;domain=.mail.live.com;";
                self.location.href = 'http\x3a\x2f\x2fmail.live.com\x2f'; 
            }
        }
 
 
        var gLoadIM = true;
        function loadIM(q)
        {
            if (gLoadIM && 
                (!q || q.indexOf('nwi=1') < 0)) 
            {
                gLoadIM = false;
                var imFrame = document.getElementById("IMFrame");
                if (imFrame)
                {
                    imFrame.src = "/im/pages/im.aspx";
                }
                imFrame = null;
            }
       }
 
 
        function uiFrameLoad()
        {
            //
            try
            {
                document.title = window.frames[0].document.title;
            
                if (gLoadIM)
                {
                    loadIM(window.frames[0].location.search); 
                }
                
            }
            catch(e)
            {
            }
        }
        function beforeUnloadHandler()
        {
            try
            {
                var frameUrl = document.getElementById("UIFrame").contentwindow.document.location.href;
                document.cookie = "afu=" + escape(frameUrl) + ";path=/;domain=.mail.live.com;";
            }
            catch(e)
            {
            }
        }

cheers

michcio

Share this post


Link to post
Share on other sites

This is the html for the Send button in Hotmail:

<a id="SendMessage" onclick="if(window.ComposeContactPicker)return Control.invokeStatic('ComposeContactPicker', 'sendMessagePrep', event, null);" href="java script:;" title="Send"><span class="Label">Send</span></a>

It's also important to know that this element exists within an iframe. This code works for me:

#include <IE.au3> 
$oIE = _IEAttach ("Windows Live Hotmail")
If @ERROR Then
    MsgBox(0,"","Failed to attach IE instance")
EndIf

$oIFRAME = _IEFrameGetObjByName ($oIE, "UIFrame")


$oA = _IEGetObjById ($oIFRAME, "SendMessage")
If @ERROR Then
    MsgBox(0,"","Send button not present")
Else
    MsgBox(0,"","Sending now")
    _IEAction ($oA, "click")
EndIf

Share this post


Link to post
Share on other sites

ah IFrame right! :) yeah it works just fine for me as well thank you for all your help! :party:

Share this post


Link to post
Share on other sites

how did you find the html for the send button, i know it all sounds trivial but webpages are organised in such a way (especially hotmail)

that i dont know how to click the 'new' text for creating a new message, any help please

Share this post


Link to post
Share on other sites

how did you find the html for the send button, i know it all sounds trivial but webpages are organised in such a way (especially hotmail)

that i dont know how to click the 'new' text for creating a new message, any help please

DebugBar


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

ive scanned the various scripts for hotmail, i would be able to write my script and others for sites that use javascript

if i just knew how to get the ID's in the code.

for example i got the ID's for the login page

$o_form = _IEFormGetObjByName ($oIE, "f1")

$o_login = _IEFormElementGetObjByName ($o_form, "login")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

but the pages after you have logged in are proving to be near impossible, any help in how i go about finding the ID's

would be very much appreciated

thanks

Share this post


Link to post
Share on other sites

DebugBar


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

ok dale, thanks for the info, just googled 'debug bar' and im back on track thanks for the help

Share this post


Link to post
Share on other sites

thanks for the response on the debug bar, i have definatly made progress with my program, i am however perplexed by the structure of hotmail pages after you log in, i can automate the login with this simple code

$o_form = _IEFormGetObjByName ($oIE, "f1")

$o_login = _IEFormElementGetObjByName ($o_form, "login")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = ""

$password = ""

_IEFormElementSetValue ($o_login, $username)

_IEFormElementSetValue ($o_password, $password)

_IEAction ($o_signin, "click")

which is straightforward, the problem however is after you login and even with the form id's and names i cant get any further, a msgbox returning the form name will only return a 0

any help with pointing in the right direction would be grately appreciated thank you

Share this post


Link to post
Share on other sites

So you show what is working for you, but not what you are having trouble with. Show your code.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

ok no probs, when someone first logs into there hotmail account there is a microsoft information page with a continue button and a check box, alls im trying to do

is click this button, its not as straight forward as signing in this should work

#include <IE.au3>




$oIE = _IECreate()
_IENavigate ($oIE, "http://www.hotmail.co.uk")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; user might not use hotmail
_IELinkClickByText ($oIE, "sign in with a different account")
_IEFormElementCheckboxSelect ($oIE, "Remember me on this computer", "", 0)


$o_form = _IEFormGetObjByName ($oIE, "f1")
$o_login = _IEFormElementGetObjByName ($o_form, "login")
$o_password = _IEFormElementGetObjByName ($o_form, "passwd")
$o_signin = _IEFormElementGetObjByName ($o_form, "SI")


$username = ""
$password = ""

_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; user might not have unchecked a box
_IELoadWait ($oIE)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;this part dosnt work
$o_form = _IEFormGetObjByName ($oIE, "MessageAtLoginForm")
$o_continue = _IEFormElementGetObjByName ($o_form, "TakeMeToInbox")
_IEAction ($o_continue, "click")
_IELoadWait ($oIE)

im not sure why the above code dosnt work, i got around it by getting the handle for the window and using controlsend() to send "TAB" keys until the desired button was selected then enter key was sent, not elegant by any means, more than anything its bugging me because i dont know why the above code wont work.

thanks for any help

neal

Share this post


Link to post
Share on other sites

What messages are displayed in the SciTe console?


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\autoit files\hotmail3.au3"

--> IE.au3 V2.3-1 Warning from function _IELinkClickByText, $_IEStatus_NoMatch

--> IE.au3 V2.3-1 Error from function _IEFormElementCheckboxSelect, $_IEStatus_InvalidObjectType

--> IE.au3 V2.3-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.3-1 Error from function _IEAction, $_IEStatus_InvalidDataType

>Exit code: 0 Time: 10.243

Share this post


Link to post
Share on other sites

Please verify that you looked at the warnings and errors returned by IE.au3 and tried to use them to troubleshoot your problem. Quite a lot of work went into trying to make them useful. Please see what you can do and then ask related questions if necessary.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

yes looked into them, the pages after the signin page are of an unfamiliar structure to me, i use the functions for getting and selecting objects but they are not matched in the same way as the signin page

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0