Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web2Image
#1
Is possible to capture a screenshot of a Web site like http://www.nirsoft.net/utils/web_site_screenshot.html using QM?
#2
Should be easy to create simplest code. But will need time to add more features, such as auto-size. And to test with many pages... Better use the nirsoft command line program.
#3
can you convert this code: https://www.autoitscript.com/forum/topic...creenshot/ to QM?
#4
or

https://www.codeproject.com/Articles/166...le-Using-G
https://www.experts-exchange.com/questio...A-BUG.html
https://www.developerfusion.com/code/471...-web-page/
http://prog3.com/sbdm/blog/wingeek/artic...ls/6067096
#5
I don't think that any of these codes work reliably, with any page, with scrolling pages. If don't want to spend several days converting these codes and trying to make them work reliably enough, use the commandline program or try to find some good library (COM or .NET), or use some online service.
#6
I just performed a test on the AutoIt code and it works correctly ...
It seems to use IHTMLElementRender to generate an image of an accessible object.
#7
Code for IHTMLElementRender.

Macro Macro151
Code:
Copy      Help
HtmlDoc d.SetOptions(2)
d.InitFromWeb("http://www.quickmacros.com/")

__MemBmp b.Create(1000 1000)

MSHTML.IHTMLElementRender r=+d.d.body
MSHTML._RemotableHandle* workaround=+b.dc ;;DrawToDC is declared incorrectly in the type library
r.DrawToDC(workaround)

str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile

;Don't ask me how to get web page dimensions, how to capture whole scrolling page, etc.
#8
Thanks.
#9
I tried to create the Web2Image function to capture an HTML element without success.
Error (RT) in <open ": 4709: / 840"> Macro53: 0x80004002, Interface not supported.

Can you create the function?

Macro Macro53
Code:
Copy      Help
int w=wait(3 WV win("Nueva pestaña - Internet Explorer" "IEFrame"))
Htm e=htm("DIV" "" "" w "0" 46 0x20 3)

__MemBmp b.Create(1000 1000)


MSHTML.IHTMLElementRender r=+e.el.document
MSHTML._RemotableHandle* workaround=+b.dc ;;DrawToDC is declared incorrectly in the type library
r.DrawToDC(workaround)

str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile
#10
MSHTML.IHTMLDocument2 d=e.el.document
MSHTML.IHTMLElementRender r=+d.body

But does not work too. Works when the web browser control is in the same process, like in the autoit code.
#11
any workaround?
#12
Macro Macro173
Code:
Copy      Help
int w=win("- Internet Explorer" "IEFrame")
int c=child("" "Internet Explorer_Server" w)
Htm e=htm("BODY" "" "" c "0" 0 0x30)

MSHTML.IHTMLElement2 e2=+e.el
int wid(e2.scrollWidth) hei(e2.scrollHeight)
out F"{wid} {hei}"

;if has scrollbar, temporarily resize to show whole page; later restore; not implemented.
;RECT r; GetWindowRect(c &r)
;if wid>r.right-r.left or hei>r.bottom-r.top
,;...

__MemBmp b.Create(wid hei)
PrintWindow(c b.dc PW_CLIENTONLY)

;restore if resized
;...


str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile
#13
Thanks again.
#14
Is there any new progress in webpage screenshots?

I need to save the entire page of a URL as a PNG image. I can only take a small part of it using the code below. I very much hope to continue to enhance and improve it. Thank you very much.
Heart


Macro Macro8
Code:
Copy      Help
;http://www.quickmacros.com/forum/showthread.php?tid=6246&highlight=service
int w=win("- Internet Explorer" "IEFrame")
int c=child("" "Internet Explorer_Server" w)
Htm e=htm("BODY" "" "" c "0" 0 0x30)

MSHTML.IHTMLElement2 e2=+e.el
int wid(e2.scrollWidth) hei(e2.scrollHeight)
out F"{wid} {hei}"

;if has scrollbar, temporarily resize to show whole page; later restore; not implemented.
;RECT r; GetWindowRect(c &r)
;if wid>r.right-r.left or hei>r.bottom-r.top
,;...

__MemBmp b.Create(wid hei)
PrintWindow(c b.dc PW_CLIENTONLY)

;restore if resized
;...


str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile
#15
When the page is loaded, I want to intercept the entire page in the dialog. How do I handle it?



Macro Macro9
Code:
Copy      Help
\Dialog_Editor

str controls = "3"
str ax3SHD
ax3SHD="https://www.msn.com"
if(!ShowDialog("" &sub.DialogProcedure &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 600 280 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 600 282 "SHDocVw.WebBrowser"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

#sub DialogProcedure
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,SHDocVw.WebBrowser we3
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


#sub we3_DocumentComplete
function IDispatch'pDisp `&URL ;;SHDocVw.IWebBrowser2'we3
out "webComplete"


HtmlDoc d.SetOptions(2)
d.InitFromWeb("https://www.msn.com")

__MemBmp b.Create(1000 6000)

MSHTML.IHTMLElementRender r=+d.d.body
MSHTML._RemotableHandle* workaround=+b.dc ;;DrawToDC is declared incorrectly in the type library
r.DrawToDC(workaround)

str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile
#16
Strange, the following code, the link to qm is OK, invalid for other links

Can provide the easiest way to intercept the entire page of a link and save it as a PNG image? 
Smile


Macro Macro16
Code:
Copy      Help
HtmlDoc d.SetOptions(2)
;d.InitFromWeb("http://www.quickmacros.com/") ;; ok
d.InitFromWeb("https://www.msn.cn/zh-cn") ;;not ok

__MemBmp b.Create(1000 1000)

MSHTML.IHTMLElementRender r=+d.d.body
MSHTML._RemotableHandle* workaround=+b.dc ;;DrawToDC is declared incorrectly in the type library
r.DrawToDC(workaround)

str sFile.expandpath("$temp$\1.bmp")
SaveBitmap b.bm sFile

run sFile
#17
I found a good solution, please use QM to execute the following powershell script Smile ​​​​​​​

 
Code:
Copy      Help
 
$ie = New-Object -ComObject InternetExplorer.Application

$ie.Visible = $true;

$Yourwebpage = $ie.navigate('www.msn.com')

while($Yourwebpage.Busy){Start-Sleep -Seconds 5}

#capturing the screenshot

$file = "C:\Users\xyz\Desktop\abc\$(Get-Date -Format dd-MM-yyyy-hhmm).bmp"

Add-Type -AssemblyName System.Windows.Forms

Add-type -AssemblyName System.Drawing

$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen

$width = $Screen.width

$Height = $Screen.Height

$Left = $Screen.Left

$Right = $Screen.Right

$Top = $Screen.Top

$Bottom = $Screen.Bottom

$bitmap = New-Object System.Drawing.Bitmap $width, $Height

$Graphics = [System.Drawing.Graphics]::FromImage($bitmap)

$Graphics.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)

$bitmap.Save($File)

Write-Output "Screenshot saved to:"

Write-Output $File


Forum Jump:


Users browsing this thread: 1 Guest(s)