Sumit Bisht - 2012-02-28

I am having a python based key recorder that uses pyhook to grab the key strokes. Just before the recording, I display a modal dialog to the user which starts the process of hooking the keyboard for the recording. After the button for record is pressed in the dialog, I am closing the dialog in its event handler:

            self.MakeModal(False)
            self.Destroy()

The dialog object then returns to the main caller and the keys are hooked again through the following method:

            self.hm = pyHook.HookManager()
            self.hm.HookKeyboard()

If I am clicking the button for the dialog box, the code runs as expected. But when I am pressing Enter instead of clicking, the Keyup event of Key.ENTER gets displayed in the application process. Is there any specific way of flushing/removing all the changes made prior to the hooking of a device by pyhook?