hassoun wrote:
does this, InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1]):, have anything to do with it?
not unless you have devised a way to get the html
Code:
COM_CoInitialize()
OnExit,kill
handle:=iWeb_getwin("page title")
F6:
broke=
Loop
{
iWeb_clickText(handle,"some text you want to click")
iWeb_complete(handle)
if broke
break
}
Return
kill:
COM_CoUninitialize()
ExitApp
F7:
broke=1
Return
iWeb_getwin(t)
{
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
LocationName := COM_InvokeDeep(psw,"Item[" A_Index-1 "].LocationName")
IfInString,LocationName,%t%
{
pwb := COM_InvokeDeep(psw,"Item[" A_Index-1 "]")
COM_Release(psw), VarSetCapacity(psw, 0), COM_Release(psh), VarSetCapacity(psh, 0)
Return pwb
}
}
COM_Release(psw), VarSetCapacity(psw, 0), COM_Release(psh), VarSetCapacity(psh, 0)
Return 0
}
iWeb_complete(pwb) ; returns bool for success or failure
{
If not pwb is Integer ; test to see if we have a valid interface pointer
ExitApp ; ExitApp if we dont
loop 80 ; sets limit if itenerations to 40 seconds 80*500=40000=40 secs
{
If (rdy:=COM_Invoke(pwb,"readyState") = 4)
Return 1 ; return success
Sleep,500 ; sleep half second between cycles
}
Return 0 ; lets face it if it got this far it failed
} ; end complete
iWeb_DomWin(pwb)
{
IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
Return COM_QueryService(pwb, IID_IHTMLWindow2, IID_IHTMLWindow2)
}
iWeb_clickText(pwb,t)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an link called username
clickText(pwb,"username")
This will cycle thru objects username pass and 3
clickText(pwb,"username,pass,3")
*/
col := COM_InvokeDeep(pWin := iWeb_DomWin(pwb), "document.links")
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0), COM_Release(pWin), VarSetCapacity(pWin, 0)
Return 0
}
lnklen := COM_Invoke(col, "length")
Loop,% lnklen
{
If itm := COM_Invoke(col,"item", A_Index-1) is integer ;if this fails there really isnt any need to do below
{
rslt := COM_Invoke(itm, "innerHTML")
IfInString,rslt,%t%
{
COM_Invoke(itm, "click")
d=1
COM_Release(itm), VarSetCapacity(itm, 0)
Break
}
;~ release and clear out any objects
}
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0), COM_Release(pWin), VarSetCapacity(pWin, 0)
Return d
}
COM_InvokeDeep(obj, path, arg1="vT_NoNe", arg2="vT_NoNe", arg3="vT_NoNe", arg4="vT_NoNe", arg5="vT_NoNe", arg6="vT_NoNe", arg7="vT_NoNe", arg8="vT_NoNe")
{
res := obj
COM_AddRef(res) ; compensate for loop's Release()
PathCt := 0
Loop, Parse, Path, .
{
PathCt++
}
Loop, Parse, Path, ., ]
{
prop := A_LoopField
value =
StringGetPos, i, A_LoopField, [
IfEqual, ErrorLevel, 0 ; contains index
{
StringLeft, prop, A_LoopField, %i%
StringMid, value, A_LoopField, % i+2
}
If (value != "") ; contains index or parameter passed to a method, enclosed in "[]"
{
If (prop = "item") or (RegExMatch(value, "^[0-9]+$") = false) ; "item" already specified, or method call
{
If (A_Index < PathCt)
propobj := COM_Invoke(res, prop, value)
Else
propobj := COM_Invoke(res, prop, value, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
COM_Release(res), VarSetCapacity(res, 0)
res := propobj
}
Else
{
propobj := COM_Invoke(res, prop)
If (A_Index < PathCt)
itemobj := COM_Invoke(propobj, "Item", value)
Else
itemobj := COM_Invoke(propobj, "Item", value, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
COM_Release(res), VarSetCapacity(res, 0)
COM_Release(propobj), VarSetCapacity(propobj, 0)
res := itemobj
}
}
Else
{
If (A_Index < PathCt)
propobj := COM_Invoke(res, prop)
Else
{
sParams := 12345678
int:=False
Loop, Parse, sParams
If arg%A_LoopField% is Integer
{
int:=true
Break
}
If int
{
Loop, Parse, sParams
{
If (arg%A_LoopField% == "vT_NoNe")
{
arg%A_LoopField% := ""
VT_BSTR%A_LoopField%:=""
}
Else
VT_BSTR%A_LoopField%:=8
}
propobj := COM_Invoke_(res, prop, VT_BSTR1,arg1,VT_BSTR2,arg2, VT_BSTR3,arg3, VT_BSTR4,arg4, VT_BSTR5,arg5, VT_BSTR6,arg6, VT_BSTR7,arg7, VT_BSTR8,arg8)
}
Else
propobj := COM_Invoke(res, prop, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
}
COM_Release(res), VarSetCapacity(res, 0)
res := propobj
}
if !res ; no sense in continuing - object not found (returns 0 or null)
break
}
Return res
}
need the COM library from my SIG (thanks Sean)
