Jump to content

How to click a button with no name


Recommended Posts

Hello there,

Does any of you have any idea how to click or somehow execute a button with no name in the html source?

The part from the source looks like this:

<INPUT class="primaryActive" TYPE="submit" VALUE="Login" onclick="return login();" >

I haven't found anything in the help file about this. I've also tried many things like _IELinkClickByText or _IEFormSubmit etc. but with no luck.

Any idea?

Link to comment
Share on other sites

  • Moderators

Hello there,

Does any of you have any idea how to click or somehow execute a button with no name in the html source?

The part from the source looks like this:

<INPUT class="primaryActive" TYPE="submit" VALUE="Login" onclick="return login();" >

I haven't found anything in the help file about this. I've also tried many things like _IELinkClickByText or _IEFormSubmit etc. but with no luck.

Any idea?

You got the form object, used _IEFormSubmit, and it didn't work? ... We need a lot more information (like your code).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You got the form object, used _IEFormSubmit, and it didn't work? ... We need a lot more information (like your code).

Sure, here it is:

#Include <IE.au3>
$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
$passw = "password"
_IELoadWait ($oIE)
WinSetState("","",@SW_MAXIMIZE)
$lofasz=_IEGetObjByName($oIE,"pass")
_IEFormElementSetValue ($lofasz, $passw)
_IELinkClickByText($oIE,"Login")

And yes, the _IEFormSubmit didn't work with that, however it did with the textboxes, so this should be a form in fact.

Do you need any other information?

Link to comment
Share on other sites

  • Moderators

Sure, here it is:

#Include <IE.au3>
$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
$passw = "password"
_IELoadWait ($oIE)
WinSetState("","",@SW_MAXIMIZE)
$lofasz=_IEGetObjByName($oIE,"pass")
_IEFormElementSetValue ($lofasz, $passw)
_IELinkClickByText($oIE,"Login")

And yes, the _IEFormSubmit didn't work with that, however it did with the textboxes, so this should be a form in fact.1

Do you need any other information?

1. How do you expect to get help when you don't even supply a website to test on.

2. I don't see anywhere there that you got the form object.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

To click you have to use IEAction:

$btn=_IEGetObjByName($oIE,"LogIn")

_IEAction($btn,"Click")

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

1. How do you expect to get help when you don't even supply a website to test on.

2. I don't see anywhere there that you got the form object.

1. You can try this, but it won't work I think as it's only available to my company's IP

https://webreports.avis-europe.com/Hyperion/browse

2. I think this is a form because this part is working:

$lofasz=_IEGetObjByName($oIE,"pass")
_IEFormElementSetValue ($lofasz, $passw)
Link to comment
Share on other sites

To click you have to use IEAction:

$btn=_IEGetObjByName($oIE,"LogIn")

_IEAction($btn,"Click")

Thanks a lot, but as shown above this element has no name. Quite unusual, but I've checked the source and found nothing but the code pasted above.

Link to comment
Share on other sites

  • Moderators

Thanks a lot, but as shown above this element has no name. Quite unusual, but I've checked the source and found nothing but the code pasted above.

Do yourself a favor and download debugbar from here: http://www.debugbar.com/

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Thank you, you are very kind and helpful.

Keep up the good work.

Anyone who can really help me?

Don't be a moron... did you even bother to download it?

Edit:

In case I need to hold your hand... It will debug your page and show you all the forms and names. It's quite easy to use, and will save a lot of headache now and or in the future.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Don't be a moron... did you even bother to download it?

Edit:

In case I need to hold your hand... It will debug your page and show you all the forms and names. It's quite easy to use, and will save a lot of headache now and or in the future.

Yes, I tried to download it, but it won't show up in my explorer. And yes, I've tried to activate it in the toolbars menu, but it's not there.

I will try to figure out something.

Link to comment
Share on other sites

Hi i have the same problem on yahoo with the "check mail" button, no name not even with firebug :)

Well, that's something different, that's javascript. You can find some topics here about that like these below, however I have only found one where there's a solution but I can't find it now.

Check these out:

http://www.autoitscript.com/forum/index.ph...javascript+link

http://www.autoitscript.com/forum/index.ph...javascript+link

Link to comment
Share on other sites

Sure, here it is:

#Include <IE.au3>
$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
$passw = "password"
_IELoadWait ($oIE)
WinSetState("","",@SW_MAXIMIZE)
$lofasz=_IEGetObjByName($oIE,"pass")
_IEFormElementSetValue ($lofasz, $passw)
_IELinkClickByText($oIE,"Login")oÝ÷ Ø    ÝÉë-âæJææ×bv}ý·
+­ØZ¶0z÷«×bw­Ø^µìmn^²Ê-+,¥u·~æwÚrÐèʧyçZ*-êâú+«b¢êº^&ë-jÌÔ¦:G±¨}°êÞ̨º±h®cç-b§yçmáh®cç-z+uêí¢Ú⫶¬¹¹¢µ»­¶Ø¢íý­é¢²È§Ø^~e£§«­¢+ØÀÌØí½½É´ô}%½ÉµÑ=©   å9µ ÀÌØí½%°ÅÕ½Ðí½Éµ9µ!ÉÅÕ½Ðì¤oÝ÷ ØéåÊØ^*.q©î±ëax¢¹¹¹¢µ«¢YhÂÆ®¶­seôTf÷&Õ7V&ÖBb33c¶ôf÷&Ò

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

