Jump to content

Recommended Posts

Posted (edited)

Good afternoon,

I created a function in my script to take out a print of a mirroring window on my computer. He functioned normally until I format my machine. Soon after formatting it returns False in _ClipBoard_Open (0) function and have tried everything to solve. I used the _ClipBoard_Close () and _ClipBoard_Empty () and was not solved my problem.

The clipboard is normal cut and paste data without any problems. But my job does not let me open this clipboard and prevent other applications to use as does the _ClipBoard_Open function.

My code below, Variables $caminho, $esquerda, $topo, $largura, $altura from outside the function

Func _CapturarEsp($caminho)

   Send("{PRINTSCREEN}")

   If Not _ClipBoard_Open(0) Then
      ConsoleWrite("_ClipBoard_Open failed" & @crlf)
      exit 1 
   EndIf

   Local $hBmp = _ClipBoard_GetDataEx($CF_BITMAP)
   _GDIPlus_Startup()

   Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
   Local $hClone = _GDIPlus_BitmapCloneArea($hImage, $esquerda, $topo, $largura, $altura, $GDIP_PXF24RGB)
   If @error Then exit 1 
   
   ; Save bitmap to file
   _GDIPlus_ImageSaveToFile($hClone, $caminho)
   _GDIPlus_BitmapDispose($hImage)
   _GDIPlus_BitmapDispose($hClone)
   _GDIPlus_Shutdown()
   If @error Then exit 1
   
   _ClipBoard_Close()
   If @error Then exit 1
  
EndFunc

Does anyone know how to help me? what might be going wrong?

Thank you!

Edited by Israel
Posted

modified the script so you can be simple, as it became follows:

Send("{PRINTSCREEN}")

If Not _ClipBoard_Open(0) Then _WinAPI_ShowError("_ClipBoard_Open failed")


It was carried out the print image and then open the clipboard so you can not be interrupted by any other application, but in _Clipboard_Open function that does this action of the error because it can not access the clipboard

Posted

Strange, if I withdraw Send ("{} PRINTSCREEN") it works but then the image will not have to work the rest of the function. The use of _ScreenCapture_Capture function ("") does not save me clipboard so you can recover forward more

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