| View previous topic :: View next topic |
| Author |
Message |
jak
Joined: 28 Feb 2006 Posts: 102
|
Posted: Tue Dec 18, 2007 11:11 pm Post subject: automatically select "next" on a webpage |
|
|
If you're looking at a webpage (for example, google search results), usually at the bottom of the screen there is a link called "next" that takes you to the next webpage in a series.
Usually you can "tab" your way down there using the keyboard. (I mean technically it is possible).
Is there a way to have AHK, via a hotkey, automatically find and select a link called "next" if it appears on the webpage?
Is that possible with an AHK script?
I searched a bit in the forums and didnt find anything on this question.
thanks. |
|
| Back to top |
|
 |
BoBo¨ Guest
|
Posted: Tue Dec 18, 2007 11:25 pm Post subject: |
|
|
| Code: | !y::
URLDowloadToFile, http://www.mySite.html, mySite.txt
RegExMatch(... ; check for "<href="...>next<"
If ErrorLevel = 0
Run, <the extracted link>
Return | Brainfart, means no working code + you'd think about to handle multiple apearences of >next< ... |
|
| Back to top |
|
 |
jak
Joined: 28 Feb 2006 Posts: 102
|
Posted: Tue Dec 18, 2007 11:37 pm Post subject: |
|
|
thanks, i'll try that out. Regarding multiple appearances of 'next', maybe the script can find the 'next occurence of next' everytime the hotkey is pressed... (kind of a 'find again')
In your example above, would ahk be able to just use the 'cached copy' of the webpage (rather than re-downloading it)? That might be faster.
Last edited by jak on Tue Dec 18, 2007 11:48 pm; edited 1 time in total |
|
| Back to top |
|
 |
jak
Joined: 28 Feb 2006 Posts: 102
|
Posted: Tue Dec 18, 2007 11:40 pm Post subject: |
|
|
I suppose I could also just make a script that does "control-f" and then types in "next" and hits enter. I guess I was wondering if there was some more automated/faster way to do it.
For instance, when you hit the 'tab' key on a webpage in the browser, how does 'tab' know to jump ONLY FROM LINK TO LINK? Can that be reproduced in AHK (and made to search on the word "next"?)? |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 511 Location: 127.0.0.1
|
Posted: Tue Dec 18, 2007 11:53 pm Post subject: |
|
|
hi there - just for my interest - how would you handle the search term 'next' used in your script, since the webpage will be full of that, when i search for NEXT.
i mean there is no point in activating the search function, somehow make the browser accept whatever the search resulted and activate the link - probably via {enter} or space - but since i am searching for next this solution will be kinda useless.
same thing when my search results contain next, when i search for whatever
just findeing the occurence of next and make it activate the button just wont do the job, unless
a) the script will be for no public use
b) u 'forbid' searches for words like next
c) simply hope that no search result contains the word next in its summary
anyways - imho this sorta attempt wont work
greets
derRaphael _________________
|
|
| Back to top |
|
 |
