Jump to content

Recommended Posts

Posted (edited)

Here's a UDF to save and restore the entire clipboard contents. I was inspired by AHK's ClipboardAll function, which is missing from AutoIt's clipboard UDF's. If anyone thinks this is worthy of submitting for Standard UDF inclusion, let me know. Otherwise I won't bother.

I'm not sure yet whether memory allocated with _MemGlobalAlloc() is automatically freed when the script closes, so I included the function to free it. If this is not necessary, then it will be removed.

Notes on Memory Management:

Thanks to Valik and ProgAndy for their helpful discussion.

The SetClipboardData() function (_Clipboard_SetDataEx()) transfers ownership of the hMem object to the Clipboard. This means that after running this function your script no longer owns that memory, and should not free it. This means -

1. _Clipboard_GetAll() creates a local script owned copy of the Clipboard in memory. If this copy is never used, ie put back onto the Clipboard with _Clipboard_PutAll(), then it MUST be freed with _Clipboard_MemFree() before exiting the script or reusing the variable again with _Clipboard_GetAll(). If not, the memory may be leaked.

2. If the copied memory is at some point placed back on the Clipboard with _Clipboard_PutAll(), then the Clipboard now owns this memory. You should NOT free it with _Clipboard_MemFree() at this point.

UPDATE 1: 2008-09-25

Updated the UDF and example based on the memory management notes above.

UPDATE 2: 2009-10-23

Updated to use memcpy_s instead of _MemMoveMemory(). Added some more comments.

UPDATE 3: 2009-10-24

Small change to return values of _MemCopyMemory(). Added a second example.

_Clipboard.au3 -

#include-once
#include <Clipboard.au3>

Func _Clipboard_GetAll(ByRef $avClip)
    Local $iFormat = 0, $hMem, $hMem_new, $pSource, $pDest, $iSize, $iErr = 0, $iErr2 = 0

    Dim $avClip[1][2]

    If Not _ClipBoard_Open(0) Then Return SetError(-1, 0, 0)
    Do
        $iFormat = _ClipBoard_EnumFormats($iFormat)
        If $iFormat <> 0 Then
            ReDim $avClip[UBound($avClip) + 1][2]
            $avClip[0][0] += 1
            ; aClip[n][0] = iFormat, aClip[n][1] = hMem
            $avClip[UBound($avClip) - 1][0] = $iFormat
            $hMem = _ClipBoard_GetDataEx($iFormat)
            If $hMem = 0 Then
                $iErr += 1
                ContinueLoop
            EndIf
            $pSource = _MemGlobalLock($hMem)
            $iSize = _MemGlobalSize($hMem)
            $hMem_new = _MemGlobalAlloc($iSize, $GHND)
            $pDest = _MemGlobalLock($hMem_new)
            _MemCopyMemory($pSource, $pDest, $iSize)
            If @error Then $iErr2 += 1
            _MemGlobalUnlock($hMem)
            _MemGlobalUnlock($hMem_new)
            $avClip[UBound($avClip) - 1][1] = $hMem_new
        EndIf
    Until $iFormat = 0
    _ClipBoard_Close()
    ; Return:
    ; | 0       - no errors
    ; |-2       - _MemGlobalAlloc errors
    ; |-4       - _MemCopyMemory errors
    ; |-6       - both errors
    ; @extended:
    ;           - total number of errors
    Local $ErrRet = 0
    If $iErr Then $ErrRet -= 2
    If $iErr2 Then $ErrRet -= 4
    If $ErrRet Then
        Return SetError($ErrRet, $iErr + $iErr2, 0)
    Else
        Return 1
    EndIf
EndFunc

