AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Automation IE7 Navigation and Scripting with Tabs
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  

Do you find this group pf wrapper functions for IE Automation Usefull
no you suck
8%
 8%  [ 2 ]
need better Documentation
29%
 29%  [ 7 ]
What is DHTML i dont understand how this helps
8%
 8%  [ 2 ]
I use Firefox this is a stupid idea
33%
 33%  [ 8 ]
I know DHTML this is a reasonably good AHK adaption
4%
 4%  [ 1 ]
This is the best DHTML too in the AHK Forum
16%
 16%  [ 4 ]
Total Votes : 24

Author Message
rani



Joined: 18 Mar 2008
Posts: 95

PostPosted: Sat Jul 12, 2008 2:21 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat Jul 12, 2008 3:29 pm    Post subject: Reply with quote

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
Code:
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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat Aug 02, 2008 2:18 pm    Post subject: Reply with quote

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
Code:
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
Return
of 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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 4:11 pm    Post subject: Reply with quote

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
Code:
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?
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 4:20 pm    Post subject: Reply with quote

Do you get anything when you type...
Code:

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.
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 4:35 pm    Post subject: Reply with quote

Yes, inside JS it works fine, "text" has a value and i'm running IE7. Any ideas?
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 5:59 pm    Post subject: Reply with quote

Quote:

Code:
COM_Init()

wh := IE7_Get("<insert name of tab here - not site>")

js := "var text=document.form1.wo1.value"
IE7_ExecuteJS(wh, js, "text")
MSgBox %text%



here's an ugly but working example
Code:

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
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 6:14 pm    Post subject: Reply with quote

Yes, this is working, but i don't get why your example works and mine doesn't:
Code:
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?
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 6:21 pm    Post subject: Reply with quote

ok, i get it now i had to do it like this:

Code:
val := IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val")


Thanks!
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 6:21 pm    Post subject: Reply with quote

neXt wrote:
Yes, this is working, but i don't get why your example works and mine doesn't:
Code:
COM_Init()
wh := IE7_Get("Google")
val := IE7_ExecuteJS(wh, "var x=document.f.q; x.value='this is a test'; var val=x.value; alert(val)", "val")
MsgBOx %val%

Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 6:22 pm    Post subject: Reply with quote

See you got it on your own. Nice...
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 6:49 pm    Post subject: Reply with quote

CannedCheese, no, i got it thanks to your examples.
_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 7:04 pm    Post subject: Reply with quote

neXt wrote:
ok, i get it now i had to do it like this:

Code:
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
Code:

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.
Back to top
View user's profile Send private message
neXt



Joined: 18 Mar 2007
Posts: 463

PostPosted: Mon Aug 04, 2008 7:26 pm    Post subject: Reply with quote

Hmm strange, this works fine for me:
Code:
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%

_________________
simplified csv - easy way to handle csv files.
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Aug 04, 2008 7:43 pm    Post subject: Reply with quote

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
Code:

IfWinExist Google

to
Code:

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
Code:

myPageHandle := IE7_Get("Google")
if myPageHandle = 0
IE7_New("www.google.com")
...


or something like that.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 4 of 8

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group