Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetHtmlElements: 2 pop-ups appearing, taking focus away from firefox
I fetch HTML using

Macro Macro100
Copy      Help
str html_string
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
Acc a.Find(w "DOCUMENT" "" "" 0x3010 3)
a.WebPageProp(0 0 html_string)

HtmlDoc d.InitFromText(html_string)
ARRAY(MSHTML.IHTMLElement) divblock
d.GetHtmlElements(divblock "div") ;; <===== SOME CODE/CLASS/FUNCTION WITHIN "GetHtmlElements" TRIGGERS POP-UP (SEE BELOW FOR POP UP)

Something within ".GetHtmlElements"  causes 2 popups to appear which causes focus being taken away from firefox.
I can get the window information from the small "Windows Security Warning" pop-up so I can use it in 'win' command.
But I can not fetch info from the other popup "You'll need a new app..." as soon as you press a key it dissapears.

I have used the following command to get all window class/name/id but still couldn't fetch the info of the "You'll need a new app..." popup:
command used: win("" "" "" 0 0 0 a) then attempted to move mouse to the each of the windows stored in "a", but the mouse did not move to the "You'll need a new app..." popup, but other windows strored in "a" did work.

QUESTION: Is there something I could do to avoid the 2 pop-ups from showing up?

I can [ESC] both windows (no need to place cookie) and my code still works.
It's just very annoying that those 2 pop-ups appear, sometimes (in the past) only the small "Windows Security Warning" only appeared.

Even if I had a way to target the "You'll need a new app..." popup it is still all happening within  "GetHtmlElements" so I need to wait until "GetHtmlElements" is finished and then after that do an if "w" exists ("w" beeing the "You'll need a new app..." popup) but this is not possible because
something within "GetHtmlElements" is keeping from completing it's process. I think I need to launch a seperate process before "GetHtmlElements"  which checks for the existance of the popups and then closes them. But I was hoping for another more effective solution. (if possible).

The 2 pop-ups:

The first one, appears last = becomes active window (top of stack)

This one appears directly below the above one
To close the popup use other thread. Start it with mac, like mac "sub.MySubfunction", before the code line that triggers the popup.


Or use FFNode instead of IHTMLElement.

Macro Macro533
Copy      Help
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
FFNode doc.FromDoc(w)
doc.FindFF(doc "div" "" "" 0 0 0 &sub.Callback_FindFF)

#sub Callback_FindFF
function# FFNode&x level cbParam FFNODEINFO&ni

;Template Callback_Acc_Find contains more info about this callback function.

;From x you can get html element tag, HTML, text, attributes, siblings/children/parent, some other info. Also to convert to Acc if possible.

out "-----"

out x.HTML

;ARRAY(str) a
;x.AttributesAll(a 1)
;out a

;Acc k.FromFFNode(x 1)
;k.Role(_s); out _s

ret 1

Thank you!!!
Sorry one more question.

Using your example I was able to extract all divs which have a classname that begins with "row\s" (regx, 'row' followed by a space).

Macro Macro101
Copy      Help
int w=wait(3 WV win("Mozilla Firefox" "MozillaWindowClass"))
FFNode doc.FromDoc(w)
doc.FindFF(doc "div" "" "class=^row\s" 8 0 0 &sub.Callback_FindFF)

Then in the subfunction I used

Macro Macro101
Copy      Help
Acc k.FromFFNode(x 1)
str tag innerHTML outerHTML
k.WebProp(tag innerHTML outerHTML)

It results in multiple HTML blocks beeing extracted:

Copy      Help
<DIV class=icn>
    <A class=fulllink href="" target=_blank>
    <IMG src="https://thumb.png"> <================================================= get  'https://thumb.png'
<DIV class=gameinfo>
    <DIV class=title>
        <A href="" target=_blank>some title</A> <================================================= get   'some title'  (inner text)
        <DIV class=js-subproduct-admin-edit data-machine-name="qm_studio" data-entity-kind="subproduct"></DIV>
    <DIV class=subtitle>
        <A href="" target=_blank>QM Studios</A>


What is the best method to extract:
FROM:  div class = "icn"
(I marked it above in the code with arrow:   <==============   )

What is the best method to extract:
some title
FROM:  div class = "title" ,
EXTRACT: the innertext from the   <A href'   which is  within   div class = "title"
(I marked it above in the code with arrow:   <==============   )

What I would attempt to use is

Macro Macro101
Copy      Help
int i
HtmlDoc d.InitFromText(outerHTML)
ARRAY(MSHTML.IHTMLElement) extract_el_arr
d.GetHtmlElements(extract_el_arr "A" "")
for i 0 extract_el_arr.len

But I do not know what best approach / proper approach is.
Maybe I am using incorrect / cpu resource waisting method (?)

Forum Jump:

Users browsing this thread: 1 Guest(s)