 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Nov 24, 2009 9:32 pm Post subject: |
|
|
Since the gears are already in place with iWeb_TableParse and iWeb_TableLength here's a conceptual framework to set in motion retrieving the table/row/cell reference for a text element:
| Code: | COM_CoInitialize()
pwb:=iWeb_getWin("AutoHotkey Community - Mouse and Keyboard Macros and Hotkeys")
MsgBox % iWeb_getTableRef(pwb,"Ask for Help")
; returns iWeb_TableParse call to retrieve 'Ask for Help' forum cell
;MsgBox % iWeb_getTableRef(pwb,"Ask for Help",1)
; returns iWeb_TableParse call to retrieve 'no. of topics' cell next to 'Ask for Help' forum cell
return
iWeb_getTableRef(pwb,txt,offset="") {
/*
txt - the text of the element to retrieve (or the text of an offset element to retrieve)
offset - a number to be added to the cell number of the retrieved element
*/
tCount:=found:=""
t=0
Loop {
if !COM_Invoke(pWin,"document.all.tags[table].item[" A_Index "].innerText")
&& !COM_Invoke(pWin,"document.all.tags[table].item[" A_Index-1 "].innerText") { ; checks for the first two consecutive empty tables
l:=A_Index-2
break
}
}
Loop % l {
pWin:=iWeb_DomWin(pwb)
COM_Error(0)
tData:=COM_Invoke(pWin,"document.all.tags[table].item[" t "].innertext")
if RegExMatch(tData,txt) {
found+=1
tCount.=((found=1) ? "" : ",") . t
tbl%found%:=tData
}
COM_Release(pWin), t++
}
MsgBox, 36, iWeb_getTableRef
, % "Search has found " found " tables that contain your search text.`n"
. "Would you like to select a table to use?"
IfMsgBox No
return
Loop, Parse, tCount, `,
{
MsgBox, 36, iWeb_getTableRef
, % "Table " A_LoopField "`n`n"
. "Press 'Y' if this is the table you would like to use or 'N' to continue looking`n"
. "(typically the last table is the correct one to select):`n`n"
. tbl%A_Index%
IfMsgBox Yes
{
t:=A_LoopField
errLvl:=1
break
}
}
if !errLvl
return 0
errLvl:=r:=0
Loop % iWeb_TableLength(pwb,t) {
c=0
Loop % iWeb_TableLength(pwb,t,r) {
current:=iWeb_tableParse(pwb,t,r,c)
if RegExMatch(current,txt) {
errLvl=1
break
}
c++
}
if errLvl
break
r++
}
COM_Release(pWin), COM_Release(pwb)
COM_CoUninitialize()
return "iWeb_TableParse(pwb," t "," r "," (offset ? c+offset : c) ")"
} |
Recommendations on how to optimize code (or write an entirely better function) are not only welcome but probably desperately needed.
11252009:- Altered the table data loop to utilize a dynamic number rather than a determinate 50 iterations. Created an external loop to count the number of existing tables (measured by when the first two empty table results are encountered) which is pushed to the table data loop.
- Changed the search method from InStr() to RegExMatch() which may narrow matching tables in some instances.
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies.
Last edited by sinkfaze on Wed Nov 25, 2009 5:25 pm; edited 1 time in total |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Nov 25, 2009 8:14 am Post subject: |
|
|
I did a slight re-write of jethrow's Learner build to mimick the old style for a proof of concept. I have re-added the old iWeb Function section of the script, but instead of a dynamic Edit box it's a static ListBox. When you press Ctrl+e while your mouse is over a page element, the recommended function calls are loaded to the ListBox. When you double click on one of the recommended calls, it is output to the code box in the writer.
I still lean towards an external script writer, but hopefully this will give a glimpse of how to output from the viewer to the writer. _________________ 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: Wed Nov 25, 2009 2:21 pm Post subject: |
|
|
I havent dived into your code yet
something should cause a selected example to copy to the clipboard i think double click ctrl + c i dunno what feels right but something
your choices for example seem intuitive
I definately think im going to keep that bit you did some cleanup on the gui this is good I am still confused why you both think frames needs a multiline. Since there seems to be a concensus on this tho i wont fight it
All informational sections i think should be grayed out (ReadOnly) i think it makes it clearer.
If jethrow voices no concerns on the new GUI layout i think ill change it as you presented it but set the other informational feilds to ReadOnly _________________
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: Wed Nov 25, 2009 2:41 pm Post subject: |
|
|
| tank wrote: | | ... I am still confused why you both think frames needs a multiline. |
IMO, it makes it much simpler to read if the element is multiple frames deep. Just a thought, but how about if it was one line - but scrollable - & the header stated how many frames were listed?
| tank wrote: | If jethrow voices no concerns on the new GUI layout i think ill change it as you presented it but set the other informational feilds to ReadOnly |
I agree with the ReadOnly (would grayed out be too dark though?). I like the sinkfaze's layout, but I still think it should be more compact. Or possibly have a simple & advanced mode (like AHK Window Info 1.7). Or maybe be resizable to show all the innerText. (I realize I'm just throwing around ideas, and haven't submited a gui example suggestion*) Also, I thought of having one tab contain general webpage info, whereas another tab could contain iWeb (or AHK specific) information & function examples.
Also, I peronally like the layout of IE HTML Element Spy. I don't know what other people's thougths are, but here is an AHK version of it - thought the GUI Stealer functionallity of SmartGUI Creator didn't create the tabs: | Code: | Gui, Add, Text, x0 y99 w546 h275 ,
Gui, Add, Edit, x52 y152 w482 h49 ,
Gui, Add, Edit, x52 y206 w482 h49 ,
Gui, Add, Edit, x52 y260 w482 h49 ,
Gui, Add, Edit, x52 y313 w482 h49 ,
Gui, Add, Text, x52 y130 w482 h13 ,
Gui, Add, Text, x11 y154 w30 h13 , Text:
Gui, Add, Text, x11 y261 w27 h13 , DOC:
Gui, Add, Text, x11 y315 w30 h13 , Code:
Gui, Add, Text, x11 y208 w33 h13 , Frame:
Gui, Add, Text, x11 y130 w30 h13 , Type:
Gui, Add, Edit, x63 y49 w498 h20 ,
Gui, Add, Edit, x63 y73 w498 h20 ,
Gui, Add, Text, x3 y8 w32 h32 ,
Gui, Add, Text, x3 y52 w56 h13 , Page URL:
Gui, Add, Text, x3 y78 w56 h13 , Page Title:
Gui, Add, GroupBox, x0 y0 w561 h44 ,
Gui, Add, Text, x219 y13 w183 h24 , iWebBrowser2 Learner
Gui, Add, Button, x530 y10 w26 h18 , ?
Gui, Add, Button, x503 y10 w26 h18 ,
; Generated using SmartGUI Creator 4.0
Gui, Show, x109 y460 h372 w568, New GUI Window
Return
GuiClose:
ExitApp |
*I'll try to come up with a skeleton GUI & see what you guys think. All-in-all though, I like sinkfaze's GUI. _________________
- 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: Wed Nov 25, 2009 5:07 pm Post subject: |
|
|
| jethrow wrote: |
*I'll try to come up with a skeleton GUI & see what you guys think. All-in-all though, I like sinkfaze's GUI. | I will then implement his changes for the time being untill something better is fleshed out if ever _________________
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: Fri Nov 27, 2009 6:07 am Post subject: |
|
|
| tank wrote: | | I will then implement his changes for the time being untill something better is fleshed out if ever | Well, I don't plan on coming up with an overall better GUI setup, but perhaps a simple/compact view. Here's what I came up with. I would still like it narrower, but I found this challenging to do with the frame info. Also, I'm not sure if the text/html is necessary either (could take these out & make the frame box bigger).
I'm not sure whether something like this fits in with you're vision for the project or not - just a suggestion . _________________
- 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: Fri Nov 27, 2009 8:16 am Post subject: |
|
|
I was annoyed with how I put together the last GUI so I re-wrote it so altering parts (if necessary) is much easier.
In accordance with jethrow's wishes, I also trimmed the width of the GUI and (in the interests of saving space) removed the width/height fields from the Viewer tab. I'm also testing a "rolled up" window feature I'd like you guys to check out. If you're on the Viewer tab, F1 will toggle the "rolled up" window state, but if you press Ctrl+e the window will automatically "roll down". The Script Writer and About tabs both default to the "rolled up" state. In addition, if you press Ctrl+e while the GUI is on any other tab, it should automatically activate and "roll down" the Viewer tab.
I've also modified how pause works in the GUI since there were previous instructions to pause the GUI before working in the Script Writer tab. The GUI should be toggled to paused automatically when in any tab other than the Viewer tab. I also created a subroutine that monitors the paused state when the Viewer tab is active, so if you navigate to another tab and go back to the Viewer tab, it should restore the Viewer tab's previous paused state.
Here's the link to check it out. Let me know what you think.
EDIT: I almost forgot, I also added additional identification techniques in the Ctrl+e hotkey to output sample code for iWeb_execScript() and iWeb_SelectOption() to the listbox where appropriate. _________________ 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: Fri Nov 27, 2009 2:16 pm Post subject: |
|
|
| sinkfaze wrote: | | Let me know what you think. | I like it a lot
2 criticizms & 1 opinion:
- the value field isn't actually the value (property) of the element
- the InnerText field looks like the HTML
- IMO, the mouse coordinates are unnecessary
| sinkfaze wrote: | | If you're on the Viewer tab, F1 will toggle the "rolled up" window state, but if you press Ctrl+e the window will automatically "roll down". | Very Nice . I had wanted to do this, but your implementation is much better than anything I could come up with. _________________
- 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: Fri Nov 27, 2009 5:09 pm Post subject: |
|
|
| jethrow wrote: | - the value field isn't actually the value (property) of the element
- the InnerText field looks like the HTML |
Oops, forgot to mention that change. And you're right, I meant to name the top box Value/InnerText and the bottom one OuterHTML. I've corrected this.
Basically the old method lumped both of those fields into one box:
| Code: | GuiControl,Text,html_text
,% (textOfObj:=inpt(pelt)) " `n" COM_Invoke(pelt, "outerhtml") |
I figured the two pieces of data were different enough that they should be displayed separately so I split them up.
| jethrow wrote: | | - IMO, the mouse coordinates are unnecessary |
In one revision I actually removed them but when I began to implement the "roll up" feature it was rolling up the window just a little too much for my tastes so I put them back in (also because I was too lazy to implement a custom "rolled up" height for the Script Writer tab right then ).
Thanks, since you guys have the inner workings covered I had to find some way to make myself useful. BTW, I cut out your JavaScript test portion because I wasn't sure where I wanted to go with the Script Writer tab, but I like the idea since we can potentially output code that will be beneficial to Firefox/Opera users (even though they're not our focus). Here's a thought though: do you think you could write a translator box? Say someone wants to log in to a website in Firefox and they've created iWeb code using the Script Writer to do it. The translator box would convert this:
| Code: | iWeb_setDomObj(pwb,"txtUser","USERNAME")
iWeb_setDomObj(pwb,"txtPass","PASSWORD")
iWeb_clickDomObj(pwb,"btnAction") |
Into this:
| Code: | javascript:void(document.getElementsByName('txtUser')[0].value='USERNAME');
javascript:void(document.getElementsByName('txtPass')[0].value='PASSWORD');
javascript:document.getElementsByName('btnAction')[0].click(); |
Possible? _________________ 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: Sat Nov 28, 2009 4:25 pm Post subject: |
|
|
Just another thought tank, how come you haven't wrapped COM_Release(pwb) into an iWeb function? Just occurred to me that one little piece seems odd when writing code through the writer. _________________ 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 Nov 29, 2009 1:11 am Post subject: |
|
|
I have upgraded iWebBrowser2 Learner to build 2.3 for review. The major implementations in this release:
- "To Clipboard" checkboxes have been added to the viewer tab and the Script Writer tab. Checking the box on the Viewer tab will automatically save the selection from the ListBox to the Clipboard; checking the box on the Script Writer tab will automatically save the added selection from the dropdownlist to the Clipboard. Appending the selected item from either page to the bottom of the existing script is now the default.
- Double-clicking to select an item from the ListBox in the Viewer tab will automatically send you to the Script Writer tab.
- The script in the Script Writer must pass through five code filters before it can be executed:
- There must be an equal number of iWeb_Init() and iWeb_Term() statements,
- iWeb_Init() must come before iWeb_Term(),
- There must be an equal number of iWeb_getWin() and COM_Release() statements,
- Each iWeb_getWin() statement must be followed by a COM_Release() statement,
- All iWeb_getWin() and COM_Release() statements must be between an iWeb_Init() and an iWeb_Term() statement
(only one iWeb_Init() and iWeb_Term() per script are currently supported).
- A beta version of individual form retrieval has been implemented for the Forms tab. When the 'Get Forms' button is pressed the source from the Source tab will be parsed, the name/id of each form will be sent to the dropdownlist and its corresponding form will appear in the Edit control when it is selected from the dropdown (the dropdownlist and the code box default to the first form).
_________________ 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: Sun Nov 29, 2009 5:50 am Post subject: |
|
|
I have uploaded the latest merges and have made some other minor changes as well _________________
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: Sun Nov 29, 2009 6:12 am Post subject: |
|
|
| tank wrote: | | ... some other minor changes as well |
Looks good - could you include the updated source code in the zip file as well? _________________
- 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 Nov 29, 2009 9:12 am Post subject: |
|
|
Is it possible 'Always on top' could be an optional mode?
And what is the bigger picture goal behind the message box that generates for each Form on the Forms tab? Is it just to show the "input" elements on the page? I just don't think an end user will be big on the persistence of those message boxes, particularly since the message boxes don't indicate what the significance of the contents are. Perhaps, as an alternative, we can trim down the size of the main Edit control for the code of each form and create another Edit control below it to output that data to?
I ultimately agree with making a lot of those fields read only but at the same time I wouldn't want to make the user feel like the information cannot (or should not) be copied. With that in mind, I added the "Left click/copy to Clipboard" functionality implmented by toralf in AHK Window Info 1.7 to my most current revision of the Learner for review. The same link I provided previously should work to download the revised version. _________________ 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: Sun Nov 29, 2009 2:59 pm Post subject: |
|
|
| sinkfaze wrote: | | Is it possible 'Always on top' could be an optional mode? | Why?.... ok
| sinkfaze wrote: | | what is the bigger picture goal behind the message box that generates for each Form on the Forms tab |
postdata
this is the info that would be used if a form filler would be created
the point is that i wanted you to tell me if the info is usefull at all and if so im going to output it to a text box as a full script using the iweb functions
IMO i want to do something similar with tables but havent come up with a format i like
I was tired last night so i didnt state this.
the many recent changes to iweb functions had quite a few errors. These should all be corrected as well i included a file called examples.ahk wth an example of logging into gmeail and hotmail/msn
| jethrow wrote: | | could you include the updated source code | what you think this is some sort of open source project or something
ok tired stupor and all I have now
Edit
I like the click thingy i added that as well _________________
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
|