Jump to content

AutoIt Windows Screenshooter v1.84 Build 2019-08-18


UEZ
 Share

Recommended Posts

@taietel and JohnOne: thanks for your feedback!

I tested also on Vista x64 (vm) and it is working properly, also when started directly from SciTE.

I assume it is a problem with my profile.

THANKS!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Added option to save image as PDF (thanks to taietel), rotate image 90° to left/right and take screenshot of controls.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks UEZ. I'm thinking of a way of capturing IE's visible window :mellow:.

Regarding the pdf, I've modified the UDF (again) to add interpolation to the image that is inserted in the pdf. Here is the modified _LoadResImage function:

Func _LoadResImage($sImgAlias, $sImage, $bInterpolate=True)
    Local $iW, $iH, $ImgBuf, $hImage, $hImageExt, $newImg, $hClone, $hGraphics, $iObj
    If $sImgAlias = "" Then __Error("You don't have an alias for the image", @ScriptLineNumber)
    If $sImage = ""  Then
        __Error("You don't have any images to insert or the path is invalid",@ScriptLineNumber)
    Else
        $hImageExt = StringUpper(StringRight($sImage, 3))
        $newImg = _TempFile(@ScriptDir, "~", ".jpg")
        Switch $hImageExt
            Case "BMP", "GIF", "TIF", "TIFF", "PNG", "JPG", "JPEG", "ICO"
                _GDIPlus_Startup()
                $hImage = _GDIPlus_ImageLoadFromFile($sImage)
                $iW = _GDIPlus_ImageGetWidth($hImage)
                $iH = _GDIPlus_ImageGetHeight($hImage)
                $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iW, $iH, $GDIP_PXF24RGB)
                $hGraphics = _GDIPlus_ImageGetGraphicsContext($hClone)
                _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
                _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
                _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)
                _GDIPlus_ImageSaveToFile($hClone, $newImg)
                $ImgBuf = __ToBinary($newImg)
                $_iImageW = $iW
                $_iImageH = $iH
                $iObj = __InitObj()
                __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & _
                " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8 [b]/Interpolate " & StringLower($bInterpolate) & "[/b] /Length " & $iObj + 1 & " 0 R" & ">>")
                __ToBuffer("stream" & @CRLF & $ImgBuf & @CRLF & "endstream")
                __EndObj()
                $_Image &= "/" & $sImgAlias & " " & $iObj & " 0 R " & @CRLF
                __InitObj()
                __ToBuffer(StringLen($ImgBuf))
                __EndObj()
                _GDIPlus_ImageDispose($hImage)
                _GDIPlus_GraphicsDispose($hGraphics)
                _GDIPlus_BitmapDispose($hClone)
                _GDIPlus_Shutdown()
                FileDelete($newImg)
            Case Else
                __Error("The image is invalid",@ScriptLineNumber)
                Exit
        EndSwitch
    EndIf
    Return $_Image
EndFunc   ;==>_LoadResImage
Link to comment
Share on other sites

@taietel: thanks for the update! I updated also mem version of this function!

Btw, function has to be

Func _LoadResImage($sImgAlias, $sImage, $bInterpolate="True")

because True=1 and there are illegal characters -> [ b ][ / b ] in your code above.

To capture the IE window you can use Func Capture_Window($hWnd, $w, $h) which you have to modify appropriately to fit your needs.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks for the tip! Initially I was getting a black caret on IE.

The tags were by mistake (tried to put emphasis on the change and were added automatically). The value has to be true or false (case sensitive). I know True=1 but I've left it this way because when I have tested, in the pdf appears /Interpolate true.

Link to comment
Share on other sites

@taietel: your are welcome.

Btw, I found some bugs -> uploaded new version! :mellow:

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Which version of IE you are using? If IE9 than the method I'm using is odd because when height of the web site is larger than 8192 pixels the screen will become completely white. I don't know the reason currently! :mellow:

With IE8 there were no problems of this kind!

This is the code I'm using more or less:

#include <Clipboard.au3>
#include <IE.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
;Coded by UEZ 2011 - beta version

If @OSBuild < 6000 Then Exit MsgBox(16, "Error!", "Script is running only on Vista+ os properly!", 10)

Global Const $hDwmApiDll = DllOpen("dwmapi.dll")
Global $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $aero = DllStructGetData($sChkAero, 1)
DllClose($hDwmApiDll)
If Not $aero Then Exit MsgBox(16, "Error", "Aero must be enabled to grab web sites properly!", 20)
$sChkAero = 0

