Jump to content

Recommended Posts

Posted

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?

Posted

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. 

Posted

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)

 

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

Posted

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. 

  • 4 months later...
Posted

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

 

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