RedwookHighway

ClipGet() after a copy

12 posts in this topic

Good day I am attempting to write a script that will copy the continence of the clipboard to an array every time a copy action is done. I was looking for the best way to signal to my script to run ClipGet() Is there a way for autoit to run a script on copy?

Share this post


Link to post
Share on other sites



I am attempting to write a script that would allow me to copy one line of text after another and then on pressing a hotkey past them into fields in the order I copied them, on at a time. Ideally it would work with both a right click + copy and the Ctrl + C. I was thinking about using a hotkey but it looks like Ctrl will not work with the hotkey. 

Share this post


Link to post
Share on other sites

Well for the most part it would be within a program called ConnectWise. I would be copying data out of there and pasting it into either a web page or Quickbooks. 

Share this post


Link to post
Share on other sites

maybe something that loops constantly.  This demo will show you your array after you have copied 3 different strings to the clipboard.

#include<array.au3>

local $aOut[0]

Do
   sleep(100)
   $sOut = clipget()
   If @Error Then continueloop
   _ArrayAdd($aOut , $sOut)
   ClipPut("")

Until ubound($aOut) > 2

 _ArrayDisplay($aOut)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Thank you very much, I am looking at that now.

Share this post


Link to post
Share on other sites

The example script will not run. Giver me an error Line 3 Array Variable subscript is badly formatted. Looks like it does not like the 0 in the array. I changed the number of elements to 1 and it now works. Thanks this method will form the base of my script. 

Share this post


Link to post
Share on other sites

Thanks jguinch I'm not sure what the clipboard viewer is I will have to do a little reading. 

P.S. Nice cup.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

_ClipBoard_SetViewer is not a graphical viewer, but a "listener" which intercepts clipboard messages.
The example uses a GUI to show how to use the function, but you can use an invisible GUI instead

Edited by jguinch

Share this post


Link to post
Share on other sites

For anyone interested, here is what I ultimately got. It will let me copy multiple lines of text. Once I am done copying I hit the ~ key and then start pasting. The script will run through all the items copied started with the first one and then switch back with a fresh clipboard once it's done.

#include <Array.au3>
#include<HotKey.au3>






Func HotSwitch()
If $modeswitch = 0 Then
    $modeswitch = 1
Else
    $modeswitch = 0
EndIf

EndFunc

HotKeySet("`", "HotSwitch")
;HotKeySet("^v", "HotPaste")

Func HotPasteNorm()
    Send("{SHIFTDOWN}")
    Send("{INS}")
    Send("{SHIFTUP}")
EndFunc

Func HotPaste()

    ClipPut($ClipboardStore[$n])
    Send("{SHIFTDOWN}")
    Send("{INS}")
    Send("{SHIFTUP}")
    sleep(20)
     $n += 1;increment varable n
    sleep(60)
EndFunc

While 1
CopyMode()
PastMode()
Wend

Func CopyMode()
    HotKeySet("^v", "HotPasteNorm")
    Global $ClipboardStore[1]
    Global $modeswitch = 0

    ClipPut("")

    While $modeswitch = 0
        sleep(100)
        $sOut = clipget()
        If @Error Then continueloop
        _ArrayAdd( $ClipboardStore, $sOut)
        ClipPut("")
    WEnd

    Beep(1000, 500)
EndFunc

Func PastMode()
    HotKeySet("^v", "HotPaste")
    Global $n = 1 ;this vallue is used to increment the clipboard counter.
    Local $m = UBound($ClipboardStore)

        Do
        Sleep(100)
        Until $n = $m or $modeswitch = 0
    Redim $ClipboardStore[1]
        $ClipboardStore[0] = ""
        $n = 1

    beep(800, 500)
EndFunc

 

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