Alert/sound notification when element found

Discussions and Tech Support specific to the iMacros Firefox Add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
dyneck
Posts: 7
Joined: Sun Mar 13, 2016 4:51 pm

Alert/sound notification when element found

Post by dyneck » Sun Mar 13, 2016 5:07 pm

VERSION BUILD=8961227
WIndows XP
Firefox 40.0.1

Hi,
I need to write a script which will constantly refresh website and notify me somehow (sound would be the best) if desired element appear on the page.

On basis what I have found in the google I have written something like this

Code: Select all

var macro;

macro = "CODE:";
macro+= "URL GOTO=http://www.facebook.com"+"\n";
macro+= "TAG POS=1 TYPE=BUTTON FORM=ID:reg ATTR=ID:u_0_j CONTENT=EVENT:FAIL_IF_FOUND"+"\n";
macro+= "WAIT SECONDS=9"+"\n";

try
{
iimPlay(macro);
}
catch(err)
{
var sound;
sound ="CODE:URL GOTO=file://C:\\\wolves.wav"+"\n";
iimPlay(sound);

alert("Error!!!");
}
but it doesn't work :/

I was trying using this: http://wiki.imacros.net/FAQ?ref=driverl ... a_sound.3F
and this: http://stackoverflow.com/questions/2312 ... acro-error
hints
Last edited by dyneck on Sun Mar 20, 2016 11:34 am, edited 1 time in total.
chivracq
Posts: 8997
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Alert/sound notification when element found

Post by chivracq » Sun Mar 13, 2016 5:34 pm

dyneck wrote:Hi,
I need to write a script which will constantly refresh website and notify me somehow (sound would be the best) if desired element appear on the page.

On basis what I have found in the google I have written something like this

Code: Select all

var macro;

macro = "CODE:";
macro+= "URL GOTO=http://www.facebook.com"+"\n";
macro+= "TAG POS=1 TYPE=BUTTON FORM=ID:reg ATTR=ID:u_0_j CONTENT=EVENT:FAIL_IF_FOUND"+"\n";
macro+= "WAIT SECONDS=9"+"\n";

try
{
iimPlay(macro);
}
catch(err)
{
var sound;
sound ="CODE:URL GOTO=file://C:\\\wolves.wav"+"\n";
iimPlay(sound);

alert("Error!!!");
}
but it doesn't work :/

I was trying using this: http://wiki.imacros.net/FAQ?ref=driverl ... a_sound.3F
and this: http://stackoverflow.com/questions/2312 ... acro-error
hints
CIM...! :mrgreen:

FCI missing, I normally don't read nor answer..., I only read your Thread Title, not checking the Threads/Links you refer to but I have already answered this Qt several times with Examples, search my Posts on "Conditional Sound"...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
dyneck
Posts: 7
Joined: Sun Mar 13, 2016 4:51 pm

Re: Alert/sound notification when element found

Post by dyneck » Sun Mar 20, 2016 11:38 am

I have found your advices but I did it with using javascript.
Here is my solution:
var macro;

macro = "CODE:";
macro+= "URL GOTO=http://www.facebook.com"+"\n";
macro+= "TAG POS=1 TYPE=BUTTON FORM=ID:reg ATTR=ID:u_0_j"+"\n";
macro+= "WAIT SECONDS=3"+"\n";

iimPlay(macro);
var err = iimGetErrorText();

if(err == "OK"){
var sound;
sound ="CODE:URL GOTO=file://C:\\\wolves.wav"+"\n";
iimPlay(sound);
break;
}
else{
//window.alert("FAIL "+err);
}
chivracq
Posts: 8997
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Alert/sound notification when element found

Post by chivracq » Sun Mar 20, 2016 12:14 pm

dyneck wrote:I have found your advices but I did it with using javascript.
Here is my solution:

Code: Select all

var macro;

macro = "CODE:";
macro+= "URL GOTO=http://www.facebook.com"+"\n";
macro+= "TAG POS=1 TYPE=BUTTON FORM=ID:reg ATTR=ID:u_0_j"+"\n";
macro+= "WAIT SECONDS=3"+"\n";

iimPlay(macro);
var err = iimGetErrorText();

if(err == "OK"){
var sound;
sound ="CODE:URL GOTO=file://C:\\\wolves.wav"+"\n";
iimPlay(sound);
break;
}
else{
//window.alert("FAIL "+err);
}
OKay...!, FCI finally mentioned:

Code: Select all

VERSION BUILD=8961227
WIndows XP
Firefox 40.0.1
... and you've shared your Solution to finish this Thread neatly. Perfect...! :D

(Even if I'm not completely convinced your Script will do exactly what you expect as the 'ATTR=ID:u_0_j' looks Dynamic to me from what I know about FB, but the point of your Thread was about the Mechanism for a Conditional Sound...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply