Max Kipness Posted June 10, 2010 Posted June 10, 2010 Hi, Been searching around the forums and found a couple of snippets that other's claim works, but it doesn't seem to be working for me. I'm basically wanting to be able to copy and image to clipboard, or via the snipping tool in Windows 7 and then click a button that saves this to a file so I could do some further processing with it. Here is what I have.\ #include <GUIConstantsEx.au3> #Include <GDIPlus.au3> #include <ClipBoard.au3> #include <ScreenCapture.au3> _Main() Func _Main() Local $hBmp ; Capture full screen $hBmp = _ClipBoard_GetDataEx ($CF_BITMAP ) ; Save bitmap to file _ScreenCapture_SaveImage (@MyDocumentsDir & "\Image.jpg", $hBmp) EndFunc ;==>_Main Can someone please point me in the right direction. Thanks, Max
KaFu Posted June 10, 2010 Posted June 10, 2010 Help-File example is close...CTRL+ALT+s to save screenshot... #include <ScreenCapture.au3> HotKeySet("{ESC}", "_Exit") HotKeySet("^!s", "_Screenshot") While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Screenshot() Local $hBmp $hBmp = _ScreenCapture_Capture("") $file = FileSaveDialog("Save Screenshot", @ScriptDir, "jpg (*.jpg)", 18, "screenshot.jpg") If Not @error Then _ScreenCapture_SaveImage($file, $hBmp) EndFunc ;==>_Screenshot OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Malkey Posted June 10, 2010 Posted June 10, 2010 (edited) Max Kipness Your example appears to be trying to combine these two methods. #include <ScreenCapture.au3> _ScreenCapture_Capture(@ScriptDir & "\GDIPlus_Image.jpg") ShellExecute(@ScriptDir & "\GDIPlus_Image.jpg")and #include <GDIPlus.au3> #include <ClipBoard.au3> ; Capture full screen Send("{PRINTSCREEN}") ; Screen ;Send("!{PRINTSCREEN}") ; window _Main() ShellExecute(@ScriptDir & "\Image.jpg") Func _Main() Local $hBmp, $hImage If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed") $hBmp = _ClipBoard_GetDataEx($CF_BITMAP) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\Image.jpg") ;$sNewName) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() _ClipBoard_Close() EndFunc ;==>_Main Edited June 10, 2010 by Malkey
Max Kipness Posted June 11, 2010 Author Posted June 11, 2010 Thanks Malkey, your second snippet of code included the function that works. I'm not interested in getting screenshots, but rather wanted to get ANY image that might be in the clipboard. So it worked. Thanks again.
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