 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
edu
Joined: 12 Oct 2006 Posts: 99 Location: Canada
|
Posted: Sat Jan 10, 2009 12:47 am Post subject: Split text in clipboard |
|
|
Hello I am trying to copy and paste some text from several html files to an ms excel file.
The text is copied to the clipboard like this:
NEW NAME
UC 900-640-O Light Blue
UC 900-645-O Peacock Blue
UC 900-650-O Powder Blue
OLD NAME
A9540-O Light Blue
A9545-O Peacock Blue
A9550-O Powder Blue
I want to be able to paste NEW NAME and data below in one column and the OLD NAME in the next column. Basically I wish to transform the data into this:
NEW NAME{TAB}OLD NAME
One of the approaches I thought of was: create a variable to hold the contents of "NEW NAME", paste it in column 1; insert everything from OLD NAME on into a new variable and paste it in column 2.
Another approach could be generating a tab delimited file.
Then I got stuck in the loop construct...
This was what I started trying:
| Code: | NewCode = ""
OldCode = ""
Loop, parse, clipboard, `n, `r
{
NewCode += A_LoopField
if (A_LoopField == "OLD NAME")
{
Break
}
} |
Could you please help me finish this code?
Thanks
Edu _________________ The best things of life are free. |
|
| Back to top |
|
 |
evan Guest
|
Posted: Sat Jan 10, 2009 4:14 am Post subject: |
|
|
| is the data lines always equal? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Sat Jan 10, 2009 4:58 am Post subject: |
|
|
| Code: | testtext =
(
NEW NAME
UC 900-640-O Light Blue
UC 900-645-O Peacock Blue
UC 900-650-O Powder Blue
OLD NAME
A9540-O Light Blue
A9545-O Peacock Blue
A9550-O Powder Blue
)
clipboard := testtext
StringReplace, clipboard, clipboard, OLD NAME, ¿
StringReplace, clipboard, clipboard, NEW NAME
StringSplit, text, clipboard, ¿, `r`n `t
StringSplit, old, text2, `n, `r
Loop, Parse, text1, `n, `r
{
Keywait, LCtrl, d
Keywait, LCtrl ; press and release left control to 'walk through' the data
SendRaw, %A_LoopField%
Send, {tab}
SendRaw, % old%A_Index%
}
return |
 _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
edu
Joined: 12 Oct 2006 Posts: 99 Location: Canada
|
Posted: Sat Jan 10, 2009 9:22 pm Post subject: |
|
|
Thank You, [VxE]! I never thought the stringsplit would do the job!
Edu _________________ The best things of life are free. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|