 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Sat Mar 20, 2010 8:48 am Post subject: |
|
|
You guys are slacking on the updates to iWebBrowser2 Learner . I implemented a Cross-Hair to outline webpage elements - rather than holding control. I didn't want to redesign the main GUI, so I put it in my compact version for testing. Could you guys try it out & let me know what you think?
>>Download Link<< _________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Sat Mar 20, 2010 4:28 pm Post subject: |
|
|
@jethrow I like it alot
On vacation this week so i will begin work again this week. a couple things i have decided
I am thinking on rewriting this for
making ahk_l com_l.ahk the standard and
or ahkcom which also uses com_l.ahk
from a newb standpoint and expecting folks to go from the msdn it just makes more sense to use the friendlier syntax. this means i do verymuch unless one of you object intend to fully abandon all use of the standard ahk release untill chris sees fit to merge these changes. I just cant justify in my own head supporting more complexity than already exists on this subject.
this will also mean a COMPLETE rewrite of iweb i intend to change the syntax and potentially get rid of a few functions
one example would be
instead of
| Code: | pwb : = iweb_getwin("google")
iweb_setdomobj(pwb,"q","autohotkey") |
to something like this
| Code: | | i:=(pwb:=iweb_getie("google")).document.getelementbyid("q").value := "autohotkey" | I will probably can any functions with a direct DOM method replacement but i havent decided for sure yet _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Sat Mar 20, 2010 6:24 pm Post subject: |
|
|
| tank wrote: | | I am thinking on rewriting this for making ahk_l com_l.ahk the standard |
+1. Just a thought ( as it may not be as Standard AHK User friendly ), but what about creating an iWeb object? Something like: | Code: | web := iWeb()
web["Google"].domobj("q") := "AutoHotkey" |
EDIT - here's an example of what I mean ( though I'm not sure how to get the "__Set" metafunction to work directly on an object - if it can ): | Code: | web := iWeb()
web["Google"].domobj("q").value := "autohotkey"
; -OR-
web["Google"].domobj("q").set("autohotkey")
iWeb() {
Return, object( "base", object( "__Get", "IEGet") )
}
domobj( obj, item, frames="" ) {
element := obj.COMobj.document.all[ item ]
Return, object( "COMobj", element, "base", object( "set", "set", "__Set", "Setter" ) )
}
Set( obj, param ) {
obj.COMobj.value := param
}
Setter( obj, key, value ) {
obj.COMobj[ key ] := value
}
IEGet( obj, name ) {
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := Name="New Tab" ? "about:Tabs":RegExReplace(Name," - (Windows|Microsoft) Internet Explorer")
Windows := COM_CreateObject( "Shell.Application" ).Windows, COM_Error( False )
Loop, % Windows.Count
If ( pwb:=Windows.item[A_Index-1] ).LocationName=Name && InStr( pwb.FullName, "iexplore.exe" ) {
COM_Error( True )
Return, object( "COMobj", pwb, "base", object( "domobj", "domobj" ) )
}
} |
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Sun Mar 21, 2010 6:27 am Post subject: |
|
|
I've already done a re-write of the original iWeb functions (adding a few of my own) for AHK_L if you want a reference point, but I admit jethrow's proposed naming convention is quite tempting.
I'll take a look at what it will take to implement the cross hairs into the main GUI, as I also like that option as opposed to holding down the control button (as that can have unusual consequences). _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Sun Mar 21, 2010 5:48 pm Post subject: |
|
|
Here's one potential problem I'm seeing in your naming convention, jethrow: how do you retain the pointer to operate on multiple items on a page? For example, initiating a page login:
| Code: | web := iWeb()
web["Sign In"].domobj("idDiv_PWD_UsernameExample0Pwd").value := "<< some username >>" ; http://www.hotmail.com
web["Sign In"].domobj("i0118").set("<< some password >>")
web["Sign In"].click("idSIButton9") |
You'd practically have to pass the pointer to a separate object anyway, no? _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Sun Mar 21, 2010 6:48 pm Post subject: |
|
|
| Quote: | | ... how do you retain the pointer to operate on multiple items on a page? | Good question - it illistrates what I meant by: | I wrote: | | ( as it may not be as Standard AHK User friendly ) | You would simply save the object: | Code: | web := iWeb()
page := web["Google"]
page.domobj ... |
Also, my example was only the tip of the iceburg, & is very subject to change. For instance, if we slightly modify the iWeb() function, we could do this: | Code: | web := iWeb( "Google" )
web.domobj ...
iWeb( window="" ) {
win := object( "base", object( "__Get", "IEGet") )
Return, window ? win[ window ] : win
} |
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Mar 22, 2010 4:31 pm Post subject: |
|
|
Here's one thing I'd like to see implemented, optional URL navigation built into iWeb_newIE() and iWeb_Model() (I also wrote a leaner and possibly meaner iWeb_complete() function to go along with it):
| Code: | pwb := newIE("http://www.google.com")
; pwb := model(0,0,"http://www.google.com")
pwb.document.all["q"].value := "hello world!"
pwb := ""
return
newIE(url="") {
navTrustedForActiveX := 0x0400
pweb := (pweb := COM_CreateObject("InternetExplorer.Application") ) ? (pweb,pweb.visible := True) : 0
if url
pweb.navigate[url,navTrustedForActiveX,"_self"]
return pweb
}
model(h=550,w=900,url="") {
navTrustedForActiveX := 0x0400, h := !h ? 550 : h, w := !w ? 900 : w
If !pwb := newIe(url)
return False
pwb.menuBar := 0, pwb.AddressBar := 0, pwb.statusBar := 0, pwb.height := h, pwb.width := w
WinSet,AlwaysOnTop,On,% "ahk_class " pwb.hwnd
Return pwb
}
complete(pwb) {
If !pwb
return False
Loop 100
If (pwb.readyState = 4)
&& (pwb.document.readystate = "complete")
Return True
Else Sleep, 300
Return False
} |
Another thing I'd like to see is a click function with more universal handling so all current possibilities (obj,text,href,value) can be called from one function rather than having four separate functions:
| Code: | pwb := newIE("http://www.google.com")
complete(pwb)
pwb.document.all["q"].value := "hello world!"
; click(pwb,"btnG")
click(pwb,"Google Search","value")
pwb := ""
return
newIE(url="") {
navTrustedForActiveX := 0x0400
pweb := (pweb := COM_CreateObject("InternetExplorer.Application") ) ? (pweb,pweb.visible := True) : 0
if url
pweb.navigate[url,navTrustedForActiveX,"_self"]
return pweb
}
complete(pwb) {
If !pwb
return False
Loop 100
If (pwb.readyState = 4)
&& (pwb.document.readystate = "complete")
Return True
Else Sleep, 300
Return False
}
click(pwb,obj,type="",frm="") { ; 'type' supports "innerText", "href" and "value"
if !pWin := domWin(pwb,frm)
return False
if !type
return pWin.document.all[obj].click
Loop % (type="value") ? pWin.document.all.length
: pWin.document.links.length {
COM_Error(0)
itm := (type="value") ? pWin.document.all.item[A_Index-1]
: pWin.document.links.item[A_Index-1]
if (type = "value") {
if (inpt(itm) ? InStr(itm.value,obj) : 0) {
itm.click(), COM_Error(1)
return True
}
}
else if InStr(itm[type],obj) {
itm.click(), COM_Error(1)
return True
}
}
COM_Error(1)
return False
}
domWin(pdsp,frm="") {
qsid := "{332C4427-26CB-11D0-B483-00C04FD90119}"
If !pWin := COM_QueryService(pdsp, qsid, qsid)
return False
If frm {
Loop, Parse, frm, `,
{
frame:=pWin.document.all.item[A_LoopField].contentwindow
pWin:=COM_QueryService(frame, qsid, qsid)
If !pWin
Return False
}
}
Return COM_Enwrap(pWin)
}
inpt(i) {
return InStr("BUTTON,INPUT,OPTION,SELECT,TEXTAREA",i.tagName) ? True : False
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Mar 22, 2010 10:16 pm Post subject: |
|
|
I also think AHK_L will give us an easier way to solve the problem with firing JS events from a page element. AHK_L seems to allow passing the proper object to the function in a way the vanilla does not (or at least not well), and since there are too many JS events to keep track of we can just parse them from the outerHTML of the element so we only fire what's there:
| Code: | fireEvent(ele) {
Pos := 1, h := "\bon\w+\b(?==)"
While Pos := RegExMatch(ele.outerHTML,h,m,Pos+StrLen(m))
ele.fireEvent[m]
return
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Mon Mar 22, 2010 11:40 pm Post subject: |
|
|
| sinkfaze wrote: | | I also think AHK_L will give us an easier way to solve the problem with firing JS events from a page element. | this is not true both allow the passage of a element pointer and i have never had issue with explicitly doing so in the past tho the current library has a flaw in it _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Tue Mar 23, 2010 12:24 am Post subject: |
|
|
| sinkfaze wrote: | I've already done a re-write of the original iWeb functions (adding a few of my own) for AHK_L if you want a reference point, but I admit jethrow's proposed naming convention is quite tempting.
I'll take a look at what it will take to implement the cross hairs into the main GUI, as I also like that option as opposed to holding down the control button (as that can have unusual consequences). | Nice head start in the end i think i'll stick this format out a bit but am finding many edits to makeI will be doing quite alot of testing with it this week before reposting it _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Mon Jun 07, 2010 5:49 pm Post subject: |
|
|
I rewrote my Compact iWebBrowser2 Learner script for AHKL. Here's the link if you want to check it out. The primary changes:- Removed ~LButton Hotkey. Now tests if the A_GuiEvent = "Normal"
- Grouped similar variables into an arrays
- Made the Outline an object
- Used FileInstall to embed Cross-Hair images in .exe
- Clicking a frame.# item in the ListView will copy the Frame URL
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference
Last edited by jethrow on Fri Jun 11, 2010 3:57 am; edited 1 time in total |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Mon Jun 07, 2010 6:47 pm Post subject: |
|
|
| jethrow wrote: | | I rewrote my Compact iWebBrowser2 Learner script | posted on the first page now god i cant wait to get time to jump back into this i have so many ideas _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 63
|
Posted: Wed Jun 16, 2010 5:00 pm Post subject: |
|
|
Im hoping someone can help me, Im trying to use this to login to a webpage but the page doesnt think Ive typed anyting into the username and password fields. If you look at the url after the login button is pressed indicates that the username was null ...
| Code: | #Include iWeb.ahk
#Include COM.ahk
username = strictlyfocused
pass = strictlyfocused ;not my real un and pw ;)
iWeb_Init()
MyKeynote:=iWeb_Model()
iWeb_nav(MyKeynote,"http://my.keynote.com/newmykeynote/logon.aspx")
iWeb_setDomObj(MyKeynote,"un,pw",username "," pass)
iWeb_clickValue(MyKeynote,"Log In")
iWeb_Release(MyKeynote)
iWeb_Term()
|
Last edited by strictlyfocused02 on Wed Jun 16, 2010 5:07 pm; edited 1 time in total |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Sun Jun 20, 2010 9:45 pm Post subject: |
|
|
OMG where have you been all my life!
@tank, took a year but finally I find the goldmine .
TnxU and jethrow + any other contributors for this! _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Sun Jun 20, 2010 10:12 pm Post subject: |
|
|
wow thanks goes to sean
jethrow and sinkfaze have done different but i think very equal shares of this in truth I am just the brain child and did what is now only a small portion of it _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| 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
|