Global $URL, $btn, $msg, $hWnd, $input, $i
$hWnd = GUICreate("Save Web Page as an image", 320, 120)
$input = GUICtrlCreateInput("http://www.autoit.de", 10, 5, 300, 20)
$btn = GUICtrlCreateButton("Ok", 40, 35, 240, 70)
ControlFocus($hWnd, "", $btn)
GUISetState()

While $msg <> -3
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            Start()
        Case $msg = -3
            GUIDelete($hWnd)
            Exit
    EndSelect
WEnd

Func Start()
    $URL = GUICtrlRead($input)
    SplashTextOn("Screenshooting Web Site", "Please wait while taking screenshot", 300, 40, -1, -1, 1 + 2 + 4 + 32, "")
    AdlibRegister("Wait", 300)
    Web_Screenshot($URL)
    AdlibUnRegister("Wait")
    SplashOff()
    MsgBox(0, "Information", "Web Site Image copied to clipboard!", 10)
EndFunc

Func Web_Screenshot($url, $IEwidth = 1045)
    Local $oIE, $GUIActiveX, $oDocument,  $oBody, $BodyWidth, $BodyHeight, $oHtml
    Local $hGUI_WebGrab, $hWin, $aWin, $aMP
    Local Const $BrowserNavConstant = 2 + 256 + 2048 ;BrowserNavConstant -> http://msdn.microsoft.com/en-us/library/dd565688(v=vs.85).aspx
    $oIE = ObjCreate("Shell.Explorer.2") ;http://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx

    $hWin = WinGetHandle("Program Manager")
    $aWin = WinGetPos($hWin)

    #region render web site to get height
    $hGUI_WebGrab = GUICreate("",  0, 0, $aWin[0] - $BodyWidth + 1, $aWin[1] - $BodyHeight + 1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP),Default, WinGetHandle(AutoItWinGetTitle()))
    $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $IEwidth, 256)
    GUISetState(@SW_MINIMIZE, $hGUI_WebGrab)

    Local $timeout = 30 * 1000
    Local $timer = TimerInit()
    With $oIE
        .Silent = True
        .FullScreen = True
        .Resizable = False
        .Visible = False
        .StatusBar = False
        .AddressBar = False
        .Navigate($URL, $BrowserNavConstant, "_top")
        Do
            If TimerDiff($timer) > $timeout Then ExitLoop
            Sleep(100)
        Until $oIE.ReadyState = 4
        .Stop
        Sleep(2000)
    EndWith

    $oDocument = $oIE.document
    $oBody = $oDocument.body
    $oBody.scroll = "no"
    $oBody.style.borderStyle = "none"
    $BodyWidth = $oBody.scrollWidth
    $BodyHeight = $oBody.scrollHeight
    GUIDelete($hGUI_WebGrab)
    $GUIActiveX = 0
    #endregion

    Local $IE_Ver = RegRead("HKLM\SOFTWARE\Microsoft\Internet Explorer", "Version"), $height
    If $IE_Ver > 8 Then $BodyHeight = Min($BodyHeight, 8192)

;~  ConsoleWrite($oIE.Path & @CRLF)

    $hGUI_WebGrab = GUICreate("",  $BodyWidth,  $BodyHeight, $aWin[0] - $BodyWidth + 1, $aWin[1] - $BodyHeight + 1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP), Default, WinGetHandle(AutoItWinGetTitle()))
;~  $hGUI_WebGrab = GUICreate("",  $BodyWidth,  $BodyHeight, -1, -1, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_POPUP), Default, WinGetHandle(AutoItWinGetTitle()))
    $GUIActiveX = GUICtrlCreateObj ($oIE, 0, 0, $BodyWidth,  $BodyHeight)
