Jump to content

Click onclick Button Javascript


Recommended Posts

I got it! I am not usre why I didn't try this before but I was going off the controlsend {ENTER} idea. This code works

_IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(200)
    _IEFormElementSetValue ($o_password, $TargetPassword)
    Sleep(200)
    _IEFormElementSetValue ($o_signin, "{ENTER}")

the first two populate the username and the password portions for the form, the last one hits the sign in button.

Thank you to the guys who helped, I really appreciate it.

Link to comment
Share on other sites

Thinking about it now, I didn't need to click the button, all I had to do was send an {ENTER} while in either of the username or password fields. Hitting enter acts like hitting the Sign In button. So, I actually do not know if my could about is actually hitting enter of the sign in button or just hitting enter while being in a field causing the sign in to occur.

Link to comment
Share on other sites

i just went back and tested my code using  

_IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(200)
    _IEFormElementSetValue ($o_password, $TargetPassword & "{ENTER}")
    Sleep(200)
   ; _IEFormElementSetValue ($o_signin, "{ENTER}")

So that the last line is commented out and the sign in did NOT occur. That being said, I would need to have the last line code in order to sign in.

Link to comment
Share on other sites

8 minutes ago, Danp2 said:

Never seen the function used like that. I wonder if it would have the same result no matter what you use for the 2nd parameter.

You are correct, when I have only "" in the second parameter, the command still works, meaning the sing in button is hit. Could that be because of how I get the object?

Local $o_signin = _IEFormElementGetObjByName ($o_form, "SUBMIT_BUTTON")

 

Edited by Chance1
Link to comment
Share on other sites

12 hours ago, Chance1 said:

i just went back and tested my code using  

_IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(200)
    _IEFormElementSetValue ($o_password, $TargetPassword & "{ENTER}")
    Sleep(200)
   ; _IEFormElementSetValue ($o_signin, "{ENTER}")

So that the last line is commented out and the sign in did NOT occur. That being said, I would need to have the last line code in order to sign in.

Could you try what happens in this way?

_IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(200)
    _IEFormElementSetValue ($o_password, $TargetPassword & @CR ) ; or also @CRLF
    Sleep(200)
   ; _IEFormElementSetValue ($o_signin, "{ENTER}")

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

6 hours ago, Chimp said:

Could you try what happens in this way?

_IEFormElementSetValue ($o_user, $TargetUsername)
    Sleep(200)
    _IEFormElementSetValue ($o_password, $TargetPassword & @CR ) ; or also @CRLF
    Sleep(200)
   ; _IEFormElementSetValue ($o_signin, "{ENTER}")

 

Yes That does work!

Link to comment
Share on other sites

I am working on automating a different javascript doing a similar procedure but the javascript is different then what it was with the last one. So far, I am able to populate the username and password, but I have had no luck clicking the Sign In button again.

This is due to the fact  that the java script is different. They are not in a form, so I collect the fields like this:

Local $o_user = _IEGetObjByName ($oIE, "pt1:_pt_it1") ;text box for sign in 
Local $o_password = _IEGetObjByName ($oIE, "pt1:_pt_it2") ;text box for password
Local $o_signin = _IEGetObjById ($oIE, "pt1:_pt_cb1") ;have to get obj by ID because there is no name for it

And the javascript for the button looks like this:

<button class="x7j p_AFTextOnly" id="pt1:_pt_cb1" onclick="return false;">Sign In</button>

I tried the following with no luck:

_IEAction($o_signin, "click")
_IEFormElementSetValue ($o_user, $TargetUsername) ;enter in username
    Sleep(2000)
    _IEFormElementSetValue ($o_password, $TargetPassword & @CR); Enter a password -- & @CR to hit enter -- doesn't work
_IEFormElementSetValue ($o_signin, "") ;strike the "Sign In" button

The last of those two actually working on the previous script.

Link to comment
Share on other sites

so that didn't work either. I am looking throught the developer tool and am not finding too much. I have attaed a screenshot of the script. You can see a bunch of things being triggered before the signon button, but non of those are actually changing the sign in. There is no function that it runs onclick. The table is just the window that the fields are being displayed in. Not to sure what to do at this point. Thanks guys for all of your help.

triggersignin.PNG

Link to comment
Share on other sites

I get that onclick is an event and then on the right side of that same window it says signin(2). When I click on it get to a window that is just filled up with javascript. Not sure how to decipher this.

edit: all of the onclick commands in the seperate window are all set to "return false"

Edited by Chance1
Link to comment
Share on other sites

maybe like this?
...worth a try...

Local $o_user = _IEGetObjByName ($oIE, "pt1:_pt_it1") ;text box for sign in 
Local $o_password = _IEGetObjByName ($oIE, "pt1:_pt_it2") ;text box for password
Local $o_signin = _IEGetObjById ($oIE, "pt1:_pt_cb1") ;have to get obj by ID because there is no name for it

_IEFormElementSetValue ($o_user, $TargetUsername) ; enter in username
_IEFormElementSetValue ($o_password, $TargetPassword ) ; Enter a password

_IEAction ($o_signin, "focus"); set focus to button
ControlSend(_IEPropertyGet($oIE, "hwnd"), "", "", "{ENTER}"); send "enter" to IE

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...