Help for IE page COM automation Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Help for IE page COM automation

28 Jan 2020, 03:18

Hi, i have a multiple web page of user and every page have a hundred of "IDENTITY_Number" with two button on the right, Delete and Modify.
For example I have 20 IDENTITY_NUMBER and I have to click 20 times on the button on the right to Delete the qualifications

Code: Select all

<tr> 
	<td>Annullamento</td> 
	<td>Pratica</td> 
	<td>Operatore</td> 
	<td>Notifica</td> 
	<td>1</td> 
	<td>NAME</td> 
	<td>SURNAME</td> 
	<td>0123456789</td> ; IDENTITY_NUMBER
	<td>ATTIVO</td> 
	<td> <a href="https://id/link_108161">Delete</a> ; link to click
			<!-- In caso ... --> 
		<a href="https://id/link_8057">Modify</a> 
	</td> 
</tr>
I'm probably wrong about grammar

Code: Select all

	IE :=   ;Cleanup, optional but advised if this is a persistent script.
	IE := IEGet() ;Retrieve pointer to existing IE window/tab

	input := IE.document.getElementsByTagName("TR")             
		; loop through list of <input> tags
		loop, % input.Length ;% Loop
		{	
			; find <input> tag by name
			if ( input[(A_index-1)].InnerHTML == "0123456789" ){
			MsgBox Trovato
			break ; break loop
			}
		}

Return
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Help for IE page COM automation

28 Jan 2020, 03:38

following code is supposed to look for InnerText having "0123456789" and click on 3rd tag which having href

Code: Select all

input := IE.document.getElementsByTagName("TR")  
While ( input[ A_Index - 1 ].InnerText != "0123456789" )
	{
		input[ A_Index + 1].getElementsByTagName("a")[ 0 ].click()   ; this is "<a" tag a and has href
		href := input[ A_Index + 1].getElementsByTagName("a")[ 0 ].href	; copy href
		msgbox, % href

		;try input[ A_Index - 1 ].getElementsByTagName("a")[ 0 ].click() ; <td>0123456789</td> has no tag A "<a" will not work
		;try input[ A_Index ].getElementsByTagName("a")[ 0 ].click()     ; this is ATTIVO and click will not work either
	}
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Help for IE page COM automation

28 Jan 2020, 04:01

problem, with this i found nothing :(

Code: Select all

	input := IE.document.getElementsByTagName("TR")             
		; loop through list of <input> tags
		loop, % input.Length ;% Loop
		{	
			; find <input> tag by name
			if ( input[(A_index-1)].InnerTEXT == "0123456789" ){  ; change to InnerTEXT
			MsgBox FOUND
			break ; break loop
			}
		}

Return
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Help for IE page COM automation

28 Jan 2020, 04:10

scriptors wrote:
28 Jan 2020, 04:01
problem, with this i found nothing :(
you have posted same code

but following code can also through same msgbox and you can also break while loop

Code: Select all

input := IE.document.getElementsByTagName("TR")  
While ( input[ A_Index - 1 ].InnerText != "0123456789" )
	msgbox, tag found having % input[ A_Index - 1 ].InnerText
and you can click 3 tag which has href

Code: Select all

input := IE.document.getElementsByTagName("TR")             
		; loop through list of <input> tags
loop, % input.Length ;% Loop
{	
			; find <input> tag by name
	if ( input[(A_index-1)].InnerTEXT == "0123456789" ){  ; change to InnerTEXT
		MsgBox FOUND
		input[(A_index+1)].click() ; this will be click on 3rd tag after found tag
		break ; break loop
	}
}
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Help for IE page COM automation

28 Jan 2020, 04:12

"0123456789" are into TD so:

Code: Select all

	input := IE.document.getElementsByTagName("TD")             
		; loop through list of <input> tags
		loop, % input.Length ;% Loop
		{	
			; find <input> tag by name
			if ( input[(A_index-1)].InnerTEXT == "0123456789" ){  ; change to InnerTEXT
			MsgBox FOUND
			break ; break loop
			}
		}

Return
this FOUND "InnerTEXT " ... so i try with your script
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Help for IE page COM automation  Topic is solved

28 Jan 2020, 04:26

:think:

Code: Select all

input := IE.document.getElementsByTagName("TR")             
		; loop through list of <input> tags
loop, % input.Length ;% Loop
{	
			; find <input> tag by name
	if ( input[(A_index-1)].InnerTEXT = "0123456789" ){  ; change to InnerTEXT
		MsgBox FOUND
		Buttons := input[(A_index+1)].getElementsByTagName("a") ; this will be click on 3rd tag after found tag which has buttons
		loop, % Buttons.Length ;% Loop
		{
			if ( Buttons[(A_index-1)].InnerTEXT = "Delete" )
				delete := Buttons[(A_index-1)]
			if ( Buttons[(A_index-1)].InnerTEXT = "Modify" )
				Modify := Buttons[(A_index-1)]
			break
		}
		break ; break loop
	}
}

; delete.click() ; to click delete 
 Modify.click() ; to click modify

; or 

url := Modify.href
IE.Navigate( url )
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Help for IE page COM automation

28 Jan 2020, 04:36

This work, just change "TR" to "TD" ... really thanks :clap:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Ineedhelplz and 230 guests