Accessing a local variable (timer ID)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe

    Accessing a local variable (timer ID)

    Hi,

    I am trying to alter the refresh rate of an online webpage in a webbrowser
    control using MFC. However the Timer ID is stored in a local variable and I
    don't know how to access it. Is there a technique in Javascript that I might
    be able to use/adapt?

    I have a timer set within a prototype thus:

    ;HControl.proto type.setFLTimeo ut = function() {
    var oFLTimeout = setTimeout("hCt rl.mkView.reloa dFL();", iFLTimeout);
    }

    But the timer Id oFLTimeout is local so, once the page is loaded how can I
    access and stop the timer to prevent the page refreshing (or perhaps "reset"
    it to my own bespoke rate)?
    The only way I know how is using clearTimeout(), however this method
    requires the timer ID.

    Can I "list" all the timers somehow?

    I really am stumped and would like some advise on how I can progress.

    Thanks





  • Evertjan.

    #2
    Re: Accessing a local variable (timer ID)

    Joe wrote on 13 sep 2004 in comp.lang.javas cript:
    [color=blue]
    > I am trying to alter the refresh rate of an online webpage in a
    > webbrowser control using MFC. However the Timer ID is stored in a
    > local variable and I don't know how to access it. Is there a technique
    > in Javascript that I might be able to use/adapt?
    >
    > I have a timer set within a prototype thus:
    >
    > ;HControl.proto type.setFLTimeo ut = function() {
    > var oFLTimeout = setTimeout("hCt rl.mkView.reloa dFL();", iFLTimeout);[/color]

    So use a global variable.

    You are the boss of the code, aren't you?

    ===

    var oFLTimeout;

    HControl.protot ype.setFLTimeou t = function() {
    oFLTimeout = setTimeout("hCt rl.mkView.reloa dFL();", iFLTimeout);

    ===

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)

    Comment

    • Joe

      #3
      Re: Accessing a local variable (timer ID)

      > So use a global variable.[color=blue]
      >
      > You are the boss of the code, aren't you?
      >[/color]

      No, I'm not!

      Perhaps I wasn't clear enough, I said "online webpage" in other words I'm
      downloading the page and its scripts and I want to inhibit/change the page
      refresh timer.

      Thanks


      Comment

      • Evertjan.

        #4
        Re: Accessing a local variable (timer ID)

        Joe wrote on 13 sep 2004 in comp.lang.javas cript:[color=blue][color=green]
        >> So use a global variable.
        >>
        >> You are the boss of the code, aren't you?[/color]
        >
        > No, I'm not!
        >
        > Perhaps I wasn't clear enough, I said "online webpage" in other words
        > I'm downloading the page and its scripts and I want to inhibit/change
        > the page refresh timer.[/color]

        Indeed you were not very clear.

        So open the page,
        go to view source,
        change the code and save the local file,
        then execute this local file,
        if necessary after adding:
        <base href="http://the original url here"> in the <head> section.


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress,
        but let us keep the discussions in the newsgroup)

        Comment

        • Lee

          #5
          Re: Accessing a local variable (timer ID)

          Joe said:[color=blue]
          >
          >Hi,
          >
          >I am trying to alter the refresh rate of an online webpage in a webbrowser
          >control using MFC. However the Timer ID is stored in a local variable and I
          >don't know how to access it. Is there a technique in Javascript that I might
          >be able to use/adapt?[/color]

          Stop trying to cheat on whatever timed test it is
          that you're trying to hack.

          Comment

          • Joe

            #6
            Re: Accessing a local variable (timer ID)


            "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
            news:Xns9563A4C 1E5Beejj99@194. 109.133.29...[color=blue]
            > Joe wrote on 13 sep 2004 in comp.lang.javas cript:[color=green][color=darkred]
            > >> So use a global variable.
            > >>
            > >> You are the boss of the code, aren't you?[/color]
            > >
            > > No, I'm not!
            > >
            > > Perhaps I wasn't clear enough, I said "online webpage" in other words
            > > I'm downloading the page and its scripts and I want to inhibit/change
            > > the page refresh timer.[/color]
            >
            > Indeed you were not very clear.
            >
            > So open the page,
            > go to view source,
            > change the code and save the local file,
            > then execute this local file,
            > if necessary after adding:
            > <base href="http://the original url here"> in the <head> section.[/color]

            Well I'm still not being very clear:)

            I want to download the web page into my browser control.
            I want to then execute a "function" within my MFC program through the
            script interface which will allow me to "automatica lly" adjust the refresh
            rate by altering the script function dynamically.

            If the timerID is a global variable I can do it.

            However as it is a local variable I can't.

            "Manually" changing the page scripts isn't an option.






            Comment

            • Joe

              #7
              Re: Accessing a local variable (timer ID)


              "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
              news:ci48mj01j6 4@drn.newsguy.c om...[color=blue]
              > Joe said:[color=green]
              > >
              > >Hi,
              > >
              > >I am trying to alter the refresh rate of an online webpage in a[/color][/color]
              webbrowser[color=blue][color=green]
              > >control using MFC. However the Timer ID is stored in a local variable and[/color][/color]
              I[color=blue][color=green]
              > >don't know how to access it. Is there a technique in Javascript that I[/color][/color]
              might[color=blue][color=green]
              > >be able to use/adapt?[/color]
              >
              > Stop trying to cheat on whatever timed test it is
              > that you're trying to hack.[/color]


              Thanks Lee, very useful. Of course, I'm not "cheating" anything.

              Have you any constructive comments to make which might actually help me out?


              Comment

              • Evertjan.

                #8
                Re: Accessing a local variable (timer ID)

                Joe wrote on 13 sep 2004 in comp.lang.javas cript:
                [color=blue]
                > Well I'm still not being very clear:)
                >
                > I want to download the web page into my browser control.[/color]

                What is a "browser control"?
                [color=blue]
                > I want to then execute a "function" within my MFC program through the
                > script interface which will allow me to "automatica lly" adjust the
                > refresh rate by altering the script function dynamically.
                >
                > If the timerID is a global variable I can do it.
                >
                > However as it is a local variable I can't.
                >
                > "Manually" changing the page scripts isn't an option.[/color]

                Changing the page by script should be possible.

                I suppose you want to do some data mining.

                Like this?

                function getUrl(url) {
                var http = new ActiveXObject(" microsoft.xmlht tp");
                http.open("GET" ,url,false);
                http.send();
                return http.responseTe xt;
                }

                When the content of the file is in a local variable as a string,
                you can replace parts of that string with multiple regex replace.

                t = getUrl('http://yourTargettedWE Bsource.com/')

                t = t.replace(/;HControl.proto type/,
                'var oFLTimeout\n;HC ontrol.prototyp e')
                t = t.replace(/var oFLTimeout/,'oFLTimeout')


                After that you can execute the string as if it were a http file.

                [How? I have to think about that ;-) ]


                --
                Evertjan.
                The Netherlands.
                (Please change the x'es to dots in my emailaddress,
                but let us keep the discussions in the newsgroup)

                Comment

                • Lee

                  #9
                  Re: Accessing a local variable (timer ID)

                  Joe said:[color=blue]
                  >
                  >
                  >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                  >news:ci48mj01j 64@drn.newsguy. com...[color=green]
                  >> Joe said:[color=darkred]
                  >> >
                  >> >Hi,
                  >> >
                  >> >I am trying to alter the refresh rate of an online webpage in a[/color][/color]
                  >webbrowser[color=green][color=darkred]
                  >> >control using MFC. However the Timer ID is stored in a local variable and[/color][/color]
                  >I[color=green][color=darkred]
                  >> >don't know how to access it. Is there a technique in Javascript that I[/color][/color]
                  >might[color=green][color=darkred]
                  >> >be able to use/adapt?[/color]
                  >>
                  >> Stop trying to cheat on whatever timed test it is
                  >> that you're trying to hack.[/color]
                  >
                  >
                  >Thanks Lee, very useful. Of course, I'm not "cheating" anything.[/color]

                  You're welcome.

                  It's not your page. Somebody put a timer there for a
                  reason. You're trying to change it. That fits my
                  definition of cheating.

                  If it happens not to be a test, posting a solution (if
                  one existed) would allow others to cheat on such tests.

                  Comment

                  • Joe

                    #10
                    Re: Accessing a local variable (timer ID)


                    "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                    news:ci4cci01vt 0@drn.newsguy.c om...[color=blue]
                    > Joe said:[color=green]
                    > >
                    > >
                    > >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                    > >news:ci48mj01j 64@drn.newsguy. com...[color=darkred]
                    > >> Joe said:
                    > >> >
                    > >> >Hi,
                    > >> >
                    > >> >I am trying to alter the refresh rate of an online webpage in a[/color]
                    > >webbrowser[color=darkred]
                    > >> >control using MFC. However the Timer ID is stored in a local variable[/color][/color][/color]
                    and[color=blue][color=green]
                    > >I[color=darkred]
                    > >> >don't know how to access it. Is there a technique in Javascript that I[/color]
                    > >might[color=darkred]
                    > >> >be able to use/adapt?
                    > >>
                    > >> Stop trying to cheat on whatever timed test it is
                    > >> that you're trying to hack.[/color]
                    > >
                    > >
                    > >Thanks Lee, very useful. Of course, I'm not "cheating" anything.[/color]
                    >
                    > You're welcome.
                    >
                    > It's not your page. Somebody put a timer there for a
                    > reason. You're trying to change it. That fits my
                    > definition of cheating.[/color]
                    [color=blue]
                    > If it happens not to be a test, posting a solution (if
                    > one existed) would allow others to cheat on such tests.[/color]

                    So you're posting smart-arse comments from baseless assumptions when you
                    have no idea at all why I want to do what I'm asking.

                    That fits my definition of a ******* ******.

                    Have a nice day.








                    Comment

                    • Joe

                      #11
                      Re: Accessing a local variable (timer ID)


                      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
                      news:Xns9563AD3 EAFFCCeejj99@19 4.109.133.29...[color=blue]
                      > Joe wrote on 13 sep 2004 in comp.lang.javas cript:
                      >[color=green]
                      > > Well I'm still not being very clear:)
                      > >
                      > > I want to download the web page into my browser control.[/color]
                      >
                      > What is a "browser control"?[/color]

                      Microsofts WebBrowser Control.
                      By downloading a page into that I can get "programati c" access to the
                      documents properties and objects, scripts etc and do some "bespoke"
                      operations on them (hopefully) such as altering the refresh rate. It also
                      allows you to execute javascript functions - "standard" such as
                      ClearTimeout() and user defined, but as the timerID is only defined locally
                      in the prototype settimer function I gave in my initial post I can't find
                      it.

                      Here's a refrence if you're interested:
                      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


                      [color=blue]
                      >Changing the page by script should be possible.[/color]
                      [color=blue]
                      >I suppose you want to do some data mining.[/color]

                      Sort of.
                      But really I don't want unecessary refreshes clogging up bandwidth. Also any
                      solution might help me learn a nice way into the scripts.[color=blue]
                      >
                      > Like this?
                      >
                      > function getUrl(url) {
                      > var http = new ActiveXObject(" microsoft.xmlht tp");
                      > http.open("GET" ,url,false);
                      > http.send();
                      > return http.responseTe xt;
                      > }[/color]

                      Maybe. With a webbrowser control its possible build that text as a function
                      and execute it as javascript. I'm sure you can in other languages but I'm
                      familiar with MFC (not an expert with the WBC or javascript though).

                      For instance I've managed to alter the timer rate and set up a new timer for
                      the page.
                      However, all this does is add a new timer in addition to the old so I end up
                      with both timers refreshing the page.

                      [color=blue]
                      > When the content of the file is in a local variable as a string,
                      > you can replace parts of that string with multiple regex replace.
                      >
                      > t = getUrl('http://yourTargettedWE Bsource.com/')
                      >
                      > t = t.replace(/;HControl.proto type/,
                      > 'var oFLTimeout\n;HC ontrol.prototyp e')
                      > t = t.replace(/var oFLTimeout/,'oFLTimeout')
                      >
                      >
                      > After that you can execute the string as if it were a http file.
                      >
                      > [How? I have to think about that ;-) ]
                      >[/color]

                      OK. Whatever ideas you may come up with I will obviously have to convert to
                      run in the WBC but thats my problem ;) - I just need a way forward.

                      Will the timer be prevented from running by changing the text, given that
                      the script may have been executed and the timer set up before the text is
                      altered?

                      I'm not sure how I can change any script after it is downloaded but before
                      it runs in a WBC. If its possible then I could just change the timer delay
                      variable to be whatever rate I want - although this would then be fixed for
                      the life of the WBC.

                      An ideal solution would be to delete the existing timer so that I can set up
                      a new timer to refresh at any rate I wish.

                      But any ideas appreciated.









                      Comment

                      • Lasse Reichstein Nielsen

                        #12
                        Re: Accessing a local variable (timer ID)

                        "Joe" <not@home.com > writes:
                        [color=blue]
                        > I want to download the web page into my browser control.
                        > I want to then execute a "function" within my MFC program through the
                        > script interface which will allow me to "automatica lly" adjust the refresh
                        > rate by altering the script function dynamically.[/color]

                        I recommend changing the content of the page by intercepting the download
                        of the page, and then change the page before giving it to the control (if
                        intercepting is possible). You can then change the page to make the local
                        variable global, or something else.
                        [color=blue]
                        > If the timerID is a global variable I can do it.[/color]
                        [color=blue]
                        > However as it is a local variable I can't.[/color]

                        Correct.
                        [color=blue]
                        > "Manually" changing the page scripts isn't an option.[/color]

                        Are you sure? It could be easier.

                        Also, getting the id of the timeout won't help you a lot anyway. All
                        you can do is cancel that one timeout. A better way would be to
                        replace the "setTimeout " with your own version, that calls the
                        original. Something like executing this script:

                        ---
                        var oldSetTimeout = setTimeout;
                        var myOverrideTime;
                        var myLatestTimeout ;
                        setTimeout = new function(arg,ti me) {
                        return (myLatestTimeou t = oldSetTimeout(a rg, myOverrideTime || time);
                        };
                        ---

                        Good luck
                        /L
                        --
                        Lasse Reichstein Nielsen - lrn@hotpop.com
                        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                        'Faith without judgement merely degrades the spirit divine.'

                        Comment

                        • Lee

                          #13
                          Re: Accessing a local variable (timer ID)

                          Joe said:[color=blue]
                          >
                          >
                          >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                          >news:ci4cci01v t0@drn.newsguy. com...[color=green]
                          >> Joe said:[color=darkred]
                          >> >
                          >> >
                          >> >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                          >> >news:ci48mj01j 64@drn.newsguy. com...
                          >> >> Joe said:
                          >> >> >
                          >> >> >Hi,
                          >> >> >
                          >> >> >I am trying to alter the refresh rate of an online webpage in a
                          >> >webbrowser
                          >> >> >control using MFC. However the Timer ID is stored in a local variable[/color][/color]
                          >and[color=green][color=darkred]
                          >> >I
                          >> >> >don't know how to access it. Is there a technique in Javascript that I
                          >> >might
                          >> >> >be able to use/adapt?
                          >> >>
                          >> >> Stop trying to cheat on whatever timed test it is
                          >> >> that you're trying to hack.
                          >> >
                          >> >
                          >> >Thanks Lee, very useful. Of course, I'm not "cheating" anything.[/color]
                          >>
                          >> You're welcome.
                          >>
                          >> It's not your page. Somebody put a timer there for a
                          >> reason. You're trying to change it. That fits my
                          >> definition of cheating.[/color]
                          >[color=green]
                          >> If it happens not to be a test, posting a solution (if
                          >> one existed) would allow others to cheat on such tests.[/color]
                          >
                          >So you're posting smart-arse comments from baseless assumptions when you
                          >have no idea at all why I want to do what I'm asking.
                          >
                          >That fits my definition of a ******* ******.[/color]

                          What part of my comments qualify as "smart-arse"?

                          No, you don't seem to read well. I do have a base for my
                          assumptions. You're trying to change the functionality of
                          somebody else's web page. That a pretty substantial base.
                          If you've got some justification, it's up to you to present
                          it, if you expect help.

                          I've also said that completely regardless of why you want to
                          do what you're asking for, it would be irresponsible to post
                          a solution (if one existed).

                          Comment

                          • Joe

                            #14
                            Re: Accessing a local variable (timer ID)


                            "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
                            news:mzzu2ls1.f sf@hotpop.com.. .[color=blue]
                            > "Joe" <not@home.com > writes:
                            >[color=green]
                            > > I want to download the web page into my browser control.
                            > > I want to then execute a "function" within my MFC program through the
                            > > script interface which will allow me to "automatica lly" adjust the[/color][/color]
                            refresh[color=blue][color=green]
                            > > rate by altering the script function dynamically.[/color]
                            >
                            > I recommend changing the content of the page by intercepting the download
                            > of the page, and then change the page before giving it to the control (if
                            > intercepting is possible). You can then change the page to make the local
                            > variable global, or something else.[/color]

                            Hello Lasse.

                            I've been investigating this for some time but haven't found out how to do
                            it through a WebBrowser Control - of course doesn't mean it can't easily be
                            done ;)

                            [color=blue][color=green]
                            > > If the timerID is a global variable I can do it.[/color]
                            >[color=green]
                            > > However as it is a local variable I can't.[/color]
                            >
                            > Correct.
                            >[color=green]
                            > > "Manually" changing the page scripts isn't an option.[/color]
                            >
                            > Are you sure? It could be easier.[/color]

                            Well, depends on what one means by "manually". I want to run the program
                            automatically without having to be present.

                            [color=blue]
                            > Also, getting the id of the timeout won't help you a lot anyway. All
                            > you can do is cancel that one timeout. A better way would be to
                            > replace the "setTimeout " with your own version, that calls the
                            > original. Something like executing this script:
                            >
                            > ---
                            > var oldSetTimeout = setTimeout;
                            > var myOverrideTime;
                            > var myLatestTimeout ;
                            > setTimeout = new function(arg,ti me) {
                            > return (myLatestTimeou t = oldSetTimeout(a rg, myOverrideTime || time);
                            > };[/color]

                            Again, this is dependent on me being able to change the scripts before
                            execution which I'm trying to work out how to do.

                            Thanks








                            Comment

                            • Joe

                              #15
                              Re: Accessing a local variable (timer ID)


                              "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                              news:ci4fth02c9 6@drn.newsguy.c om...[color=blue]
                              > Joe said:[color=green]
                              > >
                              > >
                              > >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                              > >news:ci4cci01v t0@drn.newsguy. com...[color=darkred]
                              > >> Joe said:
                              > >> >
                              > >> >
                              > >> >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                              > >> >news:ci48mj01j 64@drn.newsguy. com...
                              > >> >> Joe said:
                              > >> >> >
                              > >> >> >Hi,
                              > >> >> >
                              > >> >> >I am trying to alter the refresh rate of an online webpage in a
                              > >> >webbrowser
                              > >> >> >control using MFC. However the Timer ID is stored in a local[/color][/color][/color]
                              variable[color=blue][color=green]
                              > >and[color=darkred]
                              > >> >I
                              > >> >> >don't know how to access it. Is there a technique in Javascript[/color][/color][/color]
                              that I[color=blue][color=green][color=darkred]
                              > >> >might
                              > >> >> >be able to use/adapt?
                              > >> >>
                              > >> >> Stop trying to cheat on whatever timed test it is
                              > >> >> that you're trying to hack.
                              > >> >
                              > >> >
                              > >> >Thanks Lee, very useful. Of course, I'm not "cheating" anything.
                              > >>
                              > >> You're welcome.
                              > >>
                              > >> It's not your page. Somebody put a timer there for a
                              > >> reason. You're trying to change it. That fits my
                              > >> definition of cheating.[/color]
                              > >[color=darkred]
                              > >> If it happens not to be a test, posting a solution (if
                              > >> one existed) would allow others to cheat on such tests.[/color]
                              > >
                              > >So you're posting smart-arse comments from baseless assumptions when you
                              > >have no idea at all why I want to do what I'm asking.
                              > >
                              > >That fits my definition of a ******* ******.[/color]
                              >
                              > What part of my comments qualify as "smart-arse"?
                              >
                              > No, you don't seem to read well. I do have a base for my
                              > assumptions. You're trying to change the functionality of
                              > somebody else's web page. That a pretty substantial base.
                              > If you've got some justification, it's up to you to present
                              > it, if you expect help.
                              >
                              > I've also said that completely regardless of why you want to
                              > do what you're asking for, it would be irresponsible to post
                              > a solution (if one existed).
                              >[/color]

                              Bye


                              Comment

                              Working...