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 

copy webpage into notepad
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
newb
Guest





PostPosted: Tue Oct 27, 2009 5:24 am    Post subject: copy webpage into notepad Reply with quote

it's supposed to be simple but i want it to be error proof.

what i want to do is copy an entire webpage and paste it into notepad and repeat.

i have:
Code:
^`::
Send {Ctrl Down}a
Sleep 30
Send {Ctrl Up}
Sleep 30
Send {Ctrl Down}c
Sleep 30
Send {Ctrl Up}
Sleep 30
Send {Alt Down}{Tab}
Sleep 30
Send {Alt Up}
Sleep 30
Send {Down 2}
Sleep 30
Send {Ctrl Down}v
Sleep 30
Send {Ctrl Up}
Sleep 30
Send {Alt Down}{Tab}
Sleep 30
Send {Alt Up}
Sleep 30
Send {Ctrl Down}{Tab}
Sleep 30
Send {Ctrl Up}


however, ive noticed a couple of errors. sometimes it doesn't copy/paste the right thing. it fails to copy the new page. the end result is a duplicate. how to do fix this to ensure there are no duplicates or missing pages?

thank you in advance.

[Title edited. Please write descriptive titles for your topics. ~jaco0646]
Back to top
Guest






PostPosted: Tue Oct 27, 2009 5:38 am    Post subject: Reply with quote

the {Alt Down}{Tab} switches too fast?
either sleep increase value
or WinWaitActive

or just use append after copy
Back to top
poo_noo



Joined: 08 Dec 2006
Posts: 248
Location: Sydney Australia

PostPosted: Tue Oct 27, 2009 6:26 am    Post subject: Reply with quote

why not use the 'view source' option to get the code and then copy from there.

Code:
#persistent
space::
WinGetTitle, myTitle, A
If myTitle contains Internet Explorer, Firefox
   Send,{APPSKEY}v ; send a rightclick and select the view source option (starts with the letter v)
If myTitle contains Opera   
   Send,{APPSKEY}u ; send a rightclick and select the view source option (starts with the letter u)

The above is a hotkey that is started by pressing the spacebar. It should at least get you started.
_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
wooly_sammoth



Joined: 12 May 2009
Posts: 634
Location: Gloucester UK

PostPosted: Tue Oct 27, 2009 12:15 pm    Post subject: Reply with quote

What about using UrlDownloadToFile?

Code:
UrlDownLoadToFile, [insert name of url here], File.txt


(you don't need the square brackets when you change the url name)

This will scan the url you set and download all the content to File.txt.

It will have all the HTML tags in it but there are many ways of getting rid of that using RegEx. Just have a search on the forum for HTML and RegEx

It has the benefit that it doesn't need to open a browser so will be much quicker and more reliable as it doesn't go bad if the webpage layout changes
Back to top
View user's profile Send private message Visit poster's website
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Tue Oct 27, 2009 12:23 pm    Post subject: Reply with quote

- Use WinActivate instead of the alt-tab, will be more reliable
- clear the clipboard between copy/paste
- use clipwait to wait for the clipboard to have contents before you proceed with pasting in notepad

Alternatively, use ControlSend to paste so you don't have to switch to the notepad window at all, search the forum for controlsend notepad and you will find various scripts.
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Oct 27, 2009 12:40 pm    Post subject: Reply with quote

wooly_sammoth wrote:
What about using UrlDownloadToFile?

Code:
UrlDownLoadToFile, [insert name of url here], File.txt


(you don't need the square brackets when you change the url name)

This will scan the url you set and download all the content to File.txt.

It will have all the HTML tags in it but there are many ways of getting rid of that using RegEx. Just have a search on the forum for HTML and RegEx

It has the benefit that it doesn't need to open a browser so will be much quicker and more reliable as it doesn't go bad if the webpage layout changes

darn. i was really hoping this was what i was looking for. it wasnt what i was looking for but it should be handy for the future. thanks.
Back to top
Guest






PostPosted: Tue Oct 27, 2009 2:04 pm    Post subject: Reply with quote

HugoV wrote:
- Use WinActivate instead of the alt-tab, will be more reliable
- clear the clipboard between copy/paste
- use clipwait to wait for the clipboard to have contents before you proceed with pasting in notepad

Alternatively, use ControlSend to paste so you don't have to switch to the notepad window at all, search the forum for controlsend notepad and you will find various scripts.

thank you. this has been very helpful.
on another note, how do i type ^p? it is for word. i want to do a text replace of http to ^phttp (adding a row in between each link. thanks:D
Back to top
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Tue Oct 27, 2009 2:12 pm    Post subject: Reply with quote

You can use stringreplace. ^p in Word is newline, in ahk it is `r`n or simply `n see the examples on the stringreplace doc. Note it is ` (backtic) not a '

Edit: you can use the clipboard in stringreplace, so you can modify the clipboard contents with stringreplace BEFORE you paste the text in another program
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
newb
Guest





PostPosted: Tue Oct 27, 2009 2:23 pm    Post subject: Reply with quote

HugoV wrote:
You can use stringreplace. ^p in Word is newline, in ahk it is `r`n or simply `n see the examples on the stringreplace doc. Note it is ` (backtic) not a '

Edit: you can use the clipboard in stringreplace, so you can modify the clipboard contents with stringreplace BEFORE you paste the text in another program
ok nevermind i figured it out. i was looking for {^}p

i also want ` to be replaced but i tried both ` and {`} and neither worked.

