Sign in to follow this  
Followers 0
t0ddie

Clipboard question

7 posts in this topic

Clipput and clipget writes/reads text to/from the clipboard, but what can you do for images?

I know you can "send" the printscreen button and copy an image to the clipboard but is there a way to display an image from the clipboard using autoit and without opening another application like mspaint?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

search for ScreenCapture.au3

#include <ScreenCapture.au3>

; Capture full screen

_ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg")

; Capture region

_ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image2.jpg", 0, 0, 796, 596)

And for display it , use shellexecute (@MyDocumentsDir & "\GDIPlus_Image1.jpg" ) with the preview images of windows

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

search for ScreenCapture.au3

#include <ScreenCapture.au3>

; Capture full screen

_ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg")

; Capture region

_ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image2.jpg", 0, 0, 796, 596)

And for display it , use shellexecute (@MyDocumentsDir & "\GDIPlus_Image1.jpg" ) with the preview images of windows

That looks like it would be functional to capture and display an image, but Ideally I want to display the image from the clipboard. I basically would like to check the users clipboard, and detect whether it is empty, whether there is text, or whether there is a picture. I don't necessarily need to display the picture, I just need to know if there is a picture saved to it. I want the "status" of the clipboard. I would like to differentiate between the clipboard being blank, and the clipboard having a picture saved to it. It is easy enough with clipget() to check if it has text, but I cannot tell if a picture is saved to it because clipget() returns nothing.


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

No idea if they can help with your specific problem, but take a look at the 'low-level' clipboard functions,

see: Help file -> UDFs -> Clipboard Management

whim

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That looks like it would be functional to capture and display an image, but Ideally I want to display the image from the clipboard. I basically would like to check the users clipboard, and detect whether it is empty, whether there is text, or whether there is a picture. I don't necessarily need to display the picture, I just need to know if there is a picture saved to it. I want the "status" of the clipboard. I would like to differentiate between the clipboard being blank, and the clipboard having a picture saved to it. It is easy enough with clipget() to check if it has text, but I cannot tell if a picture is saved to it because clipget() returns nothing.

Return Value

Success: Returns a string containing the text on the clipboard.

Failure: Sets @error to 1 if clipboard is empty

to 2 if contains a non-text entry.

to 3 or 4 if cannot access the clipboard.

If I copy a png file and run this

$bak = ClipGet()

ConsoleWrite ( "@error : " & @error & @Crlf )

ConsoleWrite ( "Clipboard contains : " & $bak & @Crlf )

I get :

@error : 0

Clipboard contains : C:\Documents and Settings\Administrateur\Bureau\Youtube Subscription Bar And Autoplay Remover_extension_2_1_3_3\screenshot - before.PNG

So return @error is not reliable for determine content of clipboard !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Give this example a try... to perform continous monitoring maybe call the function with AdlibRegister().

#include <ClipBoard.au3>

ConsoleWrite("===========" & @crlf)

ClipPut("")
_Clipboard_Format()
ConsoleWrite("===========" & @crlf)

ClipPut("Test")
_Clipboard_Format()
ConsoleWrite("===========" & @crlf)

Send("{PRINTSCREEN}")
_Clipboard_Format()
ConsoleWrite("===========" & @crlf)

Func _Clipboard_Format_Available()
    Local $iFormat, $iCount
    If Not _ClipBoard_Open(0) Then
        MsgBox(16, "Error", "_ClipBoard_Open failed")
        Exit
    EndIf
    ConsoleWrite("Clipboard formats ..: " & _ClipBoard_CountFormats() & @CRLF)
    Do
        $iFormat = _ClipBoard_EnumFormats($iFormat)
        If $iFormat <> 0 Then
            $iCount += 1
            ConsoleWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr($iFormat) & @TAB & _ClipBoard_GetFormatName($iFormat) & @CRLF)
        EndIf
    Until $iFormat = 0
    _ClipBoard_Close()
EndFunc   ;==>_Clipboard_Format

Share this post


Link to post
Share on other sites

@Kafu

the issue here is I want to determine the contents of the clipboard when the script is ran.

an adlib function would only check the clipboard WHILE the script is running, and would not work until after the clipboard has changed. I want the status of the contents of the clipboard just prior to running the script.

@wakillon I never thought of error return. that would work great!

too bad it is not reliable, it seems it would be exactly what I am looking for.


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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
Sign in to follow this  
Followers 0