;~  GUISetState(@SW_SHOWNA, $hGUI_WebGrab) ;Show GUI for some milli seconds to make a screenshot

    $timer = TimerInit()
    With $oIE
        .Silent = True
        .FullScreen = True
        .Resizable = False
        .Visible = False
        .StatusBar = False
        .AddressBar = False
        .Navigate($URL, $BrowserNavConstant, "_top")
        Do
            If TimerDiff($timer) > $timeout Then ExitLoop
            Sleep(100)
        Until $oIE.ReadyState = 4
        .Stop
        Sleep(1000)
    EndWith

    $oDocument = $oIE.document
    $oBody =$oDocument.body
    $oHtml = $oDocument.documentElement
    $oBody.scroll = "no"
    $oBody.style.borderStyle = "none"
    $oBody.style.border = "0px"
    $oHtml.style.overflow = 'hidden'

    GUISetState(@SW_SHOWNA, $hGUI_WebGrab)      ;Show GUI

    Local $hDC = _WinAPI_GetWindowDC($hGUI_WebGrab)
    Local $hDC_Dummy = _WinAPI_GetWindowDC(0)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Dummy)
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Dummy, $BodyWidth, $BodyHeight)
    _WinAPI_SelectObject($hMemDC, $hBitmap)
    _WinAPI_BitBlt($hMemDC, 0, 0,  $BodyWidth, $BodyHeight, $hDC, 0, 0, $SRCCOPY)

    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_ReleaseDC($hGUI_WebGrab, $hDC)
    _WinAPI_ReleaseDC(0, $hDC_Dummy)
    _WinAPI_ReleaseDC(0, $hDC)

    _ClipBoard_Open(0)
    _ClipBoard_Empty()
    _ClipBoard_SetDataEx($hBitmap, $CF_BITMAP)
    _ClipBoard_Close()
    _WinAPI_DeleteObject ($hBitmap)

    $GUIActiveX = 0
    $oIE = 0
    GUIDelete($hGUI_WebGrab)
    _ReduceMemory()
EndFunc

Func Min($a, $b)
    If $a < $b Then Return $a
    Return $b
EndFunc

Func Wait()
    Switch Mod($i, 4)
        Case 0
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot")
        Case 1
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot .")
        Case 2
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ..")
        Case 3
            ControlSetText("Screenshooting Web Site", "", "Static1", "Please wait while taking screenshot ...")
    EndSwitch
    $i += 1
EndFunc

Func _ReduceMemory($ProcID = 0)
    If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesn't exist - use current process instead.
        Local $ai_GetCurrentProcess = DllCall('kernel32.dll', 'ptr', 'GetCurrentProcess')
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_GetCurrentProcess[0])
        Return $ai_Return[0]
    EndIf
    Local $ai_Handle = DllCall("kernel32.dll", 'ptr', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ProcID)
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'ptr', $ai_Handle[0])
    Return $ai_Return[0]
EndFunc

Unfortunately advertising windows which may appear will not suppressed and it has to be closed manually.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The bugs were not web screenshoot related... :)

Thanks for your feedback! :mellow:

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

You're right: I realized that when I click twice on the listview (not double-click, but single click with some delay between), the picture of IE is kind of refresh itself (black portion becomes as it should be).

Interesting also the zooming part: can I use it (modified) in my box-counting project? Thanks in advance!

Link to comment
Share on other sites

You're right: I realized that when I click twice on the listview (not double-click, but single click with some delay between), the picture of IE is kind of refresh itself (black portion becomes as it should be).

Interesting also the zooming part: can I use it (modified) in my box-counting project? Thanks in advance!

Double click on lmb has no action but on rmb :mellow:

Feel free to use any code you want!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 weeks later...

Updated to v1.31 Build 2011-08-26:

some internal changes and bug fixes, added sound when capturing has finished, program update check, open default mail client to paste image and freehand capturing

Look to post#1 to read how to use freehand capturing.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Memory leak bug fixed when doing freehand capturing!

Are the functions and features intuitive to use?

Br,

UEZ :mellow:

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Another update: GUI changed a little bit, added grab to AVI function (no compression available currently - thanks to monoceres / ProgAndy) and ruler, some bugs fixed.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

why is it that it crashes when I press the exit button from the bar on top ($GUI_EVENT_CLOSE), but not when I press the button on the bottom ($Button_Exit)?

I have windows XP, and this works perfectly for the screenshots that my C++ teacher wants (other than the crashing on exit)

[font=arial, sans-serif]How is education supposed to make me feel smarter? Besides, every time I learn something new, it pushes some old stuff out of my brain. Remember when I took that home winemaking course, and I forgot how to drive?[/font][font=arial, sans-serif]<div>This is how you annoy a web developer.</span>[/font]

Link to comment
Share on other sites

Thanks for your feedback. For the crashing issue please have a look to

Does it crash every time when you press the X?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 3 weeks later...

Added among others compression options when Grab Screen to AVI is used. You can use any installed video codec now.

Some settings can be done when you press the rmb when mouse is hovering the button.

Can somebody test whether it is still crashing when pressing the [X] button?

My assumption is that some functions still run through GUIRegisterMsg() function althought GUI sends a close to end program...

Thanks,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...