AutoHotkey Community

It is currently May 27th, 2012, 12:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 226 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 16  Next
Author Message
 Post subject:
PostPosted: December 14th, 2009, 7:08 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
the rewrite im working on now will remove the list
you can use comas but requires you to convert each to an html entity

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 4:08 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
there is a new mostly updated iweb library
changes include
all functions set and get dom only accept one dom reference. Sorry but without using some very unusual delimiters there really wasnt a choice here

Since the code changes may possibly break some exisiting scripts ill waita week before i make these changes part of the current download link


Supports DOM references with a dot in it such as "fred.23432g"\

new api includes some methods that work specifically to help get an element and allow the user to decide what to do with it

new api
this is pretty much shouldnt break many scripts sorry if it does
Code:
iWeb_Init()
iWeb_Term()
iWeb_NewIe()
iWeb_Model(h=550,w=900)
iWeb_GetWin(Name="")
iWeb_GetIE(Name="A") ;; an alternate way to get the browser handle
iWeb_GetDocument(title="A") ;; gets the document from the title
iWeb_BRSRfromOBJ(obj) ;; returns a browser object from any element
iWeb_Release(pdsp)
iWeb_Nav(pwb,url)
iWeb_complete(pwb)
iWeb_DomWin(pdsp,frm="")
iWeb_inpt(i)
iWeb_getDomObj(pwb,obj,frm="")
iWeb_setDomObj(pwb,obj,t,frm="")
iWeb_FindbyText(needle,win="A",property="",offset=0,frm="") ;; returns an element pointer for any found text same as ctrl + f but returns the element or an offset
iWeb_Checked(pwb,obj,checked=1,sIndex=0,frm="")
iWeb_SelectOption(pdsp,sName,selected,method="selectedIndex",frm="")
iWeb_TableParse(pdsp,table,row,cell,frm="")
iWeb_GetElementByAll(pdsp,obj,sindex=0,frm="") ;; dont use sIndex with IE 8 or unless you know how
iWeb_GetElementsByTag(pdsp,tag,obj=0,frm="")
iWeb_Offset(pdsp,offset=0)
iWeb_FireEvents(ele)
iWeb_Attributes(element)  ;; pointer to the elements attributes collection
iWeb_TableLength(pdsp,TableRows="",TableRowsCells="",frm="")
iWeb_clickDomObj(pwb,obj,frm="")
iWeb_clickText(pwb,t,frm="")
iWeb_clickHref(pwb,t,frm="")
iWeb_clickValue(pwb,t,frm="")
iWeb_execScript(pwb,js,frm="")
iWeb_getVar(pwb,var,frm="")
iWeb_escape_text(txt)
iWeb_striphtml(HTML)
iWeb_UrlEncode( String )
iWeb_uriDecode(str)
iWeb_Txt2Doc(t)
iWeb_Activate(sTitle)



I am working also on the following items but am out of time today with ID's names and ordinals

mapping all images and allowing a doubleclick to give you a choice of function calls return source or click an element

form map

link map

full element map

i will also be changeing the message box about unbalanced terms and releases to just add them

Sorry i have been neglegent but i am back



form map

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 4:23 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
I'm getting this error consistently when using the click functions:

Code:
Function Name:   "item"
ERROR:   Access is denied.
   (0x80070005)


I also get this error on occassion when using iWeb_clickDomObj, can't seem to find a consistent pattern on when or why though:

Code:
Function Name:   "specified"
ERROR:   Access is denied.
   (0x80070005)


Also, are you still going to implement an optional retrieval method for iWeb_tableParse? I would think something like this would work:

Code:
   iWeb_TableParse(pdsp,table,row,cell,type="innerText",frm="")
   {
   ;~    http://www.w3schools.com/jsref/dom_obj_table.asp
      ErrorLevel:=
      If   ErrorLevel:=!(pWin   :=   iWeb_DomWin(pdsp,frm)) ? "failed to get a window handle" : false
         Return ErrorLevel
;~       COM_Error(0)
      cell:=pWin ? COM_Invoke(pWin,"document.all.tags[table].item[" table "].rows[" row "].cells[" cell "]") : false
;~       COM_Error(1)
      COM_Release(pWin)
      If   !cell
         Return ErrorLevel:="**** failed to get the cell reference ****"
      result:=cell ? COM_Invoke(cell,type)  :
      iWeb_FireEvents(cell)
      COM_Release(cell)
      Return result
   }

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 4:49 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
tank, I had posted this in another thread, not sure if you saw it. I believe the iWeb_Activate() function should be:
Code:
iWeb_Activate(sTitle, HWND)
; rather than
iWeb_Activate(sTitle)

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 4:53 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
jethrow wrote:
tank, I had posted this in another thread, not sure if you saw it. I believe the iWeb_Activate() function should be:
Code:
iWeb_Activate(sTitle, HWND)
; rather than
iWeb_Activate(sTitle)
that would be incorrect. how will you get the windows hwnd? you cant use the title(if the tab is inactive) and the function grabs from non active tabs so there is no need at all to parse the control list first?
Edit:: :P
you are of course talking about this thread

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Last edited by tank on December 21st, 2009, 5:11 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:08 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
See the second page of this thread. I was under the impression sTitle was the title of the Tab.
tank wrote:
how will you get the windows hwnd?
I would use hwnd := COM_Invoke(pwb, "hwnd"). I guess I don't understand the following lines if the function doesn't accept a HWND param:
Code:
WinActivate,% "ahk_id " HWND
WinWaitActive,% "ahk_id " HWND,,5

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on December 21st, 2009, 5:13 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:12 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
rofl well arent i a dodo i looked in my production code seems somehow i deleted this line
Code:
HWND:=COM_Invoke(pwb:=iWeb_getwin(sTitle),"HWND")

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Last edited by tank on December 21st, 2009, 5:16 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:15 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
jethrow wrote:
I guess I don't understand the following lines if the function doesn't accept a HWND


