Sign in to follow this  
Followers 0
ozmike

Clipboard non text get and put

3 posts in this topic

#1 ·  Posted (edited)

Hi

clipput and clipget will get & put text from clipboard.

I want to get everything on clipboard (not just text) store it in a variable

and then at some later time restore it?

In autoit how do you copy the whole clipboard contents (not just text) and restore it ?

I noticed in autohotkey they have a ClipboardAll function -

ClipboardAll contains everything on the clipboard (such as pictures and formatting). It is most commonly used to save the clipboard's contents so that the script can temporarily use the clipboard for an operation. When the operation is completed, the script restores the original clipboard contents as shown below:

whats autoit equivalent?

This is my attempt can't get it to work i'm really stumped..

any ideas - does anyone know how to do this?

ah ha - this might be the bones i', looking for...

tell us if you have any other ideas...

#include
#include
#include
#include

Opt('MustDeclareVars', 1)

Global $iMemo

_Main()

Func _Main()
Local $hGUI, $iFormat, $iCount

; Create GUI
$hGUI = GUICreate("Clipboard", 600, 400)
$iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()

; Open the clipboard
If Not _ClipBoard_Open ($hGUI) Then _WinAPI_ShowError ("_ClipBoard_Open failed")

; Show clipboard formats available
MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats ())

; Enumerate clipboard formats before
Do
$iFormat = _ClipBoard_EnumFormats ($iFormat)
If $iFormat <> 0 Then
$iCount += 1
MemoWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr ($iFormat) & " " & $iFormat)
EndIf
Until $iFormat = 0
local $v,$f

; backup clipboard
$v = _ClipBoard_GetData ()
$f = _ClipBoard_EnumFormats (0)
ConsoleWrite("Clipboard formats before..: " & _ClipBoard_CountFormats()& @CRLF)

; clear clipboard
clipput("")

; restore clipboard
_ClipBoard_SetData ($v , $f)
; Close the clipboard
_ClipBoard_Close ()

If Not _ClipBoard_Open ($hGUI) Then _WinAPI_ShowError ("_ClipBoard_Open failed")

ConsoleWrite("Clipboard formats after restore..: " & _ClipBoard_CountFormats()& @CRLF)

;$v = _ClipBoard_GetData ()
ConsoleWrite("Clipboard formats ..: " & _ClipBoard_CountFormats()& @CRLF)
sleep(1000);
MemoWrite("====== " )

; Show clipboard formats available
MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats ())

; Enumerate clipboard formats after
Do
$iFormat = _ClipBoard_EnumFormats ($iFormat)
If $iFormat <> 0 Then
$iCount += 1
MemoWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr ($iFormat) & " " & $iFormat)
EndIf
Until $iFormat = 0

; Close the clipboard
_ClipBoard_Close ()

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite

;_ClipBoard_SetData ("ClipBoard Library")

;local $v = _ClipBoard_GetData ()

;_ClipBoard_SetData ($v)
Edited by ozmike

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Did you have a look at the ClipBoard UDF that comes with AutoIt?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks i have looked at this udf - for last couple of weeks

copying non text from clipboard is non trival - !

just found this might help - the bones of another - auto it explorer...

Edited by ozmike

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