Hi Tank,
ok, now I understand the functionality of JS and AHK
what remain:
how I find an instance of specific,web page documnet
let say in IE6 ?
rgrds
Ell
Automation IE7 Navigation and Scripting with Tabs
Started by
tank
, Apr 09 2008 03:14 PM
214 replies to this topic
#46
-
Posted 12 July 2008 - 02:21 PM
that is specifically what IE7_Get does
first page mid way down
returns a window handle equal to what you do with oWin in your example script
the difference is i reference shell explorer but for a windows box its perfect
oh i think i see your confusion the functions are IE7
lets be clear all these functions work equal on ie6 or ie7 with or without tabs
example lets say you have a google page open
does that clear that up
this works in ie 6 and 7 not just 7
works in 7 with or without tabs
first page mid way down
returns a window handle equal to what you do with oWin in your example script
the difference is i reference shell explorer but for a windows box its perfect
oh i think i see your confusion the functions are IE7
lets be clear all these functions work equal on ie6 or ie7 with or without tabs
example lets say you have a google page open
COM_Init() parentWindow:=IE7_Get("Google") IE7_Set_DOM(parentWindow,"q","Automation IE7 Navigation and Scripting with Tabs") IE7_Button_click(parentWindow,"Google Search")
does that clear that up
this works in ie 6 and 7 not just 7
works in 7 with or without tabs
#47
-
Posted 12 July 2008 - 03:29 PM
Never lose.
WIN or LEARN.
WIN or LEARN.
many times i see posts wehre people want to disect a page
the following code has the following issues
traversing frames. at this time the dom viewer will not give you anything more than the frame atributes i might get to adding that soon
its pretty basic but on most pages it should give you detailed info about an html object and its atributes simply by rolling mouse over. including src of image
the following code has the following issues
traversing frames. at this time the dom viewer will not give you anything more than the frame atributes i might get to adding that soon
COM_Init() COM_Error(false) mouseover= ( function whichElement() { tname=event.srcElement.tagName; tindex=event.srcElement.sourceIndex; innerhtml=event.srcElement.innerHTML oAttrColl = event.srcElement.attributes; myLen=oAttrColl.length xx="Dom=document.all(" + tindex + ")\n"; xx=xx + "document.all(" + tindex + ").tagName=" + event.srcElement.tagName + "\n"; for (i = 0; i < oAttrColl.length; i++) { oAttr = oAttrColl.item(i); bSpecified = oAttr.specified; sName = oAttr.nodeName; vValue = oAttr.nodeValue; if (bSpecified) { xx=xx + sName + "=" + vValue + "\n"; } } xx=xx + "document.all(" + tindex + ").value=" + event.srcElement.value + "\n"; } document.body.onmouseover = whichElement ) Gui, Add, Button, x6 y0 w90 h20 gResume, Resume Gui, Add, Edit, x6 y20 w310 h315 vDom, Gui, Show, h335 w320, DOM Extractor Ctrl + / to freeze SetTimer,dom,800 Return GuiClose: ExitApp Resume: SetTimer,dom,800 Return dom: WinGetTitle,thispage,ahk_class IEFrame StringReplace,thispage,thispage,% " - Microsoft Internet Explorer",,All if thispage { ControlGetText,URL,Edit1,% thispage . "ahk_class IEFrame" parentWindow:=IE7_Get(thispage) IE7_ExecuteJS(parentWindow, mouseover) tname:=IE7_ExecuteJS(parentWindow, "","tname") tindex:=IE7_ExecuteJS(parentWindow, "","tindex") myLen:=IE7_ExecuteJS(parentWindow, "","myLen") xx:=IE7_ExecuteJS(parentWindow, "","xx") innerhtml:=IE7_ExecuteJS(parentWindow, "","innerhtml") GuiControl,Text,Dom,% thispage . " `n" . URL . " `nDom accessable objects for document`.all collection `nElement type (" . tname . ")`nIndex (" . tindex . ")`nAttributes if any `n" . xx . "`nVisible text= " . innerhtml com_release(parentWindow) parentWindow= } return ^/:: SetTimer,dom,Off Returnof course you need com and the ie7 functions
its pretty basic but on most pages it should give you detailed info about an html object and its atributes simply by rolling mouse over. including src of image
#48
-
Posted 02 August 2008 - 02:18 PM
Never lose.
WIN or LEARN.
WIN or LEARN.
I have a question about IE7_executeJS:
it has a third parameter "VarNames_to_Return" which isn't working out for me. As an example:
lets say document.form1.wo1.value = 555 i would like to retrieve this value.
i tried
What am i missing here?
it has a third parameter "VarNames_to_Return" which isn't working out for me. As an example:
lets say document.form1.wo1.value = 555 i would like to retrieve this value.
i tried
COM_Init() wh := IE7_Get("site.com") js := "var text=document.form1.wo1.value" IE7_ExecuteJS(wh, js, "text") MSgBox %text%but "text" returns as blank.
What am i missing here?
#49
-
Posted 04 August 2008 - 04:11 PM
Do you get anything when you type...
in IE?
If your javascript code is correct, it should return the value. Problem is, when your javascript is incorrect, you don't get an error message.
javascript: var text=document.form1.wo1.value; alert(text);
in IE?
If your javascript code is correct, it should return the value. Problem is, when your javascript is incorrect, you don't get an error message.
#50
-
Posted 04 August 2008 - 04:20 PM
Yes, inside JS it works fine, "text" has a value and i'm running IE7. Any ideas?
#51
-
Posted 04 August 2008 - 04:35 PM
COM_Init() wh := IE7_Get("[color=red]<insert name of tab here - not site>[/color]") js := "var text=document.form1.wo1.value" IE7_ExecuteJS(wh, js, "text") MSgBox %text%
here's an ugly but working example
Com_Init() IE7_New("www.google.com") myPageHandle := IE7_Get("Google") sleep, 1000 msgbox,,,myPageHandle: %myPageHandle%, 1 x := IE7_ExecuteJS(myPageHandle, "var x=document.getElementById('gbar').childNodes[0].childNodes[4].innerText;", "x") y := IE7_ExecuteJS(myPageHandle, "var x=document.getElementById('gbar').childNodes[0].childNodes[6].innerText;", "x") z := IE7_ExecuteJS(myPageHandle, "var x=document.getElementById('gbar').childNodes[0].childNodes[8].innerText", "x") msgbox,,, retrieved:`n%x%`n%y%`n%z%`nfrom www.google.com
let me know if this works
#52
-
Posted 04 August 2008 - 05:59 PM
Yes, this is working, but i don't get why your example works and mine doesn't:
COM_Init() wh := IE7_Get("Google") IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val") MsgBOx %val%any ideas?
#53
-
Posted 04 August 2008 - 06:14 PM
ok, i get it now i had to do it like this:
Thanks!
val := IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val")
Thanks!
#54
-
Posted 04 August 2008 - 06:21 PM
Yes, this is working, but i don't get why your example works and mine doesn't:
COM_Init() wh := IE7_Get("Google") [color=red]val := [/color]IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val") MsgBOx %val%
#55
-
Posted 04 August 2008 - 06:21 PM
CannedCheese, no, i got it thanks to your examples.
#57
-
Posted 04 August 2008 - 06:49 PM
ok, i get it now i had to do it like this:
val := IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val")
Thanks!
Can you please post your working code for your example? I can't get
IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val = x.value; alert(val)")
to do anything, even though it works fine when I plug it in the browser. With IE7_ExecuteJS, I can't get the alert to pop or the form to be filled.
#58
-
Posted 04 August 2008 - 07:04 PM
Hmm strange, this works fine for me:
SetTitleMatchMode 2 COM_Init() IfWinNotExist Google { IE7_New("http://www.google.com/") WinWait Google } wh := IE7_Get("Google") IE7_ReadyState(wh) js = ( var x = document.f.q; x.value = 'this is a test'; var val = x.value; alert('js popup: ' + val); ) val := IE7_ExecuteJS(wh, js, "val") MsgBox ahk popup: %val%
#59
-
Posted 04 August 2008 - 07:26 PM
Ok, this works for me, though I'll need to look into why my code wasn't working. For those messing around with this example, if you chose to use IfWinExist to look for a google browser window, I highly recommend at least changing
so that it isn't picking up incorrect windows like my GoogleTest.ahk or firefox google windows, etc. Probably better to use something like
or something like that.
IfWinExist Googleto
IfWinExist Google - Windows Internet
so that it isn't picking up incorrect windows like my GoogleTest.ahk or firefox google windows, etc. Probably better to use something like
myPageHandle := IE7_Get("Google") if myPageHandle = 0 IE7_New("www.google.com") ...
or something like that.
#60
-
Posted 04 August 2008 - 07:43 PM