Edit :D
In further thinking on this and on your post if i were going to change it at all it would be to Only accept hwnd

what say you

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 5:21 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
tank wrote:
rofl well arent i a dodo i looked in my production code seems somehow i deleted this line

:lol: - I would say either put the line back in and leave it the way it was, or possibly allow an optional hwnd param, so you can specify the window if more that one IE window has a tab with the same name.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 6:59 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
@sinkfaze please retest now http://www.autohotkey.net/~tank/iWeb.ahk
@jethrow for now ill just add the line back unless there is a demand

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2009, 9:22 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Maybe I just didn't catch it before but if I try to pass text directly through the text parameter of iWeb_setDomObj it outputs the URL encoding for certain characters, which it didn't do before. If I pass the same text through a variable it works fine.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 11:37 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Considering that tables and cells are a somewhat unique entity in a webpage, and there is already iWeb_getDomObj and iWeb_setDomObj, could we also have a similar pairing for table cells? iWeb_getTblObj and iWeb_setTblObj for example?

Code:
iWeb_getTblObj(pdsp,table,row,cell,type="innertext",frm="") { ; same as iWeb_tableParse, type supports innerText, innerHTML and outerHTML

   ErrorLevel:=
   If   ErrorLevel:=!(pWin   :=   iWeb_DomWin(pdsp,frm)) ? "failed to get a window handle" : false
      Return ErrorLevel
   COM_Error(0)
   cell:=pWin ? COM_Invoke(pWin,"document.all.tags[table].item[" table "].rows[" row "].cells[" cell "]") : false
   COM_Error(1)
   COM_Release(pWin)
   If   !cell
      Return ErrorLevel:="**** failed to get the cell reference ****"
   result:=cell ? COM_Invoke(cell,type)  :
   iWeb_FireEvents(cell)
   COM_Release(cell)
   Return result
}


Code:
iWeb_setTblObj(pdsp,table,row,cell,t,frm="") {

   If pWin:=iWeb_DomWin(pdsp,frm) {
      COM_Error(0)
      cell:=pWin ? COM_Invoke(pWin,"document.all.tags[table].item[" table "].rows[" row "].cells[" cell "]") : false
      COM_Release(pWin)
   }
   COM_Invoke_(cell,iWeb_inpt(itm) ? "Value" : "innerHTML", VT_BSTR:=8,t)
   iWeb_FireEvents(cell)
   COM_Error(1)
   COM_Release(cell)
   Return
}


And as opposed to limiting ourselves to iWeb_tableLength, could we add a couple of general functions to retrieve items and the number of items on a page by any HTML tag? Like these, for example:

Code:
iWeb_getTagObj(pdsp,tag,itm,r="-1",c="-1",type="innerText",frm="") {

  If pWin:=iWeb_DomWin(pdsp,frm)
    result:=COM_Invoke(pWin,"document" ((tag="links") ? ".links" : ".all.tags[" tag "]") ".item[" itm "]"
     . ((tag="table" && r>=0) ? ".rows[" r "]" : "") ((tag="table" && c>=0) ? ".cells[" c "]" : "")
     . "." type)
  COM_Release(pWin)
  return result

}


Code:
iWeb_getTagLen(pdsp,tag,t="-1",r="-1",frm="") {

  If pWin:=iWeb_DomWin(pdsp,frm)
    result:=COM_Invoke(pWin,"document" ((tag="links") ? ".links" : ".all.tags[" tag "]")
     . ((tag="table" && t>=0) ? ".item[" t "].rows" : "") ((tag="table" && r>=0) ? "[" r "].cells" : "")
     . ".length")
  COM_Release(pWin)
  return result

}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2009, 2:11 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Ill address the url encode thing sunday as for your mproposed tag functions there is a problem there is also document.forms
document.frames
document.images ....

no lets leave this level of detail to com_invoke users we cant attempt to solve every likelyhood when that level of detail will be need to just use com_invoke

