Jump to content

ScreenCapture - tooltip not captured


Recommended Posts

Greetings,

with the below code the Tooltip does not show in the captured image.

Any hints?

Thanks.

#include <ScreenCapture.au3>

ToolTip("BlaBla Tooltip", 500, 300)
Sleep(1000)

_ScreenCapture_Capture(@MyDocumentsDir &"\Image1.jpg", 0, 0, 1600, 1000, True)

MsgBox(0, "TTT", "ScreenCapture done")
ShellExecute(@MyDocumentsDir &"\Image1.jpg")

 

Link to comment
Share on other sites

If it can help, I met an issue with the _ScreenCaptureXXX functions with Windows XP : some windows having the $WS_EX_LAYERED extended style was not not captured at all.

Are you using a XP OS ?

Link to comment
Share on other sites

But you can use a workaround:

#include <Clipboard.au3>
#include <GDIPlus.au3>

ToolTip("BlaBla Tooltip", 500, 300)
Sleep(1000)

_GDIPlus_Startup()
_ScreenCapture_CaptureAlternative(@ScriptDir &"\Image1.jpg", 0, 0, 1600, 1000)

MsgBox(0, "TTT", "ScreenCapture done")
ShellExecute(@ScriptDir &"\Image1.jpg")
_GDIPlus_Shutdown()

Func _ScreenCapture_CaptureAlternative($sFile, $iX, $iY, $iW, $iH, $bCursor = True) ;coded by UEZ 2014
    If Not $giGDIPRef Then Return SetError(1, 0, 0) ;check whether _GDIPlus_Startup() was called
    Send("{PRINTSCREEN}")
    Sleep(100) ;wait some ms otherwise clipboard will fail to open
    If Not _ClipBoard_Open(0) Then Return SetError(2, 0, 0)
    Local $hMemoryBMP = _ClipBoard_GetDataEx($CF_BITMAP) ;get bitmap from clipboard
    If @error Then
        _ClipBoard_Close()
        Return SetError(3, 0, 0)
    EndIf
    Local $hBmp_tmp = _GDIPlus_BitmapCreateFromHBITMAP($hMemoryBMP) ;convert GDI bitmap to GDI+ bitmap
    If @error Then
        _WinAPI_DeleteObject($hMemoryBMP)
        _ClipBoard_Close()
        Return SetError(4, 0, 0)
    EndIf
    _WinAPI_DeleteObject($hMemoryBMP)
    _ClipBoard_Close()
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;create empty bitmap
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBmp_tmp, $iX, $iY, $iW, $iH, 0, 0, $iW, $iH) ;copy selection to empty bitmap
    If $bCursor Then
        Local $aCursor = _WinAPI_GetCursorInfo()
        If $aCursor[1] Then
            Local $hBmp_Icon = _GDIPlus_BitmapCreateFromHICON32($aCursor[2])
            _GDIPlus_GraphicsDrawImage($hCtxt, $hBmp_Icon, $aCursor[3], $aCursor[4])
            _GDIPlus_BitmapDispose($hBmp_Icon)
        EndIf
    EndIf
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_BitmapDispose($hBmp_tmp)
    If $sFile = "" Then Return $hBitmap ;don't forget to dispose image later when not used anymore
    _GDIPlus_ImageSaveToFile($hBitmap, $sFile)
    _GDIPlus_BitmapDispose($hBitmap)
    Return 1
EndFunc
Edit: added cursor capture

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

Thanks for your comments.

It's the Aero thing which prevents the tooltip being captured.

However, enabling Aero slows down BilBlt used in another app by the factot of 15-20!

Anyway, thanks and have a nice day!

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...