| View previous topic :: View next topic |
| Author |
Message |
controlsman
Joined: 23 Sep 2004 Posts: 8
|
Posted: Fri Sep 24, 2004 3:05 pm Post subject: Newbie question |
|
|
Hello,
I'm new to AutoHotKey. Can anyone help me with this?
If I copied a webpage into the clipboard, and wanted to remove the first 2 lines of text, and it could be random text, what would be the best way to delete lines of text out of the clipboard?
Thx |
|
| Back to top |
|
 |
David
Joined: 08 Aug 2004 Posts: 25 Location: Lubbock, Texas
|
Posted: Fri Sep 24, 2004 3:33 pm Post subject: |
|
|
Maybe something like this (in pseudo-AHK code)?
1. Open Notepad
2. Paste (Ctrl-V)
3. Go to top (Ctrl-Home)
4. Shift-Down-Down (to select the first two lines)
5. Del
6. Select all (Ctrl-A)
7. Copy (Ctrl-C)
8. Close Notepad without saving (Alt-F, X, N) |
|
| Back to top |
|
 |
controlsman
Joined: 23 Sep 2004 Posts: 8
|
Posted: Fri Sep 24, 2004 3:46 pm Post subject: |
|
|
| David wrote: | Maybe something like this (in pseudo-AHK code)?
1. Open Notepad
2. Paste (Ctrl-V)
3. Go to top (Ctrl-Home)
4. Shift-Down-Down (to select the first two lines)
5. Del
6. Select all (Ctrl-A)
7. Copy (Ctrl-C)
8. Close Notepad without saving (Alt-F, X, N) |
Yeah, I can do it in notepad, but I didn't want to open another app. Thx anyways:) |
|
| Back to top |
|
 |
David
Joined: 08 Aug 2004 Posts: 25 Location: Lubbock, Texas
|
Posted: Fri Sep 24, 2004 4:14 pm Post subject: |
|
|
| Want elegance, huh? :) I'd take a look at Loop, parse, clipboard. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Fri Sep 24, 2004 5:20 pm Post subject: |
|
|
Here's a possible starting point: | Code: | temp = ; We'll store the modified text in this var.
Loop, parse, clipboard, `n, `r
{
if a_index > 2
temp = %temp%%A_LoopField%`r`n
}
clipboard = %temp% ; Save the modified contents. |
|
|
| Back to top |
|
 |
controlsman
Joined: 23 Sep 2004 Posts: 8
|
Posted: Wed Oct 06, 2004 1:18 pm Post subject: |
|
|
Thx Chris,
Worked good )
One more question:
How can I seach for a text(string) in the clipboard, then enter that whole line in a var? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Wed Oct 06, 2004 6:32 pm Post subject: |
|
|
| Quote: | | How can I seach for a text(string) in the clipboard, then enter that whole line in a var? | The following example parses (breaks down) the clipboard into individual lines. If a line is discovered which contains the desired string, that line is assigned to a variable: | Code: | MyVar = ; Init to blank to detect failure to find a match.
Loop, parse, clipboard, `n, `r ; Divide by `n (linefeed). Ignore `r (carriage return)
{
IfInString, A_LoopField, the string to search for
{
MyVar = %A_LoopField%
break
}
} |
|
|
| Back to top |
|
 |
controlsman
Joined: 23 Sep 2004 Posts: 8
|
Posted: Sun Oct 10, 2004 3:11 pm Post subject: |
|
|
Thx Chris,
Works great! |
|
| Back to top |
|
 |
|