Jump to content

Clipboard non text get and put


ozmike
 Share

Recommended Posts

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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...