as to the table issue i plan on adding functions that set or get but accept an element reference because there are many other scenerios where its necesary to get a reference other than via the iweb functions. We really cant hope to make an oll inclusive function list with iweb we would end up with a function list and property list as large as that in the msdn :twisted:


instead we target the simple types of scenerios and like the other script writers leave the more complex stuff to the none novice :wink:

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2009, 3:55 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
tank wrote:
...as for your mproposed tag functions there is a problem there is also document.forms
document.frames
document.images....


Really that's not much of a problem beyond my chosen naming convention for "links", is it? You can access everything in this format, no?

Code:
COM_Invoke(pwb,"document.all.tags[A].length") ; in lieu of document.links.length
COM_Invoke(pwb,"document.all.tags[form].length")
COM_Invoke(pwb,"document.all.tags[img].length")
COM_Invoke(pwb,"document.all.tags[frame].length")


Code:
iWeb_getTagLen(pdsp,tag,t="-1",r="-1",frm="") {

  If pWin:=iWeb_DomWin(pdsp,frm) ; doesn't this cover the frames already?
    result:=COM_Invoke(pWin,"document.all.tags[" tag "]"
     . ((tag="table" && t>=0) ? ".item[" t "].rows" : "") ((tag="table" && r>=0) ? "[" r "].cells" : "")
     . ".length")
  COM_Release(pWin)
  return result

}


tank wrote:
no lets leave this level of detail to com_invoke users we cant attempt to solve every likelyhood when that level of detail will be need to just use com_invoke


My counter to that would be that we've had many cases in Ask for Help where looping through elements of a particular tag type (that isn't a table) was what someone needed to do to solve a problem (click on an input button with no name/id/value, click on text based on its relative position to text in a span tag, etc.). The functions would not only make it easier for the new user (and save us the trouble of trying to explain too much), it would also make it easier for the more experienced user.

Here are two examples using COM_Invoke and the proposed functions to grab the link text for every topic that has a poll in the Wish List forum:

Code:
; using COM_Invoke
Loop % COM_Invoke(pwb,"document.all.tags[table].item[4].rows.length") {
  current:=COM_Invoke(pwb,"document.all.tags[table].item[4].rows[" A_Index-1 "].cells[1].innertext")
  if InStr(current,"[ Poll ]")
    res.=RegExReplace(current,"^\[ Poll \] ") "`n"
}

; using proposed functions
Loop % iWeb_getTagLen(pwb,"table",4) {
  current:=iWeb_getTagObj(pwb,"table",4,A_Index-1,1)
  if InStr(current,"[ Poll ]")
    res.=RegExReplace(current,"^\[ Poll \] ") "`n"
}


More simple and more clean, just what iWeb is for, no? :)

tank wrote:
We really cant hope to make an all inclusive function list with iweb we would end up with a function list and property list as large as that in the msdn :twisted:

instead we target the simple types of scenerios and like the other script writers leave the more complex stuff to the none novice :wink:


I think these functions fall under the simple types of scenarios (with a lengthy solution) that iWeb can help with. If we can simplify this in iWeb it makes it less difficult for the new user to grasp and easier for the experienced user to use. But it's your show boss, you be the judge. :wink:

FYI - I was using iWeb stuffs to determine the post distribution for the main contributors on this project, not bad at all really:

Post Count wrote:
tank: 57
sinkfaze: 49
jethrow: 30


P.S.S. - Linking to a bug report with the ahk web recorder.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 4th, 2010, 8:44 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
Hi,

Sorry for the lateness in the post I've been away the last two weeks on xmas vacation...

I noticed in an earlier post that code has been updated. I have a script which setDomObj inserts a telephone number however instead of 123-456-1234 its 123%20d456%20d1234

Did I not read something or miss something in earlier postings about some of these changes?

Code:
   iWeb_setDomObj(pwb,obj,t,frm="")
   {
   /*********************************************************************
   pwb   -   browser object
   obj   -   object reference; optionally
   t   -   text to place in object;
   frm -   frame reference; optionally,
   Example Usage
   The below will take a browser object, try to get an object called 'username' and set its value/innerHTML to 'john'
   iWeb_setDomObj(pwb,"username","john")
   */
         If   itm      :=   iWeb_GetElementByAll(pwb,obj,0,frm)   ;if this fails there really isnt any need to do below
         {
            ;~    making invoke take integers as Strings  ",   VT_BSTR:=8"
            ;~    http://www.autohotkey.com/forum/viewtopic.php?p=221631#221631 iWeb_uriDecode(str)
            COM_Invoke_(itm,v:=iWeb_inpt(itm) ? "Value=" : "innerHTML=",8,iWeb_UrlEncode(t))
            iWeb_FireEvents(itm)
            COM_Release(itm)
            d=1
         }
      Return d
   }


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 226 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11, 12, 13 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Cristi®, Google Feedfetcher, Stigg and 27 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