claude21 Posted January 17, 2010 Posted January 17, 2010 (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 January 21, 2010 by claude21
wolf9228 Posted January 17, 2010 Posted January 17, 2010 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 صرح السماء كان هنا
claude21 Posted January 17, 2010 Author Posted January 17, 2010 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 )??
wolf9228 Posted January 18, 2010 Posted January 18, 2010 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 functionsUndertake this process . صرح السماء كان هنا
claude21 Posted January 19, 2010 Author Posted January 19, 2010 (edited) I know this....But there is no library functionsUndertake this process .humm, thats weird. Btw, How could I put back the saved image file (from disk) to the clipboard ? never mind, found hereNow, I try to send back the saved image file TO the picturebox control, do you know how to manage that ? Edited January 19, 2010 by claude21
claude21 Posted January 25, 2010 Author Posted January 25, 2010 (edited) I've attached a Visual basic 6 example containing the picturebox. I just want to fill this picturebox control with a bitmap file loaded from disk.Project1.exe Edited January 25, 2010 by claude21
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