Search for text in a window

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
silversliver
Newbie
Posts: 1
Joined: Sun Jun 22, 2008 12:04 pm

Search for text in a window

Post by silversliver » Sun Jun 22, 2008 12:11 pm

Hello, I need a very simple thing, that I actually find extremely difficult using macro scheduler. I need to search for a word in a window (actually in this case in a web page, and it's a link) and make the macro do 2 different things: if it finds the word in the page, goto a label, if it doesnt find it, goto another label.

I tried using find window with text and if result= NOT FOUND then goto a label else goto another. But it looks like it doesnt see the link in any case as the result is always NOT FOUND.

Please help

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Jun 22, 2008 11:31 pm

How about showing us the code you are using......we will then have an idea of how you are making this happen.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

dafe
Junior Coder
Posts: 23
Joined: Sun Apr 06, 2008 4:21 am

Post by dafe » Thu Jun 26, 2008 9:54 am

have you tried just using getwindowtext> to dump the entire contents of your window to a variable? You can then use position> to choose your branch.
ie.

getwindowtext>[windowname],var1
position>[texttofind],%var1%,1,startpos
if>%startpos%>0
do something
else
do something else
endif

I assume this method could be entirely unsuitable however, depending on what site you are dealing with and what you are trying to do, so the above post is probably far better advice :p
--

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jun 26, 2008 12:58 pm

If its a web page, why not use HTTPRequest>?

For example this will find or not find teh text assigned to variable "TextToFind". And branch to different lables depending on whether the text is found or not found.

[code]
Let>TextToFind=SilverSliver
HTTPRequest>http://www.mjtnet.com/forum/viewtopic.p ... ,,GET,,web
Separate>web,%TextToFind%,var
If>var_count>1,Found,NotFound
Goto>EOF

Label>Found
MDL>Found %TextToFind%
Goto>EOF

Label>NotFound
MDL>Did not find %TextToFind%
Goto>EOF

Label>EOF
[/code]

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts