3

To illustrate my dilemma as simply as possible:

I have a list of values ranging from 1-10 that I want to copy and store.

When I press Ctrl+V (or any paste execution), I want 1 to be displayed. When I press Ctrl+V again, I want 2 to be displayed. This continues until the end of the list.

For context, I have to assign users to a whole bunch of groups. Problem is that with our system, I can only paste and assign one group at a time, and some users can be assigned 200+ groups. I've been having to go to an Excel spreadsheet, copy an id, paste it into our system and add them to the user, go back to Excel and go to the next row and repeat the process. It would be great if I can stay in the system screen, have the groups stored in an array in the clipboard, and paste them one by one without having to go back and forth to Excel.

Thanks!

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • How do you get to the next row to paste into? Does arrow down work? – Gantendo Mar 31 '22 at 03:42
  • Can you make some screenshots and edit the question to include urls? You can use something like Imgur.com – Gantendo Mar 31 '22 at 03:46
  • Since you're using Excel: create your list of IDs as a plain-text file, with each ID separated by a newline. Then just copy the entire list of IDs and paste it into the appropriate column in your Excel spreadsheet (for example, the "ID" column). Excel will populate each row in the ID column with just one number, from start to finish. – CuriosityCalls Mar 31 '22 at 03:46
  • @CuriosityCalls I think OP is copying from, not pasting to, Excel. – Gantendo Mar 31 '22 at 03:50
  • @Gantendo I can't add screenshots because of company policy. Arrow down does work but I'm trying to circumvent having to "ctrl+c, alt+tab, ctr+v, enter, alt+tab, arrow down, ctrl+c..." 10 times. I would ideally like to find a way to copy the whole list, and have ctrl+v paste the values individually. This would make the new flow look like "ctrl+c, alt+tab, ctrl+v, enter, ctrl+v, enter, ctrl+v, enter, etc., etc.) Hope this makes more sense! – user1681312 Mar 31 '22 at 04:14
  • @curiositycalls Gantendo is correct my issue is moreso copying a bunch of values from Excel and pasting them elsewhere one-by-one – user1681312 Mar 31 '22 at 04:15
  • @user1681312 Yeah the idea is to automate the entire process of Ctrl-V, arrow down ad nauseam – Gantendo Mar 31 '22 at 04:18
  • @Gantendo I appreciate the help! I misinterpreted your first comment and I apologize. I get the next value of the list by pressing the down arrow and copying the cell. However, I paste the value on a web browser input box that can only take one value at a time. So I'm trying to figure a way to copy the whole list from the start and paste the values on the web browser one by one, instead of switching back to excel, going one row down to copy the next value, and going back to the web browser to paste that value. – user1681312 Mar 31 '22 at 04:49
  • @user1681312 Ok, I've edited the example below. Should work now. – Gantendo Mar 31 '22 at 05:17
  • 1
    This isn't really a question about Excel. The multi-line clipboard data could have come from any source. It is really a question about how to manipulated the Windows clipboard in order to parse multi-line text into single lines. Great answer though by @Gantendo – ExcelEverything Apr 01 '22 at 12:24

1 Answers1

2

A very basic example in AutoIt:

#include <Array.au3>

$sText = ClipGet() ;store the text that is currently on the clipboard
ConsoleWrite($sText)


$aArray = StringSplit($sText, @CRLF, BitOr($STR_NOCOUNT, $STR_ENTIRESPLIT))
_ArrayDisplay($aArray, "Clipboard") ;display the copied text to see if it is OK to paste


$currItem = 0;

While 1

    If _IsPressed('2C') Then ; Print Screen https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm
        ConsoleWrite("Print Screen was pressed" & @CRLF)
        Sleep(100)


        ClipPut($aArray[$currItem])
        Sleep(100)
        Send("^v")
        Sleep(100)

        $currItem = $currItem + 1

        If $currItem = UBound($aArray) Then
            ConsoleWrite("DONE!" & @CRLF)
            ClipPut("") ;empty the clipboard
            Exit
        EndIf

    EndIf

WEnd



Func _IsPressed($HexKey)
   Local $AR
   $HexKey = '0x' & $HexKey
   $AR = DllCall("user32","int","GetAsyncKeyState","int",$HexKey)
   If NOT @Error And BitAND($AR[0],0x8000) = 0x8000 Then Return 1
   Return 0
EndFunc

Copy multiple lines of text.

Start the script.

It shows a dialog with a list of all the lines (so you can confirm you've copied the correct data).

After you close the dialog, every time you press Print Screen it pastes a line until all the lines are done, then it empties the clipboard and quits.

Gantendo
  • 4,615
  • 1
  • 18
  • 30
  • 1
    works like a charm! – user1681312 Mar 31 '22 at 15:03
  • @user1681312 If you need some changes let me know. I highly recommend learning a simple scripting language like AutoIt, Automating all kinds of repetitive and boring tasks has saved me a lot of time. – Gantendo Mar 31 '22 at 15:16