Jump to content

FFSearch always finding the string


Recommended Posts

Hello!

My problem is that this code below is always finding the String i input, no matter if its there or not.
Since i know that _FFSearch is returning "1" when the search is successful, i find putting it into an If-EndIf cycle useful.

I tried to modify a script i found on the AutoIT forum, it was nearly perfect for me, but that script didnt searched outside of a textbox, when i started typing into it.

 

#include <FF.au3>
#include <Misc.au3>

#comments-start
This script periodically checks a Firefox web page for a certain word or phrase.
#comments-end

; Enter text to watch for.
$lookfor = InputBox("Enter search text", "Enter search text")
; Exit if cancel button is pushed.
If @error = 1 Then Exit

;$rate = InputBox("Check how often?", "Enter rate in milliseconds at which to check. Entering 2000 will check every two seconds.", "2000")
$rate = 500
$counter = 0;

; Watch for desired text.
Do
; Pause for $rate milliseconds.
Sleep($rate)

if _FFSearch($lookfor) then
 MsgBox(4096, "'" & $lookfor & "' found.", "'" & $lookfor & "' found.")
 $counter = 1
endIf

Until  $counter = 1; Until desired text is found.


; Highlight desired text by searching for it using Find.
Send("^f")
Sleep(100)
Send($lookfor)
; Close Find dialog
Send("{ESC}")


Func End()
MsgBox(0, "Script ended", "` key pressed. Script ended")
Exit
EndFunc ;==>End

My question would be, how the _FFSearch is working? What would be the correct format, so that command would search properly in Mozilla?

For additional information, i can tell that i can use commands like opening new tab in Mozilla, closing a tab, etc. But this _FFSearch is an annoying thing i cannot make working.

Thank you for your help! If i made a beginner error, please forgive me, i tried so many approach to this _FFSearch command, i may missed something simple solution.

Link to comment
Share on other sites

It would help if you posted a link to FF.au3, so people didn't have to search the forum just to test your code.

Anyways..The values returned from _FFSearch look dodgy. Have you tried with $bSearchInFrames set to false?

;o) Cor

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

Ah yes, im sorry about that. I'll provide the link to the FF.au3 right now!

'?do=embed' frameborder='0' data-embedContent>>

Now that i modified the part:
 

if _FFSearch($lookfor) then
 MsgBox(4096, "'" & $lookfor & "' found.", "'" & $lookfor & "' found.")
 $counter = 1
endIf

To:

 

if _FFSearch($lookfor [, $bCaseSensitive = False [, $bBackwards = False [, $bWrapAround = True [, $bWholeWord = False [, $bSearchInFrames = False]]]]]) then
   MsgBox(4096, "'" & $lookfor & "' found.", "'" & $lookfor & "' found.")
   $counter = 1

  endIf

im having the error message:
Subscript used on non-accessible variable. Which i find weird, because that variables are created in FF.au3. Im clueless right now, since im using AutoIT for the third day by now. >_<

I tried to run the script with the default _FFSearch parameters, which i found in the FF.au3 documentation:

http://english.documentation.ff-au3.thorsten-willert.de/ff_functions/_FFSearch.php



 

Link to comment
Share on other sites

By the way, this..

$foo = SomeFunction($param [,$param2="foo" [,$param3="bar"]])

means that the first parameter is required, but the second and third are optional. You don't include the square brackets or the "=value" parts in the function call, they are simply to let you know what it and isn't optional, and what the default values (that you don't send) would be. e.g.

$foo = SomeFunction($variable)

or

$foo = SomeFunction($variable, $another_variable)

or

$foo = SomeFunction($variable, $another_variable, $and_another)

would all be fine. The $variables could be actual values, e.g.

$foo = SomeFunction("foo", "bar", 256)

These are fairly standard coding conventions which if you have no expreience of, might be slightly confusing.

;o) Cor

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

Thank you for your help Cor!

Im having no error messages right now, however the program doesnt want to find the String i enter, it just skips to the Else statement.

if $stringFound = 1 then
   MsgBox(4096, "'" & $lookfor & "' found.", "'" & $lookfor & "' found.")
   $counter = 1
  else
    MsgBox(4096, "'" & $lookfor & "'not found.", "'" & $lookfor & "' not found.")
endIf

I was curious if other functions from the FF.au3 are working or not, so i tried to enter a new command outside of the IF cycle:

$tabAdd = _FFTabAdd("www.google.com")
$tabAdd

Turns out, the script does not open a new tab in Mozilla, so there is something i missed, when i included the FF.au3.

Out of curiosity, i'd like to ask about this:

_FFSearch($sSearchString[, $bCaseSensitive = False[, $bBackwards = False[, $bWrapAround = True[, $bWholeWord = False[, $bSearchInFrames = True]]]]])

I see that there is five parameters inside of _FFSearch, so i tried this line in the script:

$stringFound = _FFSearch($lookfor, false, false, false, false, false)

This is giving me "Error: incorrect number of parameters in function call."

How come, that your line, which is:

$stringFound = _FFSearch($lookfor, false, false, false)

is working fine?
I tought that your command line is changing only the first three parameter, instead of all the five parameters in the _FFSearch function.
I'll try to make myself easy to understand, so this is what i imagined, what your line is doing :sweating:

_FFSearch($sSearchString[, $bCaseSensitive = False [, $bBackwards = False [, $bWrapAround = False]]])
Link to comment
Share on other sites

I didn't look at the documentation (which on looking now, looks wrong), but inside the UDF (FF.au3) the function has only four parameters..

Func _FFSearch($sSearchString, $bCaseSensitive = False, $bWholeWord = False, $bSearchInFrames = True)

I should add, I have no experience with this UDF!

;o) Cor

ps. you have the MozRepl add-on installed, right?

Edited by corz

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

You had a right guess then, but it worked, haha!

Yes, MozRepl is up and running. Yesterday i ran some example script for the FF.au3, and they worked fine, Firefox opened a new tab, closed one, started up, so everything went fine. I'll create a new script, just for testing if the FF.au3 functions are working today, or not.

EDIT:
Yup, even a test script is doing nothing, when i run it. I'll try to fix this myself, i have no idea how its not working today, but yesterday everything was fine >_<

EDIT2:
A simple computer restard, and the script is working, incorrectly tought, but its working... weird!

Edited by princze89
Link to comment
Share on other sites

I just cant figure out why _FFSearch cant find the string in a Firefox tab.

if _FFSearch($lookfor, False, False, False) then
   ;$lookfor is the string we are looking for
   MsgBox(0,"Found:", $lookfor)   

   ;if string hasnt been found, "Not found" message will appear
  elseIf _FFSearch($lookfor, False, False, False) = 0 then
    MsgBox(0,"Not found:", $lookfor)

endIf

Its jumping to elseIf right away. But if im using:

if _FFSearch($lookfor) then
   MsgBox(0,"Found:", $lookfor)

   ;if string hasnt been found, "Not found" message will appear
   elseIf _FFSearch($lookfor) = 01 then
    MsgBox(0,"Not found:", $lookfor)

endIf

FFSearch is always returning 1, it finds the string no matter what i type in.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...