Func _ClipBoard_PutAll(ByRef $avClip)
    ; DO NOT free the memory handles after a call to this function
    ; the system now owns the memory
    Local $iErr = 0

    If Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] <= 0 Then Return SetError(-1, 0, 0)

    If Not _ClipBoard_Open(0) Then Return SetError(-2, 0, 0)
    If Not _ClipBoard_Empty() Then
        _ClipBoard_Close()
        Return SetError(-3, 0, 0)
    EndIf
    ; seems to work without closing / reopening the clipboard, but MSDN implies we should do this
    ; since a call to EmptyClipboard after opening with a NULL handle sets the owner to NULL,
    ; and SetClipboardData is supposed to fail, so we close and reopen it to be safe
    _ClipBoard_Close()
    If Not _ClipBoard_Open(0) Then Return SetError(-3, 0, 0)
    For $i = 1 To $avClip[0][0]
        If _ClipBoard_SetDataEx($avClip[$i][1], $avClip[$i][0]) = 0 Then $iErr += 1
    Next
    _ClipBoard_Close()
    If $iErr Then
        Return SetError(-4, $iErr, 0)
    Else
        Return 1
    EndIf
EndFunc

Func _Clipboard_MemFree(ByRef $avClip)
    Local $iErr = 0

    If Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] <= 0 Then
        Dim $avClip[1][2]
        Return SetError(-1, 0, 0)
    EndIf

    For $i = 1 To $avClip[0][0]
        If Not _MemGlobalFree($avClip[$i][1]) Then $iErr += 1
    Next
    Dim $avClip[1][2]
    If $iErr Then
        Return SetError(-2, $iErr, 0)
    Else
        Return 1
    EndIf
EndFunc

Func _MemCopyMemory($pSource, $pDest, $iLength)
    Local $aResult = DllCall("msvcrt.dll", "int:cdecl", "memcpy_s", "ptr", $pDest, "ulong_ptr", $iLength, "ptr", $pSource, "ulong_ptr", $iLength)
    If @error Then Return SetError(@error, 0, -1)
    Return SetError(Number($aResult[0] <> 0), 0, $aResult[0])
EndFunc

Example 1: copy something to the clipboard first -

#include <_Clipboard.au3>
#include <Array.au3>

Global $aClip

ConsoleWrite("->Clipboard contents from ClipGet():" & @CRLF & ClipGet() & @CRLF)
_Clipboard_GetAll($aClip)
ConsoleWrite(">_Clipboard_GetAll Error:  " & @error & @CRLF)
_ArrayDisplay($aClip)
ConsoleWrite("->Clipboard contents after _Clipboard_GetAll (via ClipGet):" & @CRLF & ClipGet() & @CRLF)
_ClipBoard_Open(0)
_ClipBoard_Empty()
_ClipBoard_Close()
ConsoleWrite("->Proof the clipboard is empty:  |<" & ClipGet() & ">|" & @CRLF)
_ClipBoard_PutAll($aClip)
ConsoleWrite(">_Clipboard_PutAll Error:  " & @error & @CRLF)
ConsoleWrite("->New clipboard contents from ClipGet():" & @CRLF & ClipGet() & @CRLF)

Example 2: remove formatting from copied text -

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <_Clipboard.au3>

HotKeySet("^v", "_ClearAndPaste")
HotKeySet("^+v", "_PasteNormal")

While 1
    Sleep(1000)
WEnd

Func OnAutoItExit()
    ; unset hotkeys
    HotKeySet("^v")
    HotKeySet("^+v")
EndFunc

Func _ClearAndPaste() ; CTRL+v
    HotKeySet("^v") ; unset hotkey
    Local $aClip
    _Clipboard_GetAll($aClip) ; save clipboard contents
    Local $sClip = ClipGet() ; get clipboard as plain text
    ClipPut($sClip) ; put clear text back on clipboard
    Send("^v") ; paste it
    _Clipboard_PutAll($aClip) ; restore previous contents (clears current contents)
    HotKeySet("^v", "_ClearAndPaste") ; reset hotkey
EndFunc

Func _PasteNormal() ; CTRL+SHIFT+v
    HotKeySet("^v") ; unset hotkey
    Send("^v") ; paste
    HotKeySet("^v", "_ClearAndPaste") ; reset hotkey
EndFunc
Edited by wraithdu
Posted (edited)

Here's a _Clipboard_Wait() function, which pauses the script until the clipboard contents change. It has 2 optional parameters, a command to execute before waiting (can also be an array of commands), and a timeout value. Send the command(s) as a string(s) (IMPORTANT!!), as in the example. Not exactly suitable for a UDF since it requires some global variables. But should be good for individual needs.

