AutoHotkey Community

It is currently May 27th, 2012, 12:59 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 20th, 2011, 10:36 pm 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
I'm trying to convert a piece of my old code over to Autohotkey_L - without success.

Code:
frames := Com_Invoke(pwb, "document.all.tags", "iframe")
Length := Com_Invoke(frames, "length")
Loop, %Length%
{
   frame := Com_Invoke(frames, "item", A_Index-1)
   id := Com_Invoke(frame, "id")

   pWin := iWeb_DomWin(pwb,id)
   Collection := COM_Invoke(pWin, "document.getElementsByTagName[INPUT].length")
   Loop %Collection%
   {
      found := COM_Invoke(pWin, "document.getElementsByTagName[INPUT].item[" A_Index-1 "].outerhtml")
      msgbox, %found%
   }
}


Could someone show me any easy way to get this working in Autohotkey_L?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 4:58 am 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
Ok, can anyone let me know what I'm doing wrong here?

I'm trying to loop through iframes and disaply all the "input" tags.

Code:
      Loop % pwb.document.all.tags("iframe").length
      {
         id := pwb.document.all.tags("iframe").item[A_Index-1].id
         IID := "{332C4427-26CB-11D0-B483-00C04FD90119}"
         pweb := ComObjQuery(pwb, IID, IID)
         frame := pweb.document.frames[id].contentwindow
         ObjRelease(pweb)
         pweb := ComObjQuery(frame, IID, IID)
         ObjRelease(frame)


         tags := pweb.document.getElementsByTagName("input").length
         Loop %tags%
         {
            found := pweb.document.getElementsByTagName("input")[A_Index-1].outerhtml
            msgbox, %found%
         }
      }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 6:46 am 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
I think I may have narrowed down part of the problem.

Normal AHK
Code:
frames := Com_Invoke(pwb, "document.all.tags", "iframe")
msgbox, %frames%

This produces a number like 35687480


AHK_L
Code:
frames := pwb.document.all.tags("iframe")
msgbox, %frames%


The message box is empty. Why is this?

Do I have the wrong syntax for AHK_L?


Last edited by ecksphore on October 21st, 2011, 8:15 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 12:24 pm 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
because when you get "all.tags" it gets an array of "iframe" so you must find a property to use IN the iframe

Exampel with a "Select" (DropDownList) :
Code:
Doc := WB.document
Select := Doc.getElementsByName["NameOfTheList"]
Options := Select[0].all.tags("option")
NumOptions := Options.length


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2011, 6:14 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
frames := WB.document.all.tags("iframe")
Loop, % frames.length
{
   frame := frames[A_Index-1]
   Win := _DomWin(WB, frame.id)
   Collection := Win.document.getElementsByTagName("input")
   Loop, % Collection.length
      MsgBox, % found := Collection[A_Index-1].outerHTML
}

_DomWin(pdsp,frm="") {
   static IID :="{332C4427-26CB-11D0-B483-00C04FD90119}"
   if pWin := ComObjQuery(pdsp, IID, IID) {
      Loop, Parse, frm, `,
      {
         Win := ComObj(9, pWin, 1)
         frame := Win.document.all(A_LoopField).contentWindow
         if Not pWin := ComObjQuery(frame, IID, IID)
            return, false
      }
      return, ComObj(9, pWin, 1)
   }   
   return, false
}

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2011, 3:53 am 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
Thank you very much guys!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2012, 9:46 pm 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
jethrow, it appears I'm having an issue where the website has an iframe within an iframe.

It is possible to modify your code to handle those?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Google Feedfetcher, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group