referencing a COM element img

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dytanaka
Posts: 10
Joined: 23 Nov 2013, 13:46

referencing a COM element img

14 Feb 2014, 18:36

Hi,

I am trying find a different way to reference an image that is a button.
This is the Exit object:

Code: Select all

<span style="position: absolute; top: 2px; cursor: pointer; left: 0px;">
<img title="Exit to Menu" class="" id="" onclick="ckSubmit(document.main,"menu.php",true);" src="../images/btn_close.jpg" complete="complete"/>
</img/>
This is the change object in the browser:

Code: Select all

<span style="position: absolute; top: 0px; cursor: pointer; left: 825px;">
<img title="Change" class="" id="" onclick="reqtype.value="MODIFY";submit();" src="../images/btn_edit.jpg" complete="complete"/>
</img/>
I currently reference it with:

Code: Select all

ie.document.getElementsByTagName("IMG")[3].Click()  ; The Done Button
The issue is that there are at times upto four images between the different in the screens (all the screens have the same name). The different screens that are returned are determined by the data returned. Then each screen has a different number of buttons. The buttons can be referenced by changing the image number ([3], [4]...) but the different buttons will change numbers between screens (basically "ADD", "EDIT", "CANCEL", "SEARCH", "DONE") might be a different number depending on the data returned. So my question is is there a way to reference the objects by (img title="Change") or call the onclick using the method it's calling i.e. (onclick="reqtype.value="MODIFY";submit();) . This would enable me to be more exact because you don't know what data will be returned.

Thanks

David
jpginc
Posts: 124
Joined: 29 Sep 2013, 22:35

Re: referencing a COM element img

16 Feb 2014, 23:40

I haven't tested this but I think it will still work

Code: Select all

images := ie.document.getElementsByTagName("IMG")

Loop, % images.length
{   if(images[A_index].title == "Change")
    {   images[A_Index].click()
        break
    }
}
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: referencing a COM element img

17 Feb 2014, 01:15

Remember when looping the elements like that to use A_Index-1 as DOM collections are zero based ;)
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
dytanaka
Posts: 10
Joined: 23 Nov 2013, 13:46

Re: referencing a COM element img

21 Feb 2014, 19:48

Hey There,

Thank you very much works great. Sorry it took so long to respond had to work on another project.

Thanks Again

David

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: pond_pop and 325 guests