Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Control Web Page


  • Please log in to reply
30 replies to this topic
jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
Where there frames in the webpage? (javascript: alert(frames.length)) If so, review the discussion above on how to access an element in a frame.

Example:
javascript: alert(frames['[color=red]frame_name/id[/color]'].document.all['[color=red]element_name/id[/color]'].value)

NOTE - you may have to go more than one frame in depth - ie:
frame[].frame[].frame[].document.all[].value


Vanessa
  • Guests
  • Last active:
  • Joined: --
This one works
javascript: alert(frames.length)
The result was "2"

How to access the elements in the frame?

Thank you for your patience

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
What does iWebBrowser2 Learner give you in the Frames box as you hover over the element?

vanessa
  • Guests
  • Last active:
  • Joined: --

What does iWebBrowser2 Learner give you in the Frames box as you hover over the element?


Example:
[innertext]=CCF Registo

[FRAME].1 **[sourceIndex]=28 **[name]= _sweclient **[id]=
[FRAME].2 **[sourceIndex]=10 **[name]= _swecontent **[id]=
[FRAME].3 **[sourceIndex]=12 **[name]= _sweview **[id]=
[FRAME].4 **[sourceIndex]=5 **[name]= _svf1 **[id]=


tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Apr 19 2019 05:49 PM
  • Joined: 21 Dec 2007
com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[[color=red]element name id or ordinal[/color]].[color=red]methodOrProperty[/color]")


com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[s_1_1_223_0_mb].click")
Framdoc:=com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document")
iweb_clicktext(Framdoc,"CCF Registo") ;use the iweb function to click some text without knowing any id or name for the element




or use soemthing like this
element:=IE_Find("CCF Registo")
Com_invoke(element,"click")

IE_Find(needle,win="A",property="",offset=0)
{
	If	(win=="A")
		WinGetTitle,win,%win% ahk_class IEFrame
	StringSplit,wins,win,-
	_autotrim:=A_AutoTrim
	AutoTrim,On	
	wins1=%wins1%
	AutoTrim,%_autotrim%
	If	psh	:=	COM_CreateObject("Shell.Application") {
		If	psw	:=	COM_Invoke(psh,	"Windows") {
			Loop, %	COM_Invoke(psw,	"Count")
				If	pwb	:=	(InStr(COM_Invoke(psw,"Item[" A_Index-1 "].LocationName"),wins1)   && InStr(COM_Invoke(psw,"Item[" A_Index-1 "].FullName"), "iexplore.exe")) ? COM_Invoke(psw,"Item", A_Index-1) :
					Break
			COM_Release(psw)
		}
		COM_Release(psh)
	}
	If	!pwb
		Return
	If	!pWin:=COM_QueryService(pwb,	"{332C4427-26CB-11D0-B483-00C04FD90119}",	"{332C4427-26CB-11D0-B483-00C04FD90119}")
	{
		COM_Release(pwb)
		Return
	}	
	If	oRange:=COM_Invoke(pWin,"document.body.createTextRange")
	{
		COM_Invoke(oRange,"findText",needle)
		_res:=property ? COM_Invoke(pWin,"Document.all.item[" COM_Invoke(oRange,"parentElement.sourceIndex")+offset "]." property) :  COM_Invoke(pWin,"Document.all.item", COM_Invoke(oRange,"parentElement.sourceIndex")+offset)
		COM_Release(oRange)
	}	
	COM_Release(pWin)
	COM_Release(pwb)
	Return	_res
}

Never lose.
WIN or LEARN.

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
As far as javascript, I think this should work:
javascript: frames['[color=red]_sweclient[/color]'].frames['[color=red]_swecontent[/color]'].frames['[color=red]_sweview[/color]'].frames['[color=red]_svf1[/color]'].document.all['[color=red]s_1_1_223_0_mb[/color]'].click()


vanessa
  • Guests
  • Last active:
  • Joined: --
I’ve tried the javascript and it works :-) :-) :-) Eureka!!!

The COM will try next. What is the best way to feed the address bar with the javascript command’s? preferably Imperceptibly…

Thanks a lot!

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

What is the best way to feed the address bar with the javascript command’s?

I would recommend the Control commands. However, COM is fantastically more effective if you're using Internet Explorer.

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
I just tried this method of 'working down the frames' on a problem I had previously had mentioned in this thread, works perfect now. Thanks to both you guys.

Vanessa
  • Guests
  • Last active:
  • Joined: --
I´m not getting the COM examples working . It gives the error:
Function Name: "document"
ERROR: The COM Object may not be a valid Dispatch Object
First Ensure that COM Library has been initialized through COM_Init ().
Will Continue?


What am I doing wrong? I think is something with the "pwb"... my code is something like:

#Include C:\Program Files\AutoHotkey\COM.ahk
...
COM_Init()
...
F1::
{
...
pwb:=iWeb_getwin("ONE - Produção - Servidor 10 - Microsoft Internet Explorer") com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[s_2_1_10_0_mb].click")
...
}



Thanks

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Apr 19 2019 05:49 PM
  • Joined: 21 Dec 2007

I´m not getting the COM examples working . It gives the error:
Function Name: "document"
ERROR: The COM Object may not be a valid Dispatch Object
First Ensure that COM Library has been initialized through COM_Init ().
Will Continue?


What am I doing wrong? I think is something with the "pwb"... my code is something like:

#Include C:\Program Files\AutoHotkey\COM.ahk
...
COM_Init()
...
F1::
{
...
pwb:=iWeb_getwin("ONE - Produção - Servidor 10
- Microsoft Internet Explorer") com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[s_2_1_10_0_mb].click")
...
}



Thanks

firstly remove the browser suffix which isnt actually part of the page name

Also if you could bring yourself to use code tags it would be awesome :!: :idea: :!: :D
[code]some ahk code[/code]

Never lose.
WIN or LEARN.

Vanessa
  • Guests
  • Last active:
  • Joined: --
Sorry :-)
The error change to:
Function Name: "click"
ERROR: The COM Object may not be a valid Dispatch Object
First Ensure that COM Library has been initialized through COM_Init ().
Will Continue?

Any ideas?

#Include C:\Program Files\AutoHotkey\COM.ahk
COM_Init()
F1::
{
pwb:=iWeb_getwin("ONE - Produção - Servidor 10") com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[s_2_1_10_0_mb].click")
}
return


tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Apr 19 2019 05:49 PM
  • Joined: 21 Dec 2007
ok i see you have everything on the same line this is part of the problem as well
#Include C:\Program Files\AutoHotkey\COM.ahk
COM_Init()
F1::
{
pwb:=iWeb_getwin("ONE - Produção - Servidor 10") 
com_invoke(pwb,"document.all[28].contentwindow.document.all[10].contentwindow.document.all[12].contentwindow.document.all[5].contentwindow.document.all[s_2_1_10_0_mb].click")
}
return

Never lose.
WIN or LEARN.

Vanessa
  • Guests
  • Last active:
  • Joined: --

ok i see you have everything on the same line this is part of the problem as well


What you mean Tank? What should I do?

Thanks

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Apr 19 2019 05:49 PM
  • Joined: 21 Dec 2007
I posted amended code did you try it
you had com_invoke on same line with the iweb_getwin
Never lose.
WIN or LEARN.