Jump to content

IE controll ID


Recommended Posts

Hello,

Is there a way to get the controllID of an IE button if there is not NAME or ID at the source code.

What i mean is this:

<input tabIndex="1" class="button" accessKey="s" type="submit" value="Reset"/>

this is a button and i dont know how can i get the controllID of it since until now i was using

_IEGetObjById  ...or...   _IEGetObjByName

Is there another way to do it???

Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

I often have a need to do this so wrote this general function that allows using a variety of alternative elements you can grab - it is quite straightforward but let me know if you need any explanation - no doubt it can be tidied up - but it does the job for me:

; Return $element on specified form of type "class/name/id/value..." etc with a given text label eg "submit" or "OK", which occurrance number (if the text value can appear more than once in the html code) and a html tag like "input/div/a..." etc
Func GetFormElement($form_name, $type, $label, $count = 1, $tag = "", $oIE)
Local $form, $element, $elements, $i = 1
If $form_name <> "" Then $form = _IEFormGetObjByName($oIE, $form_name)
If $form_name = "" Or @error Then
  If $tag = "" Then
   $elements = _IETagNameAllGetCollection($oIE)
  Else
   $elements = _IETagNameGetCollection($oIE, $tag)
  EndIf
Else
  $elements = _IEFormElementGetCollection($form)
EndIf
For $element In $elements
  Switch $type
   Case "class"
    If _IEPropertyGet($element, "class") And StringInStr($element.class, $label) Then
     If $i = $count Then Return $element
     $i += 1
    EndIf
   Case "id"
    If _IEPropertyGet($element, "id") And StringInStr($element.id, $label) Then
     If $i = $count Then Return $element
     $i += 1
    EndIf
   Case "name"
    If _IEPropertyGet($element, "name") And $element.name = $label Then
     If $i = $count Then Return $element
     $i += 1
    EndIf
   Case "value", "title"
    If StringInStr($element.outerhtml, $label, 1) And StringInStr($element.outerhtml, $type) Then
     If $i = $count Then
      If Not $LIVE Then ConsoleWrite("GETFORMELEMENT : 1  " & $element.outerhtml & @CRLF)
      Return $element
     EndIf
     $i += 1
    EndIf
   Case "misc"
    If StringInStr($element.outerhtml, $label) Then
     If $i = $count Then Return $element
     $i += 1
    EndIf
  EndSwitch
Next
Return 0
EndFunc   ;==>GetFormElement
Edited by DelStone
Link to comment
Share on other sites

See _IETagnameGetCollection()

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

Link to comment
Share on other sites

Dale

I managed this but i dont know why its not working...

#include <IE.au3>
Local $idctrl
Local $oIE = _IECreate($url)
Local $oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
if $oInput.type = "submit" And $oInput.value = "Log in" And $oInput.tabIndex = "1" Then $idctrl = $oInputs
Next

This should work right??? I cant find these

_IETagNameGetCollection($s_TagName)
...

Edit: I made it work. I just had some mistakes in my script and removed this

And $oInputs.class = "button"

Thanks Dale

Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

Dale,

I have an input and i want to get controlID of it. There is no name or id at the source code. From the script of the page (source code) i got the script of it.

Its a listbox input. This is the html code from the source code

<textarea class="readonly multilinebox" onclick="this.select(); pageTracker._trackEvent('new-done-click','direct-click');" wrap="off" readOnly="" jQuery1334144828381="37">

I am trying to use

_IEFormElementGetValue()

but i get this error

--> IE.au3 V2.4-0 Error from function _IEFormElementGetValue, $_IEStatus_InvalidDataType

What can i do???

I feel nothing.It feels great.

Link to comment
Share on other sites

Build a reproducer. You do not provide enough information to help you.

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

Link to comment
Share on other sites

Well i am sorry again. I usually dont provide enought but i dont really know how.

The above is a input with a url of this website http://imageshack.us/

After uploading a image there, i want to get the controlID of the input "Direct Link" at the next page.I loging the page with my account and when i try to find the controlID of that input it gives me the text above from the html source code. I tried _IETagnameGetCollection() but after getting the controlID it doesnt accept commands...

I feel nothing.It feels great.

Link to comment
Share on other sites

