Sign in to follow this  
Followers 0
Eraserblade

A little starter Help please

2 posts in this topic

Hy, im a somwhat beginer in the art of programing.

Let me explain in little details what i would like to do. Its something to ease my daily work and some headache...

So first of im using Mozilla Firefox and a plugin named GreaseMonkey and with some help from other forums i manage to patch a script( mostly from others help ofc) that automates some stuff on a webpage.

Now this script is so complex and a little over me, but does the job pretty good. Only problem is i need to keep a live window of Mozilla active at all times and sometime that makes my PC lagg a lot when playing online, or whatching an online movie.

So i decided to make a nice Auto IT script that would open Mozilla, acces the webpage, let the script do the job, and close it. But the script to remain and run in the background for a certain amount of time ( the amount of time taken from the Greasemonkey's script). And here it is my problem: im not able to get that Timer value from the Greasemonkeys script.

because i need that value, so my Script would know when its the time to trigger another event:

Start mozilla, - >  visit webpage, - >  wait for the grease monkey script to the job,  - >  take the new timer value, - >  sleep.    And so on.

 

Later on i want to develop that into a GUI, so my girlfriend can use it from anywhere...also i wana have it with me at work. But im stuck for now.

Please keep in mind that im only doing this out of passion, not NEED...cause i can just set an alarm clock  and do it manualy..

So here is the part where the GreaseMonkeys script sets the timer value:

// TODO: Add code to get next task finish time
        chartimers[charcurrent] = getNextFinishedTask();
        return false;
    }
    
    /**
     * Finds the task finishing next & returns the date or NULL otherwise
     * 
     * @return {Date} / {null}
     */
    function getNextFinishedTask() {
        var tmpNext, next = null;
    unsafeWindow.client.dataModel.model.ent.main.itemassignments.assignments.forEach(function(entry) {
        if (entry.uassignmentid) {
            tmpNext = new Date(entry.ufinishdate);
            if (!next || tmpNext < next) { next = tmpNext; }
        }
    });
    if (next) {
        console.log("Next finished task at " + next.toLocaleString());
    } else {
        console.log("No next finishing date found!!");
    }
    return next;
    }

now here is what i get when inspecting the timer element on mozilla:

<h3 class="promo-image copy-top prh3">Professions Robot<br>Next task for ...<br><span data-timer="Mon Dec 01 2014 23:15:42 GMT+0200 (GTB Standard Time)" data-timer-length="2">21m 42s</span></h3>

Please help me get that timer Value, how can i make my script to take that value so it can use it ???

Dont give me the exact code ... but at least throw me a bone pls :)

i will be forever in your debt :)

Share this post


Link to post
Share on other sites



Something tells me you're using FF.au3, and I'm am totally unaware of how it's used.

However, from the snippet, it looks like getNextFinshedTask() is a public function that returns the value for the "charcurrent" count.

If you are able to set a global var outside the functions, that you can access it would be easy.

A simple eval call would do it.

eg:

var myuniqueVarName = 0
// all my functions
function 1{
chartimers[charcurrent] = getNextFinishedTask();
myuniqueVarName = chartimers[charcurrent];
        return false;
}
// rest of my functions

 

Then with AutoIt it would be something like (pseudo):

$oObjWindow.Eval('myuniqueVarName;')

Assuming eval can be called outright, maybe they (FF.au3) have a eval function, I'm sure they do.

From that string, you could parse it with regex if it returns a string date like you've provided.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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