IAMK Posted December 9, 2018 Posted December 9, 2018 I have a script which saves cropped screenshots to a folder. drawRect() returns the x and y coordinates of the screenshot I wish to take. Func snip() _ScreenCapture_Capture($saveFolder & "temp" & $fileType) SplashImageOn("", $saveFolder & "temp" & $fileType, @DesktopWidth, @DesktopHeight, -1, -1, 1) drawRect() _ScreenCapture_Capture($saveFolder & String($picNum) & $fileType, $iX1, $iY1, $iX2, $iY2, False) SplashOff() ;_ClipPutFile($saveFolder & String($picNum) & $fileType) $hClipboard_Bitmap = _GDIPlus_BitmapCreateFromFile($saveFolder & String($picNum) & $fileType) $hClipboard_BitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClipboard_Bitmap) $hHBmp_Clipboard = _WinAPI_CopyImage($hClipboard_BitmapGDI, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG)) _WinAPI_Bitmap2Clipboard($hHBmp_Clipboard) $picNum = $picNum + 1 EndFunc 1- I tried adding _ClipPutFile() then Ctrl+Ving the image into Word, but it doesn't work: "Word cannot obtain the data for the Snips\9.bmp link." The file does exist and is viewable, so why the error? 2- I tried using GDIPlus.au3 as I saw in solutions for #1 not working, and it still didn't work for me. What is the difference between how _ClipPutFile() works and GDIPlus.au3 if all I want to do is copy an image into clipboard? 3- I also tried using SplashImageOn(), but it only works for .jpg and .bmp formats. How do I get the same to work with .png? 4- On top of freezing my screen, how should I go about getting an effect like the Snipping Tool? Whitewash the screen (temp.bmp), and the selected area is the original colour. 5- This script breaks my Ctrl+C and Ctrl+V ability. How do I stop this behaviour? Thank you in advance.
Aelc Posted December 9, 2018 Posted December 9, 2018 (edited) What u exactly want to do ? Just save it ? why u splash it on then im a bit confused #include <ScreenCapture.au3> $iX1 = 100 $iY1 = 100 $iX2 = 500 $iY2 = 500 $bmp = _ScreenCapture_Capture("",$iX1, $iY1, $iX2, $iY2) _ScreenCapture_SaveImage ("screen.jpg",$bmp) thats how to safe it Edited December 9, 2018 by Aelc why do i get garbage when i buy garbage bags?
IAMK Posted December 9, 2018 Author Posted December 9, 2018 (edited) The first one saves a fullscreen picture then splashes it so that the second screenshot of the area I want will be frozen while I try to take a screenshot. Imagine watching a movie with Chinese subtitles, and I want to take a screenshot of a certain word before it disappears. This is where saving comes in. The second use I want is basically just an easy to use snipping tool. Take screenshots and copy to word to make documents by simply using ` as my hotkey, rather than going through the hassle of Window's Snipping Tool. Edited December 9, 2018 by IAMK
Aelc Posted December 9, 2018 Posted December 9, 2018 I still dont know why u wanna splash it on if u want to set it to word try _word_docpictureadd i actually got no word so i cant help u there ... the coordinates are actually always the same? #include <ScreenCapture.au3> $iX1 = 159 $iY1 = 182 $iX2 = 1315 $iY2 = 899 $bmp = _ScreenCapture_Capture("") _ScreenCapture_SaveImage ("screen.jpg",$bmp) SplashImageOn ( "","screen.jpg",@DesktopWidth,@DesktopHeight ) $bmp_cut = _ScreenCapture_Capture("",$iX1, $iY1, $iX2, $iY2) SplashOff() _ScreenCapture_SaveImage ("screen_cut.jpg",$bmp_cut) why do i get garbage when i buy garbage bags?
IAMK Posted December 9, 2018 Author Posted December 9, 2018 Splash is the only way I found to freeze the graphics on my screen. I don't want _word_docpictureadd as not all pictures will be going to a document, and I could have multiple documents open. By default the image is saved. If I wanted to paste it somewhere, it would already be copied to the clipboard and ready for me to do so. The 4 coordinates are not the same. I get them from drawRect(), but for this example, they can be the values you put.
Aelc Posted December 9, 2018 Posted December 9, 2018 (edited) ouh #include <ScreenCapture.au3> #include <Misc.au3> #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $iX1 = 159 $iY1 = 182 $iX2 = 1315 $iY2 = 899 $bmp = _ScreenCapture_Capture("") _ScreenCapture_SaveImage ("screen.jpg",$bmp) $bmp_cut = _ScreenCapture_Capture("",$iX1, $iY1, $iX2, $iY2) _ScreenCapture_SaveImage ("screen_cut.jpg",$bmp_cut) SplashImageOn ( "","screen_cut.jpg",@DesktopWidth,@DesktopHeight ) Sleep ( 500 ) send ("{Printscreen}" ) SplashOff() dont know how to get this with winapi or GDI+ but if it helps... at least u got the snip on the clipboard EDIT: if it takes to long for u i will get another way later but have to go for now Edited December 9, 2018 by Aelc why do i get garbage when i buy garbage bags?
IAMK Posted December 9, 2018 Author Posted December 9, 2018 @Aelc Thanks, but that's not really what I'm trying to achieve. It's actually the opposite.
Aelc Posted December 9, 2018 Posted December 9, 2018 (edited) expandcollapse popup#include <ScreenCapture.au3> #include <Misc.au3> #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <ClipBoard.au3> #include <Constants.au3> #Include <WinAPI.au3> $iX1 = 159 $iY1 = 182 $iX2 = 1315 $iY2 = 899 $freezetime = 1000 While 1 HotKeySet ( "{F5}", "_snipsplash" ) HotKeySet ( "{F3}", "_exit" ) WEnd Func _snipsplash() $bmp = _ScreenCapture_Capture("") $bmp_cut = _ScreenCapture_Capture("",$iX1, $iY1, $iX2, $iY2) _ScreenCapture_SaveImage ("screen.jpg",$bmp) _ScreenCapture_SaveImage ("screen_cut.jpg",$bmp_cut) SplashImageOn ( "","screen.jpg",@DesktopWidth,@DesktopHeight ) _GDIPlus_Startup () $image = _GDIPlus_ImageLoadFromFile("screen_cut.jpg") $gdibmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($image) $bitmap = _WinAPI_CopyImage($gdibmp, 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($bitmap, $CF_BITMAP) _ClipBoard_Close() _GDIPlus_ImageDispose($image) _GDIPlus_Shutdown() Sleep ( $freezetime ) SplashOff() EndFunc Func _exit () HotKeySet ( "{F5}" ) HotKeySet ( "{F3}" ) Exit EndFunc My last try ... did i really dont get it or was it bad description? ( im a bit tired too actually i should safe me to bed ) its exactly what u said: Screenshot -> Splash up for freeze 2nd Screenshot of XY Coords with copy to clipboard and CTRL + V insert to paint or something even if i didnt hit the right thing i think u can tinker it to ur idea now at least i just had more then 2secs time for write xD sry for my bad english x) Edited December 9, 2018 by Aelc why do i get garbage when i buy garbage bags?
Nine Posted December 9, 2018 Posted December 9, 2018 You may try this one : #include <GDIPlus.au3> #include <Clipboard.au3> #include <ScreenCapture.au3> Opt ("MustDeclareVars", 1) _GDIPlus_Startup() Local $hBitmap = _ScreenCapture_Capture("") Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) Local $iLeft = 150, $iTop = 100, $iRight = 500, $iBottom = 400 Local $hClone = _GDIPlus_BitmapCloneArea($hImage, $iLeft, $iTop,$iRight,$iBottom, $GDIP_PXF32RGB) _GDIPlus_ImageSaveToFile($hClone, "Crop_Image.jpg") _ScreenCapture_SaveImage ("Full_Screen.jpg", $hBitmap, True) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone) Local $hCopy = _WinAPI_CopyImage($hBitmap) _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($hCopy, $CF_BITMAP) _ClipBoard_Close() _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hClone) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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