Herb191 Posted January 23, 2010 Posted January 23, 2010 From searching in the forms it looks like this question has been asked before but I couldn’t find anywhere anyone had found a solution. I am trying to open up a html file in Internet Explorer and save all of its contents (not just what you can see in the window) as a .jpg file. For what I am doing it doesn’t have to be opened in Internet Explorer as long as I can converted the html to a jpg file.
nobbe Posted January 23, 2010 Posted January 23, 2010 i did something like this - close all IE windows before running it or it will get wrong screen results expandcollapse popup; ; do screenshots of websites, save in scriptdir ; ; - please close all "internet explorer" sessions before snapshot ; - after new IE window starts, move IE to position where it is not overlapped by another window ; - press GO button ; author nobbe 2008 ; ; #include <GUIConstants.au3> #include <IE.au3> #include <String.au3> #include <ScreenCapture.au3> ; ------------------------------------------------------------------- Global $oIE ; ------------------------------------------------------------------- $Form1 = GUICreate("screenshot demo", 200, 100, 0, 0) $btn_go = GUICtrlCreateButton("go", 10, 10, 75, 20) GUISetState(@SW_SHOW) ; --------------------------------------------------------------------------------- $oIE = _IECreate("about:blank", 0) ; --------------------------------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg ; start Case $btn_go doit() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; --------------------------------------------------------------------------------- ; ; do some screenshots ; Func doit() do_screen_shot_url("http://www.autoitscript.com") do_screen_shot_url("http://www.google.com") do_screen_shot_url("http://www.cnn.com") ;; or load from setup file etc.. EndFunc ;==>doit ; ; move to url, then take snapshot of IE window ; Func do_screen_shot_url($url) local $Hwnd, $Winlist, $list Local $tmp = StringReplace($url, "http://", ""); Local $outfile = @ScriptDir & "\" & $tmp & "_1.jpg"; _IENavigate($oIE, $url) _IELoadWait($oIE) $Winlist = WinList() For $list = 1 To $Winlist[0][0] $WinTitle = $Winlist[$list][0] If StringInStr($WinTitle, "Internet explorer") > 0 Then $Hwnd = $Winlist[$list][1] EndIf Next _ScreenCapture_CaptureWnd($outfile, $Hwnd) sleep(500) EndFunc ;==>do_screen_shot_url
nobbe Posted January 23, 2010 Posted January 23, 2010 (edited) if you want to have the picture without frames etc (just the html content) you will need to position IE window (maximise), and setup your screen coord to something like this (need some tries here to get the positions right) local $xstart = 190; local $ystart = 170; Opt("PixelCoordMode", 0); Screen coordinates relative to active screen _ScreenCapture_Capture(@ScriptDir & "\ie.jpg", $xstart, $ystart, $xstart+320, $ystart+330, False) Edited January 23, 2010 by nobbe
Herb191 Posted January 23, 2010 Author Posted January 23, 2010 i did something like this - close all IE windows before running it or it will get wrong screen results expandcollapse popup; ; do screenshots of websites, save in scriptdir ; ; - please close all "internet explorer" sessions before snapshot ; - after new IE window starts, move IE to position where it is not overlapped by another window ; - press GO button ; author nobbe 2008 ; ; #include <GUIConstants.au3> #include <IE.au3> #include <String.au3> #include <ScreenCapture.au3> ; ------------------------------------------------------------------- Global $oIE ; ------------------------------------------------------------------- $Form1 = GUICreate("screenshot demo", 200, 100, 0, 0) $btn_go = GUICtrlCreateButton("go", 10, 10, 75, 20) GUISetState(@SW_SHOW) ; --------------------------------------------------------------------------------- $oIE = _IECreate("about:blank", 0) ; --------------------------------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg ; start Case $btn_go doit() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; --------------------------------------------------------------------------------- ; ; do some screenshots ; Func doit() do_screen_shot_url("http://www.autoitscript.com") do_screen_shot_url("http://www.google.com") do_screen_shot_url("http://www.cnn.com") ;; or load from setup file etc.. EndFunc ;==>doit ; ; move to url, then take snapshot of IE window ; Func do_screen_shot_url($url) local $Hwnd, $Winlist, $list Local $tmp = StringReplace($url, "http://", ""); Local $outfile = @ScriptDir & "\" & $tmp & "_1.jpg"; _IENavigate($oIE, $url) _IELoadWait($oIE) $Winlist = WinList() For $list = 1 To $Winlist[0][0] $WinTitle = $Winlist[$list][0] If StringInStr($WinTitle, "Internet explorer") > 0 Then $Hwnd = $Winlist[$list][1] EndIf Next _ScreenCapture_CaptureWnd($outfile, $Hwnd) sleep(500) EndFunc ;==>do_screen_shot_url This captors the window content for me but not all of the page info…
jchd Posted January 23, 2010 Posted January 23, 2010 This captors the window content for me but not all of the page info…I don't know how to do that in AutoIt, but I use FastStone Capture for that and it works like a charm. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Herb191 Posted January 23, 2010 Author Posted January 23, 2010 I don't know how to do that in AutoIt, but I use FastStone Capture for that and it works like a charm.I have actually used FastStone Capture and it does work great but this is part of I larger project and I would like to keep it all in Autoit if i can.
jchd Posted January 23, 2010 Posted January 23, 2010 I have actually used FastStone Capture and it does work great but this is part of I larger project and I would like to keep it all in Autoit if i can.So there begins my incompetence, sorry. Hopefully a smart good sould will guide you in the right direction, possibly using _ie* with pasted screenshots of partial screens, but I'm lost there. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now