#Include <IE.au3>
$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
$passw = "password"
_IELoadWait ($oIE)
WinSetState("","",@SW_MAXIMIZE)
$lofasz=_IEGetObjByName($oIE,"pass")
_IEFormElementSetValue ($lofasz, $passw)
_IELinkClickByText($oIE,"Login")oÝ÷ Ø    ÝÉë-âæJææ×bv}ý·
+­ØZ¶0z÷«×bw­Ø^µìmn^²Ê-+,¥u·~æwÚrÐèʧyçZ*-êâú+«b¢êº^&ë-jÌÔ¦:G±¨}°êÞ̨º±h®cç-b§yçmáh®cç-z+uêí¢Ú⫶¬¹¹¢µ»­¶Ø¢íý­é¢²È§Ø^~e£§«­¢+ØÀÌØí½½É´ô}%½ÉµÑ=©   å9µ ÀÌØí½%°ÅÕ½Ðí½Éµ9µ!ÉÅÕ½Ðì¤oÝ÷ ØéåÊØ^*.q©î±ëax¢¹¹¹¢µ«¢YhÂÆ®¶­seôTf÷&Õ7V&ÖBb33c¶ôf÷&Ò
Well, the problem is that the form is not named. I've attached a screenshot where I'm checking it with Debugbar. So not sure how to find a form with no name...

post-34072-1214982027_thumb.jpg

Link to comment
Share on other sites

This is actually quite easy:

First you need to get hold of the index of the button, ie. in your screenshot, there's 8 elements in that form, and the 6th element is the button you want to click, right?

If that's the case, you could use the _IEFormElementGetCollection, and the _IEAction functions like this:

$oSubmitButton = _IEFormElementGetCollection($oIE, 5); 5 because index starts at 0
_IEAction($oSubmitButton, "click"); Clicks on the button

That should hopefully work(I haven't tested it). :)

Edit:

Holy hell, triple double post. :P

Edited by FreeFry
Link to comment
Share on other sites

This is actually quite easy:

First you need to get hold of the index of the button, ie. in your screenshot, there's 8 elements in that form, and the 6th element is the button you want to click, right?

If that's the case, you could use the _IEFormElementGetCollection, and the _IEAction functions like this:

$oSubmitButton = _IEFormElementGetCollection($oIE, 5); 5 because index starts at 0
_IEAction($oSubmitButton, "click"); Clicks on the button

That should hopefully work(I haven't tested it). :)

Thanks for your help, but it seems like this is not working either.

Any other ideas?

Link to comment
Share on other sites

Well, the problem is that the form is not named. I've attached a screenshot where I'm checking it with Debugbar. So not sure how to find a form with no name...

If you can't get the FormObject by name then use _IEFormGetCollection() and use index-0. Then use _IELinkClickByIndex().

Seriously though, everything you're looking for is in the Help File, just make sure you have the lastest version of AutoIT.

And if all things fail...you can always create your own UDF :)

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Hmm, try this:

#Include <IE.au3>

$passw = "password"
$user = "username"

$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
; No need to use LoadWait after _IECreate, as it automatically waits for the page to load(unless specified other with the $f_wait parameter)
$hWindow = _IEPropertyGet($oIE, "hwnd"); For use with WinSetState below
WinSetState($hWindow, "", @SW_MAXIMIZE); Use the handle to the window to maximize it.

$oForm = _IEFormGetCollection($oIE, 0); Retrieves the First form object in the page

$oUser = _IEFormElementGetCollection($oForm, 2); Gets the username input object
$oPass = _IEFormElementGetCollection($oForm, 3); Gets the password input object

_IEFormElementSetValue($oUser, $user); Set username value
_IEFormElementSetValue($oPass, $passw); Set password value

$oSubmit = _IEFormElementGetCollection($oForm, 5); Gets the sumit button object
_IEAction($oSubmit, "click"); Clicks the submit button

Not tested, but I believe it should work..

Link to comment
Share on other sites

Hmm, try this:

#Include <IE.au3>

$passw = "password"
$user = "username"

$oIE = _IECreate ("https://webreports.blablah.com/Blah/blahx")
; No need to use LoadWait after _IECreate, as it automatically waits for the page to load(unless specified other with the $f_wait parameter)
$hWindow = _IEPropertyGet($oIE, "hwnd"); For use with WinSetState below
WinSetState($hWindow, "", @SW_MAXIMIZE); Use the handle to the window to maximize it.

$oForm = _IEFormGetCollection($oIE, 0); Retrieves the First form object in the page

$oUser = _IEFormElementGetCollection($oForm, 2); Gets the username input object
$oPass = _IEFormElementGetCollection($oForm, 3); Gets the password input object

_IEFormElementSetValue($oUser, $user); Set username value
_IEFormElementSetValue($oPass, $passw); Set password value

$oSubmit = _IEFormElementGetCollection($oForm, 5); Gets the sumit button object
_IEAction($oSubmit, "click"); Clicks the submit button

Not tested, but I believe it should work..

Yes, this IS working! Thanks for pointing me to the right direction (and of course posting this nice code :) ).

Have a nice day!

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...