AutoHotkey Community

It is currently May 27th, 2012, 10:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: December 18th, 2007, 11:11 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2007, 11:25 pm 
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< ...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2007, 11:37 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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 December 18th, 2007, 11:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2007, 11:40 pm 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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"?)?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2007, 11:53 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
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

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 12:46 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 1:05 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
sorry - just double resent my post while i was actually editing the url

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Last edited by derRaphael on December 19th, 2007, 1:12 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 1:05 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
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

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 1:34 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 1:38 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
thats a nice one [VxE]

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2007, 1:55 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 5:23 pm 
Offline

Joined: October 10th, 2007, 7:43 pm
Posts: 29
Location: Montreal, Canada
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, specter333 and 73 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