The optional command is the best way to run commands that will immediately effect the clipboard, as in the example. Otherwise, the notification may be missed.

_Clipboard_Wait() -

#include <Clipboard.au3>
#include <WindowsConstants.au3>

Global $bClipwaitExit, $hClipwaitNextHwnd

Func _Clipboard_Wait($cmd = "", $timeout = -1)
    Local $gui, $timer = 9999
    
    If $timeout > -1 Then $timer = $timeout
    $bClipwaitExit = False
    $gui = GUICreate("")
    $hClipwaitNextHwnd = _ClipBoard_SetViewer($gui)

    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")
    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    
    If IsArray($cmd) Then
        For $i = 0 To UBound($cmd) - 1
            Execute($cmd[$i])
        Next
    Else
        Execute($cmd)
    EndIf
    Do
        Sleep(10)
        If $timeout > -1 Then $timer -= 10
    Until $bClipwaitExit Or $timer <= 0
    
    _ClipBoard_ChangeChain($gui, $hClipwaitNextHwnd)
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "")
    GUIRegisterMsg($WM_CHANGECBCHAIN, "")
    GUIDelete($gui)
EndFunc

Func WM_DRAWCLIPBOARD($hWnd, $Msg, $wParam, $lParam)
    If $hClipwaitNextHwnd <> 0 Then _SendMessage($hClipwaitNextHwnd, $WM_DRAWCLIPBOARD, $wParam, $lParam)
    $bClipwaitExit = True
EndFunc

Func WM_CHANGECBCHAIN($hWnd, $Msg, $wParam, $lParam)
; wParam = window being removed
; lParam = window in chain after window being removed
    If $wParam == $hClipwaitNextHwnd Then
        $hClipwaitNextHwnd = $lParam
    Else
        If $hClipwaitNextHwnd <> 0 Then _SendMessage($hClipwaitNextHwnd, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc

; === EXAMPLE ===

HotKeySet("{DEL}", "MY_DEL")
HotKeySet("{ESC}", "MY_EXIT")

While 1
    Sleep(1000)
WEnd

Func MY_DEL()
    Local $timer
    ConsoleWrite("Old clip:  " & ClipGet() & @CRLF)
    _Clipboard_Wait('ClipPut("")')
    $timer = TimerInit()
    _Clipboard_Wait('Send("^c")')
    MsgBox(0, "", "Waited:  " & TimerDiff($timer) & @CRLF & @CRLF & ClipGet())
EndFunc

Func MY_EXIT()
    Exit
EndFunc
Edited by wraithdu
  • Moderators
Posted

Nice work. Don't know if you know this or not, but the minimum sleep is 10 ms. Anything less than that goes the default 10 anyway.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Huh, I didn't know that, but it explains some results I was getting last night. Thanks, will update accordingly!

$dwMilliSeconds = 5
DllCall("kernel32.dll", "none", "Sleep", "dword", $dwMilliSeconds)

Is a bit more accurate than Sleep(), I believe it doesn't have the imposed limitation of 10 ms. (untested)

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
  • Moderators
Posted (edited)

$dwMilliSeconds = 5
DllCall("kernel32.dll", "none", "Sleep", "dword", $dwMilliSeconds)

Is a bit more accurate than Sleep(), I believe it doesn't have the imposed limitation of 10 ms. (untested)

What's the loss of ms for calling that function versus calling Sleep() over a period of time? ... Just curious (and don't have time to test, but assuming you have).

Edit:

P.S. I really like the GUI idea wraithdu.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Simply put try this.. (results may vary)

$dll=DllOpen("kernel32.dll")

$time = 100

$sleep = ""
$dllcll = ""

$count = 100

For $i = 1 to $count
    
    $timer=TimerInit()
    Sleep($time)
    ConsoleWrite("using sleep: "& TimerDiff($timer)&" milliseconds"&@CRLF)
    $sleep += TimerDiff($timer)
    
    $timer=TimerInit()
    DllCall($dll,"none","Sleep","dword",$time)
    ConsoleWrite("using dllcall: " & TimerDiff($timer)&" milliseconds"&@CRLF)
    $dllcll += TimerDiff($timer)