jak
Joined: 28 Feb 2006 Posts: 102
|
Posted: Wed Dec 19, 2007 12:46 am Post subject: |
|
|
hi raphael - the script wont 'automatically activate' the link that has the words 'next'. Rather, it will merely 'highlight' it (the same way that hitting the TAB key will highlight the following link on a webpage).
So that way the script can be reinvoked many times till the correct "next" appears. I dont think it would need to be activated too many times on a given webpage. Also alternately, I might want to search for "Next >" since most links have the ">" on them.
But my point is that the script will only highlight the link, not activate it. Therefore, when it has landed on the correct "Next", then I can just hit enter to activate the link. |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 511 Location: 127.0.0.1
|
Posted: Wed Dec 19, 2007 1:05 am Post subject: |
|
|
sorry - just double resent my post while i was actually editing the url _________________
Last edited by DerRaphael on Wed Dec 19, 2007 1:12 am; edited 2 times in total |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 511 Location: 127.0.0.1
|
Posted: Wed Dec 19, 2007 1:05 am Post subject: |
|
|
personally, i think it'd be wiser to grab the url from locationbar, since there its noticed which part of query results you're actually watching
for google its like following:
http://www.google.de/search?q=QUERY&hl=de&start=10&sa=N
the 10 as value for start indicates from where to display
the above is the link for page two from page one
to access page three you'd simply use start=20
other pages - even this phpBB page uses similar techniques
accessing the locationbar is not that difficult _________________
|
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1234
|
Posted: Wed Dec 19, 2007 1:34 am Post subject: |
|
|
| Code: | RWin up::
SetTitleMatchMode, 2
IfWinNotActive, Google ; only tested on Google
return
oclip := clipboardall
Send !d^x
definc = 10
IfWinActive, Google Image Search
definc := 18
snumber := flag := NewURL := ""
StringSplit, NewURL, clipboard, &
loop % NewURL0
If InStr( ( "NewURL" . ( 1 + NewURL0 - a_index ) ), "ndsp=" )
StringTrimLeft, definc, NewURL%a_index%, 5
loop % NewURL0
{
IfinString, NewURL%a_index%, start=
{
StringTrimLeft, snumber, NewURL%a_index%, 6
StringLeft, NewURL%a_index%, NewURL%a_index%, 6
NewURL%a_index% .= ( snumber + definc ? snumber + definc : definc )
flag = ok
}
NewURL .= NewURL%a_index% . "&"
;NewURL%a_Index% := ""
}
StringTrimRight, NewURL, NewURL, 1
If flag =
NewURL .= "&ndsp=" . definc . "&start=" . definc
clipboard := NewURL
Send ^v{enter}
clipboard := oclip
return |
Tested in Firefox using Google Search. Give it a spin, it really makes browsing images a breeze. Thx for the idea, jak. _________________ My Home Thread [New: Vector Function Library]
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 511 Location: 127.0.0.1
|
Posted: Wed Dec 19, 2007 1:38 am Post subject: |
|
|
thats a nice one [VxE] _________________
|
|
| Back to top |
|
 |
jak
Joined: 28 Feb 2006 Posts: 102
|
Posted: Wed Dec 19, 2007 1:55 am Post subject: |
|
|
| Quote: | | Tested in Firefox using Google Search. Give it a spin, it really makes browsing images a breeze. Thx for the idea, jak. |
sure thing, I've wanted to do this in AHK for a while and I was surprised that no one seems to have tried it yet. (after all, we have pageup/pagedown for regular documents, wont it make sense to have a single key on websites to go to the next page in a series? Whether thats a news article, a blog, a search page, or images?)
VXE - any ideas on how to make this more generic? It seems to me depending on the URL in this way ties us to particular sites (and particular ways they implement a series of pages). Thats why i was thinking if we could use AHK to "highlight" the "next" link (the same way the tab key does), then all we have to do is hit 'enter' at that point to go there.
I realize there will always be some limitations, but the "Next" link seems quite universal. |
|
| Back to top |
|
 |
epconfig
Joined: 10 Oct 2007 Posts: 19 Location: Montreal, Canada
|
Posted: Wed Feb 27, 2008 5:23 pm Post subject: |
|
|
The “next” label you are looking to automatically go to the next-results page with Google search engine is the last one on the search engine page (except if your search includes the keyword “next”). So, instead of using {tab} to travel down to the last “next”, why not use ^{end} to go at the bottom of the page and search backwards. You should find the label “next” at the first try. This is what I am successfully doing with Google, Yahoo and Live.
Here is my code for Yahoo and Live:
| Code: | SetKeyDelay 100
send ^{end}
send ^f
sleep 250
sendinput next
send !p
send {esc}
send {tab}
send {enter}
SetKeyDelay 10 |
Here is my code for Google:
| Code: | SetKeyDelay 100
send ^{end}
send ^f
sleep 250
sendinput next
send !p
send {esc}
send {tab}
send +{tab}
send {enter}
SetKeyDelay 10 |
You may have to adjust the delays.
May 2008 update: Google changed something with their search engine page. So I wrote two versions of the code: one for Yahoo/Live and the other for Google. _________________ epconfig
Enterpad Keyboard for AutoHotkey |
|
| Back to top |
|
 |
|