I'm trying to work with OCX files in Python script (you can see it in my last topic "Use an OCX", my problem is always here).
I have downloaded ietimer.ocx because i want to test the events in OCX.
Here is my code :
- Code: Select all
from win32com.client import DispatchWithEvents
i = 0
class Events:
def OnTimer(self):
global i
i = i + 1
l = DispatchWithEvents("Internet.Timer.1", Events)
l.Interval = 1000
l.Enabled = True
print "Press any key when finished with Timer!"
# Wait for a keypress
import time, pythoncom, msvcrt
while not msvcrt.kbhit():
pythoncom.PumpWaitingMessages()
time.sleep(.2)
# Gobble the key.
msvcrt.getch()
print i
# Release the object
l = None
I was expecting that my function OnTimer would be called every second (1000ms) but it is not the case (I tried with Interval = 1 but it is the same).
Can someone explain me why?
Thanks
Yohann

