 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
Posted: Mon Dec 21, 2009 4:08 am Post subject: |
|
|
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 _________________ Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
 |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 2694 Location: the tunnel(?=light)
|
Posted: Mon Dec 21, 2009 4:23 pm Post subject: |
|
|
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
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 783 Location: Iowa, USA
|
Posted: Mon Dec 21, 2009 4:49 pm Post subject: |
|
|
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) |
_________________ AHKL, COM_L,Webpage Controls,Donate to AHK |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
Posted: Mon Dec 21, 2009 4:53 pm Post subject: |
|
|
| 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::
you are of course talking about this thread _________________ Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow

Last edited by tank on Mon Dec 21, 2009 5:11 pm; edited 1 time in total |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 783 Location: Iowa, USA
|
Posted: Mon Dec 21, 2009 5:08 pm Post subject: |
|
|
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 |
_________________ AHKL, COM_L,Webpage Controls,Donate to AHK
Last edited by jethrow on Mon Dec 21, 2009 5:13 pm; edited 1 time in total |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
Posted: Mon Dec 21, 2009 5:12 pm Post subject: |
|
|
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") |
_________________ Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow

Last edited by tank on Mon Dec 21, 2009 5:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
Posted: Mon Dec 21, 2009 5:15 pm Post subject: |
|
|
| jethrow wrote: | | I guess I don't understand the following lines if the function doesn't accept a HWND |
Edit
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 _________________ Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
 |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 783 Location: Iowa, USA
|
Posted: Mon Dec 21, 2009 5:21 pm Post subject: |
|
|
| tank wrote: | | rofl well arent i a dodo i looked in my production code seems somehow i deleted this line |
- 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. _________________ AHKL, COM_L,Webpage Controls,Donate to AHK |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 2694 Location: the tunnel(?=light)
|
Posted: Mon Dec 21, 2009 9:22 pm Post subject: |
|
|
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. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 2694 Location: the tunnel(?=light)
|
Posted: Wed Dec 23, 2009 11:37 pm Post subject: |
|
|
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
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2408 Location: Louisville KY USA
|
Posted: Thu Dec 24, 2009 2:11 am Post subject: |
|
|
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
instead we target the simple types of scenerios and like the other script writers leave the more complex stuff to the none novice  _________________ Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
 |
|
| Back to top |
|
 |
sinkfaze
Joined: 19 Mar 2008 Posts: 2694 Location: the tunnel(?=light)
|
Posted: Thu Dec 24, 2009 3:55 pm Post subject: |
|
|
| 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
instead we target the simple types of scenerios and like the other script writers leave the more complex stuff to the none novice  |
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.
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. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
frescalus
Joined: 19 Nov 2009 Posts: 49
|
Posted: Mon Jan 04, 2010 8:44 pm Post subject: |
|
|
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
} |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|