Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

copy excel value one by one and paste to another programe


  • Please log in to reply
14 replies to this topic
sam123
  • Guests
  • Last active:
  • Joined: --
Hello all,

Is there any way so that I can read a .txt file which has alfa-numeric number in each line as below and assign it to variable, and then i have to SEND variable (every line ) .

Actually this is an excel column but to make things easy i paste in the .txt file.


QWER1234
QVER6432
ASDF7654
....
....
....
....

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Does each cell have to have its own unique variable for its data or can you re-use the same one for each copy from Excel/paste to another program?

sam123
  • Guests
  • Last active:
  • Joined: --
Thanks for reply.

here is the script i m using now. I need to read the number from .txt or excel file . and SEND to the place of ------- in the script belowthere are around 500 numbers . and i wish the whole process run autometically.
I thin it doesn't mattter if i use same variable or different variable for each line. I thin to use Array but I am new to this.



#space::IfWinExist Citrix1

Send F
-----
send {NumpadEnter}
send M
Send {Tab}
Send {Tab}
Send PGS Baeake
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
Send {space}
send {NumpadEnter}
send F

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
If you want to copy one number from Excel and move it over to the Citrix window you can run this (which I've modified a little to condense down your code):

Send ^c
ClipWait
Send {ENTER 2} ; sends ENTER twice, which goes to the next cell below
WinWait, Citrix1
WinActivate, Citrix1
Send F[color=red]^v[/color]{NumpadEnter}M{Tab [color=red]2[/color]}PGS Baeake{space [color=red]20[/color]}{NumpadEnter}F
return

If you need to copy a whole series of things before you go to the other program and paste them I'm sure we can look into a loop that can copy all of them, something like this:

Loop, 20 ; loops 20 times if you need to copy 20 spreadsheet cells, for example
{
  Send ^c
  ClipWait
  Send {ENTER 2}
  ClipText .= Clipboard "`n" ; appends the current contents of the Clipboard followed by a linefeed(`n, which moves to a new line) to a variable
  Clipboard = ; empties the Clipboard before the next loop
}
Clipboard := ClipText ; saves the contents of the variable ClipText to the Clipboard


sam123
  • Guests
  • Last active:
  • Joined: --
thank you very much. I really appreciate your help. i will try this tommorow at work .

In the case this will not work what if i want to use .txt file which has all the numbers in seperate line. i think processing text file would be easy because the excel file is locked and when i pressed down arrow manually it doesnt go in to the next down cell. so if u write some code for .txt it would be great.

AAA125545
ABD127635
SWH652522
....
....
....


(500)

outstretchedarm
  • Members
  • 6 posts
  • Last active: May 28 2009 01:09 AM
  • Joined: 03 Nov 2006
I'm also really interested in this.

I have a spreadsheet that is a 7 x 128 table.

I'd like to have autohotkey copy the certain cells and paste them into another program I use, called midi-ox,

I've been doing it manually for about 5 hours now and am only about 15% through.

I'm new, but I'm not looking for the code to be given to me, just how I might structure this

thanks

outstretchedarm
  • Members
  • 6 posts
  • Last active: May 28 2009 01:09 AM
  • Joined: 03 Nov 2006
I've been perusing the sight and have learned that when people are serious about being helped, they break down what the macro they are desiring does, step by step. Also, I'll attached some screenies to help visualize:

A) Check excel spreadsheet, "Chords by more" and look up cell B1. This value we'll call the "trigger".

http://www.theflipsi...ach=12651;image

B) Copy this value to the clipboard

C) Open up the application Midi-Ox

D) Click the Insert button in Midi-Ox (see green arrow in screenie2)

http://www.theflipsi...ach=12652;image

E) In new dialogue box, paste the copied value into the 3rd and 4th fields (labeled min and max values)

F) go back to the excel spreadsheet

G) go down one cell

H) Copy that value (I call this second value down the contrabass value)

I) Go back to midi-ox

J) In the dialogue box, click on the "Pass original value (clone) check box so it is checked

K) Also in the dialogue box, paste this second copied value, into the 10th and 11th fields

L) Ok the dialogue box

M) Repeat: go back, copy the trigger value again and paste each of the values for bass, baritone, tenor, etc...till there are no more values in the column

N) Now move over to the next column on the right, and repeat the whole thing again for this new trigger number

O) Stop when there are no more columns with data in excel



thanks in advance for any help. I hope my screenies come through but if not I hope I have supplied enough info

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
screen shots didnt work
Never lose.
WIN or LEARN.

outstretchedarm
  • Members
  • 6 posts
  • Last active: May 28 2009 01:09 AM
  • Joined: 03 Nov 2006
can anybody help without the screenies? i thought I was pretty thorough

thanks

outstretchedarm
  • Members
  • 6 posts
  • Last active: May 28 2009 01:09 AM
  • Joined: 03 Nov 2006
anyone?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
I dont have the other application and am not interested in getting it
there are half a dozen COM based methods for workign with excel posted in the forum i wont repost those here
Never lose.
WIN or LEARN.

wooly_sammoth
  • Members
  • 644 posts
  • Last active: Jul 03 2013 08:08 PM
  • Joined: 12 May 2009
outstretchedarm:

I would script this so that all the values in the excel spreadsheet were copied in one go and saved to variables, then move to the midi-ox program and paste what you need. That way you can set up a loop to move one column over each time.

something like:

clipboard = ; empties the clipboard
WinActivate, (name of excel window)
Send, ^{Home}{Left}^c ; Copies cell B1
ClipWait, 1
StringTrimRight, trigger, clipboard, 2 ; copies the clipboard to the 'trigger' variable (minus the line break at the end)
Loop
{
    clipboard =
    Send, {Down}^c ; Copies Cell B2
    ClipWait, 1
    CellCheck := Clipboard ; This bit checks if the cell is empty 
    StringSplit, CellCheck_, CellCheck, `n, %A_Space% %A_Tab% `n 
    Length := StrLen(CellCheck_1) 
    IfLessOrEqual, Length, 1 ; and if it is stops copying
        Break
    Else, 
        StringTrimRight, value_%A_Index%, clipboard, 2 ; If the cell has a content it is copied to a variable (%A_Index% is the number of times the loop has run so each copied cell down will be one number higher)
}


You now have all the data from the first column of your spreadsheet saved as variables so you just need to activate the midi-ox window and use 'Click' and 'Send' to fill in the various input boxes.

When you've done that just activate the Excel window again, and copy the next line over.

outstretchedarm
  • Members
  • 6 posts
  • Last active: May 28 2009 01:09 AM
  • Joined: 03 Nov 2006
hey thanks alot, now I just need to digest this

CloudSurfer777
  • Members
  • 42 posts
  • Last active: Sep 04 2013 01:55 AM
  • Joined: 02 Oct 2012
Nice code wooly_sammoth!

Gs00000000
  • Members
  • 1 posts
  • Last active: Mar 31 2015 05:04 AM
  • Joined: 31 Mar 2015
Hi,
Just wondering if you could show an example of pasting the clipboard variables into notepad

Paste variable 1
Send {return}
Paste variable 2
Etc?