Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting info from hidden browser window
#1
Hi Gintaras,
I sometimes need to scrape text from a browser window. GetInt doesn't work so I use the http or acc functions. However, sometimes it needs to be hidden as the scrape is more of a background information capture. However if the web browser control is hidden or covered up, the scrape doesn't work. Also can't direct it to the right object. Any thoughts from the example below. Also how do you control z-order within a dialog after it is created other than using hid/hid- ... sort of like setting the order in the dialog definition.

Thanks, S

Function MultiPageTest22
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;Example of multipage dialog calling code:
;str controls = "3"
;str lb3

;if(!ShowDialog("ThisFunction" &ThisFunction &controls)) ret
;;...
;int w=wait(3 WV win("Dialog" "#32770"))
;Htm e=htm("DIV" "[] " "" w "0" 33 0x21 3)
;str text=e.Text

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 609 506 "Dialog"
;3 ListBox 0x54230101 0x204 2 14 124 88 ""
;1001 Static 0x54020000 0x4 44 112 48 13 "Page0"
;1002 ActiveX 0x54030000 0x0 138 8 464 458 "SHDocVw.WebBrowser"
;1201 Static 0x54020000 0x4 106 4 48 13 "Page2"
;1 Button 0x54030001 0x4 142 484 48 14 "OK"
;2 Button 0x54030000 0x4 192 484 48 14 "Cancel"
;4 Button 0x54032000 0x4 244 484 18 14 "?"
;5 Static 0x54000010 0x20004 8 472 800 1 ""
;1003 ActiveX 0x54030000 0x0 138 6 464 460 "SHDocVw.WebBrowser"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "0" "" ""


str controls = "3 1002 1003"
str lb3 ax1002SHD ax1003SHD
lb3="&Page0[]Page1[]Page2"
if(!ShowDialog("MultiPageTest22" &MultiPageTest22 &controls)) ret


ret
;messages
sel message
,case WM_INITDIALOG
,,SHDocVw.WebBrowser we0._getcontrol(id(1002 hDlg))    
,,;we0._setevents("we3_DWebBrowserEvents2")
,,we0.Silent=TRUE ;;prevent script error messages
,,we0.Navigate("http://www.google.com")
,,
,,SHDocVw.WebBrowser we1._getcontrol(id(1003 hDlg));;Careteam    
,,;we0._setevents("we3_DWebBrowserEvents2")
,,we1.Silent=TRUE ;;prevent script error messages
,,we1.Navigate("http://www.quickmacros.com")
,;goto selectpage
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,;sel _i
,,;case 0            
,,,;hid id(1003 hDlg)
,,,;hid- id(1002 hDlg)
,,;case 1
,,,;hid id(1002 hDlg)
,,,;hid- id(1003 hDlg)
,;DT_Page hDlg _i
ret 1

Macro attempt to scrape from hidden wbrowser object
Code:
Copy      Help
int w=wait(3 WV win("Dialog" "#32770"))
Htm e=htm("P" "" "" w "0" 5 0x20 3)
str VersionInfo=e.Text
out "VersionInfo = %s" VersionInfo
#2
htm works but searches in the visible control if you don't specify the hidden control.

Function MultiPageTest22
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 1001 1101"
str lb3 ax1001SHD ax1101SHD
lb3="&Page0[]Page1"
ax1001SHD="http://www.google.com"
ax1101SHD="http://www.quickmacros.com"
if(!ShowDialog("" &MultiPageTest22 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 4 4 96 80 ""
;1001 ActiveX 0x54030000 0x0 108 4 154 128 "SHDocVw.WebBrowser"
;1101 ActiveX 0x54030000 0x0 108 4 154 128 "SHDocVw.WebBrowser"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;6 Button 0x54032000 0x0 4 90 96 26 "Get info from hidden browser control"
;5 Static 0x54000010 0x20004 0 138 800 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030502 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,goto selectpage
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
,
,case 6
,int w=hDlg ;;int w=wait(3 WV win("Dialog" "#32770"))
,w=id(1101 w) ;;get control that is parent of the hidden web browser control. Without this, htm would search in the visible.
,Htm e=htm("P" "" "" w "0" 5 0x20 3)
,str VersionInfo=e.Text
,out "VersionInfo = %s" VersionInfo
ret 1

Functions to change Z-order of controls:
BringWindowToTop (easiest)
SetWindowPos
Zorder (uses SetWindowPos)


Forum Jump:


Users browsing this thread: 1 Guest(s)