AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie question

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
controlsman



Joined: 23 Sep 2004
Posts: 8

PostPosted: Fri Sep 24, 2004 3:05 pm    Post subject: Newbie question Reply with quote

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
View user's profile Send private message Send e-mail
David



Joined: 08 Aug 2004
Posts: 25
Location: Lubbock, Texas

PostPosted: Fri Sep 24, 2004 3:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
controlsman



Joined: 23 Sep 2004
Posts: 8

PostPosted: Fri Sep 24, 2004 3:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
David



Joined: 08 Aug 2004
Posts: 25
Location: Lubbock, Texas

PostPosted: Fri Sep 24, 2004 4:14 pm    Post subject: Reply with quote

Want elegance, huh? :) I'd take a look at Loop, parse, clipboard.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri Sep 24, 2004 5:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
controlsman



Joined: 23 Sep 2004
Posts: 8

PostPosted: Wed Oct 06, 2004 1:18 pm    Post subject: Reply with quote

Thx Chris,

Worked good Smile)

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
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Oct 06, 2004 6:32 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
controlsman



Joined: 23 Sep 2004
Posts: 8

PostPosted: Sun Oct 10, 2004 3:11 pm    Post subject: Reply with quote

Thx Chris,

Works great!
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group