Next

ConsoleWrite("sleep avg: "& $sleep/$count &@LF& "dllcall avg: "& $dllcll/$count &@lf)

Results

sleep avg: 109.01373219222
dllcall avg: 106.430769832479
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
  • Moderators
Posted (edited)

Simply put try this.. (results may vary)

$dll=DllOpen("kernel32.dll")

$time = 100

$sleep = ""
$dllcll = ""

$count = 100

For $i = 1 to $count
    
    $timer=TimerInit()
    Sleep($time)
    ConsoleWrite("using sleep: "& TimerDiff($timer)&" milliseconds"&@CRLF)
    $sleep += TimerDiff($timer)
    
    $timer=TimerInit()
    DllCall($dll,"none","Sleep","dword",$time)
    ConsoleWrite("using dllcall: " & TimerDiff($timer)&" milliseconds"&@CRLF)
    $dllcll += TimerDiff($timer)
Next

ConsoleWrite("sleep avg: "& $sleep/$count &@LF& "dllcall avg: "& $dllcll/$count &@lf)

Results

sleep avg: 109.01373219222
dllcall avg: 106.430769832479
Thanks... sorry wraith, no more hijacking :)

Edit:

Impressive actually:

sleep avg: 107.561575563375

dllcall avg: 101.803290641688

But it does use more cpu cycles. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  • 1 year later...
Posted (edited)

I took another look through this UDF while considering a script to remove formatting from copied text. Just small updates.

Musings:

I still can't figure out why _ClipBoard_SetDataEx() doesn't fail after opening the clipboard with a NULL handle and calling _ClipBoard_Empty() without reopening the clipboard. MSDN and the help file both say that it should. I've added a comment about this and the proper procedure (closing and reopening the clipboard) to the _Clipboard_PutAll() function, but it doesn't seem to be necessary (comment out those extra lines and try it). Any insights feel free to comment.

Lastly, does _MemMoveMemory() (uses the RtlMoveMemory function) destroy the source data? A memory 'move' implies that it should, versus a 'copy' operation which should not. I can't find a definitive answer to this, which is partially why I changed to use memcpy_s instead (it's also faster). If I had to guess, I'd say RtlMoveMemory makes a temporary copy of the source, then copies it to the destination, which is why RtlMoveMemory can have overlapping source and destination locations and memcpy_s cannot, and why memcpy_s is faster (no temporary copy).

Edited by wraithdu
  • 2 years later...
Posted

Wraithdu, this UDF is very useful for me! The ability to save and restore the entire clipboard contents I really missed!

Thanks a lot

  • 2 years later...
Posted (edited)

update - 30-Jun-2014: my version of this function is buggy and i have not investigated the problem yet

6 years later iCode says...
 
I have an interest in seeing this included as an official UDF, though judging by the lack of replies here, i'm not so sure how popular it is. As wraithdu says though, AHK has it :)
 
I hacked it a bit so the script writer need not call _Clipboard_MemFree, which is now handled internally, and changed a few other things. Also added an alternative to _Clipboard_Wait when _ClipBoard_PutAll is called (code is commented out).
 