#include <IE.au3>
Local $button
$oIE = _IECreate("[url="http://imageshack.us/"]http://imageshack.us/[/url]")
 $oForm = _IEGetObjByName($oIE, "fileupload")
_IEAction($oForm, "click")
$upl = _IEGetObjById($oIE, "text")
_IEAction($upl, "click")
_IELoadWait($oIE)
Sleep(10000)
Local $oInputs = _IETagNameGetCollection($oIE, "input")
for $oInput in $oInputs
if $oInput.onclick = "this.select(); pageTracker._trackEvent('new-done-click','direct-click');" And $oInput.class = "readonly multilinebox"  Then $button = $oInput
Next
$val = _IEFormElementGetValue($button)
MsgBox(0,"tittle", $val)

I feel nothing.It feels great.

Link to comment
Share on other sites

Here is your example with some debugging code added and some other cleanup.

#include <IE.au3>

Dim $button

$oIE = _IECreate([url="http://imageshack.us/"]http://imageshack.us/[/url])

$oForm = _IEGetObjByName($oIE, "fileupload")
_IEAction($oForm, "click")

$upl = _IEGetObjById($oIE, "text")
_IEAction($upl, "click")

_IELoadWait($oIE)
Sleep(10000)

$oInputs = _IETagNameGetCollection($oIE, "input")

For $oInput In $oInputs
If String($oInput.onclick) = "this.select(); pageTracker._trackEvent('new-done-click','direct-click');" _
  And String($oInput.classname) = "readonly multilinebox" Then
  ;;;
  $button = $oInput
  ConsoleWrite(">> We found it: " & _IEPropertyGet($oInput, "outerhtml") & @LF)
  ExitLoop
Else
  ConsoleWrite("** Not this one: " & _IEPropertyGet($oInput, "outerhtml") & @LF)
EndIf
Next

If IsObj($button) Then
    $val = _IEFormElementGetValue($button)
    MsgBox(0, "tittle", $val)
Else
    ConsoleWrite("We never found the right button" & @LF)
EndIf

Exit

There are 6 iFrames on the page, so if everything else is correct, I'd suggest the object you are trying to reference in nested in one of them.

Dale

Edited by DaleHohm

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

Link to comment
Share on other sites

I had no idea of this code you just made. I'm surprised!!!

At the consolorite it find its but it set it that "Not this one:"

I find this one contains the url.

** Not this one: <input class="readonly" onclick="this.select(); pageTracker._trackEvent('new-done-click','shareable-click');" readOnly="" value="<noscript>[URL=http://imageshack.us/photo/my-images/705/loguu.png/][IMG]http://img705.imageshack.us/img705/9624/loguu.png[/IMG][/URL]</noscript>" jQuery1334269316418="38">

I changed this line and got sth different if you want to check it.

$oInputs = _IETagNameGetCollection($oIE, "textarea")
Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

I have no idea what you are trying to say.

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

Link to comment
Share on other sites

As i hope you know what i want to do with this script is that i want to take the url that is inside the input "Direct Link" after the upload...

With the script you gave me, in one of the console writes there is the url. But the script gives the resaults that is not that one...

I feel nothing.It feels great.

Link to comment
Share on other sites

I think you'd better look again. You are definitely wasting our time now - you should be able to take it from here.

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

Link to comment
Share on other sites

I know i should but there are some bugs i think.... I do everything i have to do and it still doesnt get the controlID of it....

Have you tried it??? You will come out with the same if you try it.

If you dont want its fine...

I feel nothing.It feels great.

Link to comment
Share on other sites

I wasn't trying to write your code for you, I was trying to show you debugging techniques. You need to learn from it and solve the problem yourself - or not, your choice. You'll have a hard time getting help here until you invest in your own code and your own skills.

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

Link to comment
Share on other sites

Dear Dale,

I am using _IEFormElementSetValue($text, "Bonjour") to set the value of a edit in a website.

My code was working fine until the website updated. Now when i use my code it set the value but it is not visible.

If i move forward navigating another site and then return at my website the value i had set appears. I dont know why. Is there something to do?

Is this a bug??? I checked the source code and the controlID name of it it hasnt change. I cant post a working code because it requies log in.

Please if you could give me an advice or some tips. Everything will be appreciated.

Edited by ileandros

I feel nothing.It feels great.

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