Clipboard to Array Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
NewbieITguy
Posts: 8
Joined: 21 Jun 2021, 09:49

Clipboard to Array

Post by NewbieITguy » 21 Jun 2021, 10:01

Good morning everyone!

Okay, so I have a small issue that's been bugging me. I've been trying to automate more and more with AHK and so far, it's been wonderful. I've just been doing simple stuff so far.

Now I'm branching out and trying to see if I can automate copying cells from a google sheet, then using ahk to paste the data in different cells in the right way I want.

In other words, in both sheets, the data in the cells I need are there, they are just in the wrong order.! My solution was to:

1) Copy the data to a clipboard
2) Save that data into an array
3) Use AHK to rearrange the data in said array
4) Save that back into the clipboard

Then I could just press a button to paste everything in another sheet.

Right now, I'm stuck at part 2, I'm not sure how to do this.

an example of what I'm doing is here:
image.png
image.png (1.43 KiB) Viewed 942 times
to
image.png
image.png (1.42 KiB) Viewed 942 times

I'm just getting a line of info from some cells and then rearrange that. I've looked at some older posts but I can't find anything doing exactly what I want.

AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Clipboard to Array  Topic is solved

Post by AHKStudent » 21 Jun 2021, 11:02

copy the items in excel then run this code and then go back and paste

Code: Select all

array := StrSplit(clipboard, a_tab)
Clipboard := array[2] a_tab array[4] a_tab array[1] a_tab array[3]
ExitApp

NewbieITguy
Posts: 8
Joined: 21 Jun 2021, 09:49

Re: Clipboard to Array

Post by NewbieITguy » 23 Jun 2021, 13:34

AHKStudent wrote:
21 Jun 2021, 11:02
copy the items in excel then run this code and then go back and paste

Code: Select all

array := StrSplit(clipboard, a_tab)
Clipboard := array[2] a_tab array[4] a_tab array[1] a_tab array[3]
ExitApp
Thanks so much for this! This was exactly what I needed. I wasn't aware of the StrSplit command.

Post Reply

Return to “Ask for Help (v1)”