AutoHotkey Community

It is currently May 26th, 2012, 2:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Find Text And Click It
PostPosted: December 17th, 2007, 1:18 pm 
I want that my script would find Text wich is a link and left click on it.

,Skulltower


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2007, 1:20 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
you should find some informations here:

http://www.autohotkey.com/forum/viewtopic.php?t=26654

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2007, 1:26 pm 
Come on... I've been searching this forum for an hour and i couldn't find it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2007, 6:43 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
search for javascript and bookmarklets.

It's not esay to work with webpages and links.

To get help, you must provide us with enough info to help you.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2008, 6:48 am 
Offline

Joined: October 15th, 2007, 2:02 am
Posts: 9
i have the same problem
its just a webpage, i need to find in the text if have the word example eat
that is always a text and link
but sometimes it doesn´t apear
If find I just need the postion, and i do some math and find the right spot to click

I just don´t know how to find the position of the string i´m looking for.

A example

You want click in profile, so you find for FAQ if you find the word faq, you get the position do some math and make your mouse click in profile.


i hope i give the enough information
tks very much


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2008, 7:10 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
is the link you're talking about hardcoded or done via javascript ...

when you look at the source of the page (that readable text with all these pointy brackets <> stuff in it) is your 'eat' link surrounded by something like <a href="somelinkwhateveraction">eat</a> or is it more like
<a href="javascript:void(0)">eat</a> or something completly different?

also which browser are you using?

are you aware, that font sizes can change at a webpage so calculating techniques will fail unless you determine the exact pixel size of the letters?
you could do some pixel search, but this one 'll also fail from previous reasons.

can you use the page without login?
does this page work without cookies (small lil text bitsnpieces storing some information like username, fave color last visit etc) using?
does this page work when NOT using javascript?

if you could answer last three questions with yes, there is a chance doing it more or less easy with ahk ... than more NOs than complicated it'd become

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: January 10th, 2008, 5:48 pm 
Offline

Joined: October 15th, 2007, 2:02 am
Posts: 9
its a link like this
www.site.com/adventure.asp?eat=yes

the code is
P><a href="adventure.asp?eat=yes">Eat the berry »</A><BR><FONT COLOR=Red>
with the position i will calculate the icon i need to click

i´m using explorer, but i can use this site with opera or firefox, i´m using explorer because to me is easier to make ahk work better in explorer, tabs make more harder

I need login in the page, but there is a picture there is always the same and dont change, I can try to find the picutre and then click in the picture if is easyer.

I will also need find if the page has the right word, check if has eat, because some times the page dont have the word eat.


I know that this code I´m doing only will work for me, because the pixel calculations


My script so far, can click in the link(fix) every 5 seconds, but he cant find if have eat and find the position.

The all idea is
every 5 seconds click in the fix link(done), see if have the word eat and see the position( the help I need), if have calculate the new position(i know do), click in another link( i know)
and do this 5 times( I can learn). ( click in the link near eat 5 times and stopped)
thanks very much

edit
I find the image, and its missing find the right word in all text in the page

Code:
  ImageSearch, FoundX, FoundY, 180, 386, 358,

500, C:\tobackpackdown.gif


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2008, 10:35 pm 
Offline

Joined: April 18th, 2007, 9:03 am
Posts: 127
is this what you wonted?

this is ment for firefox
becouse when you search ther will become a green color around the writen text what this script dose is serching for every 0,5 sec and move mouse to that point

and the hotkey to click is the "f7" button

Code:
loop,
{
sleep, 500
PixelSearch, Px, Py, 0, 0, 1000, 1000, 0x78d838, 3, Fast
MouseMove, %Px%, %Py%
}
f7::mouseclick ;; change the hotkey witch click on the link


if the color dosent display green you might chage the "0x78d838"

_________________
you'll have to excuse me...I'm from Sweden, so my English is not that good...(but now it's better cuz JSLover/Guest is helping me)...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2008, 11:02 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
actually i asked, cuz my approach would be different, but more robust also not relying on pixelsearch or statustext or things like that.

you'd simply use some utility like wget to load that page and pass login credentials, either save the page (which if fairly easy) or redirect from standard output to skript, parse there for the passage surrounding the link (examples of how doing this, are enough in forum; tipp: use regex) and extract the link

when having the link just use run command to open in browser

this is how I'd solve this

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: January 11th, 2008, 12:43 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
i dunno im afraid if i couldnt figure out how to search for htmldom on a forum i might give up
give it another try?
nah... just give up

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2008, 2:30 am 
Offline

Joined: October 15th, 2007, 2:02 am
Posts: 9
i do this
a image search
ImageSearch, FoundX, FoundY, 180, 386, 358, 500, C:\tobackpackdown.gif

a clipboard copy with ctrl+c

StringGetPos, pos, clipboard, %Var1%
if pos > 1
with the string get pos, i know if the word i want is in the page
if is not, go the next page

if is in the page
click in the image (C:\tobackpackdown.gif)
open your bag and put the object there( tab tab tab tab...)

and a counter to get out after few trys or full bag


DerRaphael helped me a lot, you give me the ideas for the solution
find the link and use run command didn´t work I try this way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2008, 2:37 am 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
try finding out, if

a) site still works when all scripting is off by default
b) site still works when cookies are off by default and no previously saved cookies available

(best done with mozilla firefox, easy to change settings there and restore those)

when your site still works though no cookies and no scripting active, the wget solution is easy.

in case you need to find the link, in downloaded html just feel free to ask
when the html form says action=post instead of action=get you will need to change one or two params for wget to get back the page source as you'd have logged in.

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: February 18th, 2008, 6:57 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
same link each time use curl
or you can try something like this
http://www.autohotkey.com/forum/viewtop ... highlight=
little creative ok not so creative use of document.links collection
Code:
JS_to_Inject=
(
var x=document.links;
for (var i=0;i<x.length;i++)
  {
str = x[i].innerHTML;
if (str.match("eat")=="eat")
{
  x[i].click();
  break;

}
  }

)
loop, 5
{
IE_InjectJS(WinExist(A), JS_to_Inject)
sleep,2000
}

the above is just a really basic example and untested because your site you posted doesnt work
it would search each link on the active browser window find the first link with display text containing the word eat in lower case (modify the code as you see fit for case and words)
and click it when it is found
Note this is preatty basic example so it would also click "wheat" if found also
if this doesnt work its likely the javascript that i didnt test some sort of simple syntax error

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Exabot [Bot] and 12 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