Jump to content
Israel

Failure to use the clipboard

Recommended Posts

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

Share this post


Link to post
Share on other sites

What I mean is, does your computer administrator block you from using the clipboard? because that is what your statement implies.

Does ClipGet() work?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

×
×
  • Create New...