Sign in to follow this  
Followers 0
kosu

How to look for a string in a browser and fire a function when found?

8 posts in this topic

Hey guys! New to the forums but not to Autoit. For an internal system at my company, I need to fire an Autoit function when a given text is shown in a browser to the user. The thing is I need this to work with IE, Firefox and Chrome. I have NO idea how to start! How can I look for a string in the browser? The only idea I have is OCR, which is ridicoulous, you can't take a screenshot and OCR it every 2 seconds... So, monitor the cache??? Or is there anyway to interact with all 3 (maybe in different ways, if you can offer an idea for one, GREATLY appreciated)? Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the Forums here. I have re-written and shrunk down a bit of code that I use regularly. This bit of code only requires that IE be installed on the machine it is run on. Change the variable $Find from peace, as it is now, to hate to see the difference. Good luck with you project. :)

#include <INet.au3>

Local $URL = "http://somdcomputerguy.com", $Source, $Result, $Find = "peace"

$Source = _INetGetSource($URL)
$Result  = StringInStr($Source, $Find)
If $Result <> 0 Then
    MsgBox(0, "", "Yay!")
Else
    MsgBox(0, "", "No " & $Find & " at " & $URL)
EndIf
I am very poor at commenting my code, so refer to the Help file for any function or code logic descriptions. Edited by somdcomputerguy
1 person likes this

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Hi man!

Thanks for your response.

The thing is that, more than monitoring the content of a site, what I need to operate with this old web interface propietary software, is to interact with the content displayed to the user in his or her own browser, do you get the difference?

So, the user browses using Firefox, Chrome or IE to www.random.com, when the user sees "blahblahblah" as text, THEN I need to fire up the function, not when the site itself has it.

Share this post


Link to post
Share on other sites

Oh, I get it. When a user, using whatever browser they use, goes to a site and sees themselves some particular text, some action will then be performed. That does make things more difficult though. There is a set of functions for Internet Explorer built into AutoIt, and there are individual UDF's available on this forum for Firefox, Chrome, and Opera. I'm not too sure about the last two.. In the Example Scripts forum, there is also a UDF for generic (not browser related) HTTP functions. This is probably what will do it for you. I just quickly searched thru that forum, and I believe this is it - WinHTTP functions - '?do=embed' frameborder='0' data-embedContent>>

Again, good luck with your project. :)


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You know, that looks much better than my suggestion. Thanks JohnOne. :)

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Guys, if anyone is able to help, I'm able to pay you for the assistance, we could set up an arrangement via Elance or a similar site.

The link posted by John seems like it would do the trick, but it's a bit advanced for me and I need this set up soon.

Let me know.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The thing is that, more than monitoring the content of a site, what I need to operate with this old web interface propietary software, is to interact with the content displayed to the user in his or her own browser, do you get the difference?

 

So, the user browses using Firefox, Chrome or IE to www.random.com, when the user sees "blahblahblah" as text, THEN I need to fire up the function, not when the site itself has it.

 

Guys, if anyone is able to help, I'm able to pay you for the assistance, we could set up an arrangement via Elance or a similar site.

The link posted by John seems like it would do the trick, but it's a bit advanced for me and I need this set up soon.

 

This sounding more and more like a 'CAPCTHA breaking' sort of script that you want.. Perhaps if you could better describe what you want, you could get better help.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0