AutoHotkey Community

It is currently May 26th, 2012, 10:56 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: October 27th, 2009, 6:24 am 
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]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 6:38 am 
the {Alt Down}{Tab} switches too fast?
either sleep increase value
or WinWaitActive

or just use append after copy


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 7:26 am 
Offline

Joined: December 8th, 2006, 5:17 am
Posts: 248
Location: Sydney Australia
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 1:15 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 1:23 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
- 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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 1:40 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 3:04 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 3:12 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 3:23 pm 
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 `.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 3:59 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 11:21 pm 
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]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 11:22 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 28th, 2009, 11:39 pm 
still cant get the ` to get replaced by nothing in the word box for some reason.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2009, 12:35 am 
newb wrote:
still cant get the ` to get replaced by nothing in the word box for some reason.
bump


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2009, 12:44 am 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, JSLover, Kirtman, Leef_me, Maestr0, Miguel, XstatyK and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group