Code:
 Send {`}
Sleep 30
 Send {Tab}
Sleep 30
 Send {Delete}
Sleep 30
 Send {Alt Down}a
Sleep 30
 Send {Alt Up}
Sleep 30
 Send {Space}


here i am trying to delete all `.
Back to top
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Tue Oct 27, 2009 2:59 pm    Post subject: Reply with quote

If you are going to just delete the backticks you would do this:

Code:
StringReplace, URLvar, URLvar, ``, , All
; or StringReplace, URLvar, URLvar, % Chr(96), , All

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
newb
Guest





PostPosted: Wed Oct 28, 2009 10:21 pm    Post subject: Reply with quote

sinkfaze wrote:
If you are going to just delete the backticks you would do this:

Code:
StringReplace, URLvar, URLvar, ``, , All
; or StringReplace, URLvar, URLvar, % Chr(96), , All

all i want to do here is to have the key type in ` and nothing into the two boxes in word's text replace.
Code:
`::
 Send {Ctrl Down}h
Sleep 30
 Send {Ctrl Up}
Sleep 30
 Send {`}
Sleep 30
 Send {Tab}
Sleep 30
 Send {Delete}
Sleep 30
 Send {Alt Down}a
Sleep 30
 Send {Alt Up}
Sleep 30
 Send {Space}
 Send http
[b]etc[/b]
Back to top
newb
Guest





PostPosted: Wed Oct 28, 2009 10:22 pm    Post subject: Reply with quote

newb wrote:
sinkfaze wrote:
If you are going to just delete the backticks you would do this:

Code:
StringReplace, URLvar, URLvar, ``, , All
; or StringReplace, URLvar, URLvar, % Chr(96), , All

all i want to do here is to have the key type in ` and nothing into the two boxes in word's text replace.
Code:
`::
 Send {Ctrl Down}h
Sleep 30
 Send {Ctrl Up}
Sleep 30
 Send {`}
Sleep 30
 Send {Tab}
Sleep 30
 Send {Delete}
Sleep 30
 Send {Alt Down}a
Sleep 30
 Send {Alt Up}
Sleep 30
 Send {Space}
 Send http
[b]etc[/b]

oh i think i know what happened lol. ` appears as the initiator key and within the code as a send.
Back to top
newb
Guest





PostPosted: Wed Oct 28, 2009 10:39 pm    Post subject: Reply with quote

still cant get the ` to get replaced by nothing in the word box for some reason.
Back to top
newb
Guest





PostPosted: Fri Oct 30, 2009 11:35 pm    Post subject: Reply with quote

newb wrote:
still cant get the ` to get replaced by nothing in the word box for some reason.
bump
Back to top
Guest






PostPosted: Fri Oct 30, 2009 11:44 pm    Post subject: Reply with quote

with sinkfaze's solution, it suppose to work
show us a not working situation in the following format:
Code:

text = abc`123
msgbox, % text
text = abc``123
msgbox, % text
StringReplace, text, text, ``, , All
msgbox, % text
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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