AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timer weirdness with JavaScript in an embedded IE control

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
tfcahm



Joined: 20 May 2007
Posts: 48

PostPosted: Tue Jul 17, 2007 8:29 am    Post subject: Timer weirdness with JavaScript in an embedded IE control Reply with quote

JavaScript timers (Windows timers) do not work in HTML pages displayed using an embedded IE control. Interestingly, if a MsgBox is opened the timers will start to work. When the MsgBox is closed the timers stop working.

Similar symptoms without JavaScript were reported in this thread: BalloonTip.

This example demonstrates the problem. Copy both files to the same directory. Requires CoHelper.ahk and IEControl.ahk. Tested with AHK version 1.0.47.01.

Test.ahk
Code:
#Include CoHelper.ahk
#Include IEControl.ahk

CoInitialize()
AtlAxWinInit()
Gui, +LastFound
Gui, Show, w200 h50 x50 y50, Timer Weirdness
hWnd := WinExist()
pwb := ActiveXObject("Shell.Explorer")
AtlAxAttachControl(pwb, hWnd)
IE_LoadURL(pwb, A_ScriptDir . "\Test.html")
Hotkey, IfWinActive, ahk_id %hWnd%
Hotkey, ^m, NewMsgBox

;  While a msgbox exists the JavaScript timer works.
;  The msgbox does not need to be active or visible.
;  Close the msgbox and the JavaScript timer stops working
GoSub NewMsgBox

Return

NewMsgBox:
  MsgBox,, AHK MsgBox,
    (LTrim
      Close this AHK MsgBox and the timer used by JavaScript stops working.       
      Open a new MsgBox with the hotkey ^m and the timers will start working again.
    )
Return

GuiClose:
  Gui, Destroy
  Release(pwb)
  AtlAxWinTerm()
  CoUninitialize()
  ExitApp
Return

Test.html (works properly when opened in Internet Explorer)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
      setTimeout("showmsg()",500);  //First time only, the timer fires after 0.5 sec
      function showmsg(){
          var msg = 'This JavaScript message appears whenever the timer fires. ' + 
          'As long as the AHK MsgBox exists the timer works. ' + 
          'As soon as the AHK MsgBox is closed the timer stops working. ' +
          'Click OK to close this dialog and reset the timer.' ;
          alert(msg)
          setTimeout("showmsg()",2000);  //Timer fires after 2 sec
         }
    </script>
  </head>
  <body></body>
</html>

This is a much simpler example than the one discussed in this thread JavaScript Tooltip in an embedded IE Control.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10465

PostPosted: Thu Jul 19, 2007 12:04 am    Post subject: Reply with quote

I may have found the problem: the program currently intercepts/blocks WM_TIMER messages that don't have a TimerProc. Perhaps you can try out the latest release to see if it fixes the problem.

Thanks for reporting it.


Last edited by Chris on Thu Jul 19, 2007 4:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
tfcahm



Joined: 20 May 2007
Posts: 48

PostPosted: Thu Jul 19, 2007 6:13 am    Post subject: Reply with quote

Works perfectly in my scripts! Thanks Chris!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group