One thing i am not sure of is why _ClipBoard_GetDataEx returns '0' for some formats. The formats in one test were 49577 and 49756, which are in clipboard memory (if that's the right term) after copying an image in Firefox.

The dll call for _ClipBoard_GetDataEx is:

DllCall("user32.dll", "handle", "GetClipboardData", "uint", $iFormat)

According to MSDN, i'm not seeing anything wrong with the dll call, so i don't why _ClipBoard_GetDataEx fails - is this normal for image/binary data perhaps ???

EDIT: functions updated 29-Apr-2014
 

#include-once
#include <Clipboard.au3>

OnAutoItExitRegister("__AutoItExit_ClipAll")

Global $__bMemFree = False

; #FUNCTION# ====================================================================================================================
; Name ..........: _ClipBoard_GetAll
; Description ...: Backup clipboard content
; Syntax ........: _ClipBoard_GetAll(Byref $avClip)
; Parameters ....: $avClip              - [in/out] An array of variants.
; Return values .: Returns 1 if no error, else 0 and sets @error:
;                  1 = failed to open clipboard
;                  2 = _ClipBoard_GetDataEx failed
;                  3 = _MemGlobalAlloc failed
;                  4 = DllCall failed
;                  5 = _ClipBoard_Close failed
;                  @extended = total number of errors
; Author ........: wraithdu (modified by iCode)
; Modified ......: 29-Apr-2014
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/81267-clipboard-getall-clipboard-putall-clipboard-wait/
; Example .......: No
; ===============================================================================================================================
Func _ClipBoard_GetAll(ByRef $avClip)

    Local $i = 0, $iFormat = 0, $hMem, $hMemNew, $pSource, $pDest, $iSize, $iErr = 0, $iErrEx = 0

    If $__bMemFree = True Then
        __MemFree($avClip)
    Else
        Dim $avClip[1][2]
    EndIf

    If Not _ClipBoard_Open(0) Then Return SetError(1, 1, 0)

    Do
        $iFormat = _ClipBoard_EnumFormats($iFormat)
        If $iFormat = 0 Then ExitLoop
        $hMem = _ClipBoard_GetDataEx($iFormat) ; this can/will fail for some formats - don't know why yet, so let's continue without retutning an error
        If $hMem = 0 Then ContinueLoop

        ; copy the memory
        $pSource = _MemGlobalLock($hMem)
        If $pSource = 0 Then
            $iErr = 3
            $iErrEx += 1
            ExitLoop
        EndIf
        $iSize = _MemGlobalSize($hMem)
        $hMemNew = _MemGlobalAlloc($iSize, $GHND)
        If $hMemNew = 0 Then
            _MemGlobalUnlock($hMemNew)
            $iErr = 4
            $iErrEx += 1
            ExitLoop
        EndIf
        $pDest = _MemGlobalLock($hMemNew)
        If $pDest = 0 Then
            _MemGlobalFree($hMemNew)
            $iErr = 5
            $iErrEx += 1
            ExitLoop
        EndIf
        DllCall("msvcrt.dll", "int:cdecl", "memcpy_s", "ptr", $pDest, "ulong_ptr", $iSize, "ptr", $pSource, "ulong_ptr", $iSize)
        If @error Then
            $iErr = 6
            $iErrEx += 1
        EndIf
        _MemGlobalUnlock($hMem)
        _MemGlobalUnlock($hMemNew)
        $__bMemFree = True
        If $iErr = 6 Then
            __MemFree($avClip)
            ExitLoop
        EndIf

        ; add handle and format to array
        $i += 1
        ReDim $avClip[$i + 1][2]
        $avClip[0][0] = $i
        $avClip[$i][0] = $hMemNew
        $avClip[$i][1] = $iFormat
    Until $iFormat = 0

    If Not _ClipBoard_Close() Then $iErr = 5

    If $iErr Then Return SetError($iErr, $iErrEx, 0)
    Return 1

EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _ClipBoard_PutAll
; Description ...: Restore clipboard content
; Syntax ........: _ClipBoard_PutAll(Byref $avClip)
; Parameters ....: $avClip              - [in/out] An array of variants.
; Return values .: Returns 1 if no error, else 0 and sets @error:
;                  1 = invalid array
;                  2 = _ClipBoard_Open failed
;                  3 = _ClipBoard_Empty failed
;                  4 = _ClipBoard_Close failed
;                  5 = _ClipBoard_Open failed
;                  6 = _ClipBoard_SetDataEx failed
;                  7 = _ClipBoard_Close failed
;                  @extended = total number of errors
; Author ........: wraithdu (modified by iCode)
; Modified ......: iCode 29-Apr-2014
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/81267-clipboard-getall-clipboard-putall-clipboard-wait/
; Example .......: No
; ===============================================================================================================================
Func _ClipBoard_PutAll(ByRef $avClip)

    ; DO NOT free the memory handles after a call to this function - the system now owns the memory
    Local $iErr = 0, $iErrEx = 0 ; , $bOpen, $iTime

    $__bMemFree = False

    If Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] < 1 Then
        Dim $avClip[1][2]
        Return SetError(1, 1, 0)
    EndIf

    ; test if clipboard can be opened
    ; if _ClipBoard_Open failes, the clipboard is likely still being updated, so we keep trying until it succeeds
    ;Local $hTimer = TimerInit()
    ;Do
    ;    $bOpen = _ClipBoard_Open(0)
    ;    Sleep(50)
    ;    $iTime = TimerDiff($hTimer)
    ;Until $bOpen = 1 Or $iTime >= 2000
    ;If $bOpen = 0 Then
    ;    Return SetError(2, 1, 0)
    ;EndIf

    ; empty clipboard
    If Not _ClipBoard_Open(0) Then Return SetError(2, 1, 0) ; comment out if using the code above
    If Not _ClipBoard_Empty() Then
        _ClipBoard_Close()
        Return SetError(3, 1, 0)
    EndIf
    If Not _ClipBoard_Close() Then Return SetError(4, 1, 0)

    ; re-open clipboard and put data
    If Not _ClipBoard_Open(0) Then Return SetError(5, 1, 0)
    For $i = 1 To $avClip[0][0]
        If Not _ClipBoard_SetDataEx($avClip[$i][0], $avClip[$i][1]) Then
            $iErr = 6
            $iErrEx += 1
        EndIf
    Next
    If Not _ClipBoard_Close() Then
        $iErr = 7
        $iErrEx += 1
    EndIf

    If $iErr Then Return SetError($iErr, $iErrEx, 0)
    Return 1

