COM onclick=

Get help with using AutoHotkey and its commands and hotkeys
Trigg
Posts: 97
Joined: 07 Apr 2017, 19:43

COM onclick=

18 Aug 2017, 08:57

For some reason I can't click this link that says "Add task". I've tried a couple methods, but I'm not very good with COM especially when my object has no ID.

Does anyone have any suggestions or links?

Thank you :)

Code: Select all

;#LHS_actionsDiv > table > tbody > tr:nth-child(5) > td > div.igActionContentSpacing > a	Selector
;//*[@id="LHS_actionsDiv"]/table/tbody/tr[5]/td/div[2]/a							XPath
;<a href="#" onclick="showAddDiary ();">Add task </a>							Element

2::
If !IsObject(ICwb)
	ICwb := IEGet("Innovation insurer")

;ICwb.document.getElementById("LHS_actionsDiv").InnerHTML.onclick := "Add task"

;While ( value <> "Add task" )                                                                               
;    value           := ICwb.document.getElementsByTagName("a")[ A_Index].innerText, index := A_Index
;ICwb.document.getElementsByTagName( "a")[ index].Click()     

Return
User avatar
tank
Posts: 2847
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: COM onclick=

18 Aug 2017, 09:37

You're close ... use a_index-1 in both places
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
Trigg
Posts: 97
Joined: 07 Apr 2017, 19:43

Re: COM onclick=

18 Aug 2017, 10:01

tank wrote:You're close ... use a_index-1 in both places
Alright. I added A_Index-1 to both, but now I'm receiving an error. "Error: 0x80020006 - Unknown name. Specifically: 124".

Code: Select all

;#LHS_actionsDiv > table > tbody > tr:nth-child(5) > td > div.igActionContentSpacing > a
;//*[@id="LHS_actionsDiv"]/table/tbody/tr[5]/td/div[2]/a
;<a href="#" onclick="showAddDiary ();">Add task </a>

2::
If !IsObject(ICwb)
	ICwb := IEGet("Innovation insurer")
value := ""
While ( value <> "Add task" )                                                                               
    value           := ICwb.document.getElementsByTagName("a")[ A_Index-1].innerText, index := A_Index-1
ICwb.document.getElementsByTagName( "a")[ index].Click() 

Return
just me
Posts: 7388
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: COM onclick=

18 Aug 2017, 11:01

You might want to try:

Code: Select all

Elements := ICwb.Document.getElementsByTagName("a")
Index := 0
Loop, % Elements.Length
{
   If (Elements[Index].innerText = "Add task")
      Break
   Index++
}
If (Index < Elements.Length) ; found
   Elements[Index].Click()
Else
   MsgBox, Didn't find "Add task" tag!
BTW: I don't know if it's relevant, but if

Code: Select all

<a href="#" onclick="showAddDiary ();">Add task </a> ; with blank
(value <> "Add task") ; without blank
Is it a typo?
Trigg
Posts: 97
Joined: 07 Apr 2017, 19:43

Re: COM onclick=

18 Aug 2017, 11:24

WOW. I can't believe I missed that. The space "Add task " was the issue. Thank you lol. I feel like an idiot that I didn't see that :wtf:
just me wrote:You might want to try:

Code: Select all

Elements := ICwb.Document.getElementsByTagName("a")
Index := 0
Loop, % Elements.Length
{
   If (Elements[Index].innerText = "Add task")
      Break
   Index++
}
If (Index < Elements.Length) ; found
   Elements[Index].Click()
Else
   MsgBox, Didn't find "Add task" tag!
BTW: I don't know if it's relevant, but if

Code: Select all

<a href="#" onclick="showAddDiary ();">Add task </a> ; with blank
(value <> "Add task") ; without blank
Is it a typo?

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], mcl, ronboprime, zhainv2013 and 48 guests