Jump to content

Recommended Posts

Posted (edited)

I'm trying to copy (to either the clipboard or to a new file on disk) the image content of a picturebox control ( [CLASS:ThunderRT6PictureBoxDC; INSTANCE:2] ) from an external app, but so far all I've got is a black rectangle. I've the handle of the control with no problem, but, being new to autoit, can't find a way to manage this. Can someone show me an example script for this purpose ?

Edited by claude21
Posted

I'm trying to copy (to either the clipboard or to a new file on disk) the image content of a picturebox control ( [CLASS:ThunderRT6PictureBoxDC; INSTANCE:2] ) from an external app, but so far all I've got is a black rectangle. I've the handle of the control with no problem, but, being new to autoit, can't find a way to manage this. Can someone show me an example script for this purpose ?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
HotKeySet("{ESC}", "Capture")
While 1

WEnd





Func Capture()
Run("notepad.exe")
Sleep(2000)
$HWND = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")
$hBitmap = BitmapCreateFromControlHWND($HWND)
 _GDIPlus_Startup ()
 $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
  _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")
 _GDIPlus_ShutDown ()
Exit
EndFunc

Func BitmapCreateFromControlHWND($HWND)
Local $Width = _WinAPI_GetWindowWidth($hWnd)
Local $Height =_WinAPI_GetWindowHeight($hWnd)
$DC = _WinAPI_GetDC($HWND)
$CompatibleDC = _WinAPI_CreateCompatibleDC($DC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($DC,$Width, $Height)
_WinAPI_SelectObject($CompatibleDC, $hBitmap)
_WinAPI_BitBlt($CompatibleDC, 0, 0, $Width, $Height, $DC, 0, 0,$SRCCOPY)
Return $hBitmap
EndFunc

صرح السماء كان هنا

 

Posted

Thanks for this code wolf !

This help me a lot. However, it seems that the function can't copy the picturebox data when the main window is minimized, not visible (in background) or whatever state except when in foreground. Is there a way to copy the picturebox data no matter the window state (without bringing the window in focus, eventually restore it if minimized etc etc )??

Posted

Thanks for this code wolf !

This help me a lot. However, it seems that the function can't copy the picturebox data when the main window is minimized, not visible (in background) or whatever state except when in foreground. Is there a way to copy the picturebox data no matter the window state (without bringing the window in focus, eventually restore it if minimized etc etc )??

I know this....But there is no library functions

Undertake this process .

صرح السماء كان هنا

 

Posted (edited)

I know this....But there is no library functions

Undertake this process .

humm, thats weird. Btw, How could I put back the saved image file (from disk) to the clipboard ? never mind, found here

Now, I try to send back the saved image file TO the picturebox control, do you know how to manage that ?

Edited by claude21

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...