EndFunc

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name ..........: __MemFree
; Description ...: Free clipboard memory
; Syntax ........: __MemFree(Byref $avClip)
; Parameters ....: $avClip              - [in/out] An array of variants.
; Return values .: Returns 1 if no error, else 0 and sets @error:
;                  1 = array is invalid
;                  2 = _MemGlobalFree failed
;                  @extended = total number of errors
; Author ........: wraithdu (modified by iCode)
; Modified ......: 29-Apr-2014
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/81267-clipboard-getall-clipboard-putall-clipboard-wait/
; Example .......: No
; ===============================================================================================================================
Func __MemFree(ByRef $avClip)

    Local $iErr = 0, $iErrEx = 0

    If $__bMemFree = False Then
        Return
    ElseIf Not IsArray($avClip) Or UBound($avClip, 0) <> 2 Or $avClip[0][0] < 1 Then
        Dim $avClip[1][2]
        $__bMemFree = False
        Return SetError(1, 1, 0)
    EndIf

    For $i = 1 To $avClip[0][0]
        If Not _MemGlobalFree($avClip[$i][1]) Then
            $iErr = 2
            $iErrEx += 1
        EndIf
    Next

    $__bMemFree = False
    Dim $avClip[1][2]

    If $iErr Then Return SetError($iErr, $iErrEx, 0)
    Return 1

EndFunc

; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name ..........: __AutoItExit_ClipAll
; Description ...: Free clipboard memory on AutoIt exit
; Syntax ........: __AutoItExit_ClipAll()
; Parameters ....:
; Return values .: None
; Author ........: iCode
; Modified ......: 29-Apr-2014
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func __AutoItExit_ClipAll()
    #forcedef $avClip
    __MemFree($avClip)
EndFunc
Edited by iCode

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

  • 2 months later...
Posted (edited)

It looks really very good.

I test it in next week.

This is good Idea for add this to standard UDF.

But I think it must be indicated by OP, or I'am wrong ?

Edited by mLipok

Signature beginning:
* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
* ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * 

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * 

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted

It seems it not working when you copy screenshot ALT+PrintScreen

But if you make a screenshot and put it in WordPad, and then copy all WordPad content, so now it works toogether with captured image.

Signature beginning:
* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
* ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * 

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * 

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted

Do you use original or updated by iCode version ?

Signature beginning:
* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
* ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * 

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * 

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted

aha.

I confirm that the original works.

so iCode make a bug.

Signature beginning:
* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
* ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * 

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * 

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted

so iCode make a bug.

 

yes, i apparently did :)

i have had trouble with both the original and my version.

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

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