amazing-andrew/AutoHotkey.Interop

"RegClass" Error when creating an Instance

AkilaJ opened this issue · 4 comments

I'm creating a new AHK instance at my WPF window load event. However, if I close the window and open the same window quickly, I get a dialog box with "RegClass" as the text. This only happens if I close and open the window quickly.

Recreation steps.

  1. Create ahk = new AutoHotkey.Interop.AutoHotkeyEngine(); in the Window Load. Then call ExecRaw to execute some command.
  2. Open the Window.
  3. Close the Window.
  4. IMPORTANT: Open the window again very quickly (within 2-3 seconds)
    Outcome: There will be a dialog box with the Message "RegClass" and then the application will crash.

Screenshot

error

UPDATE: I've managed to find a workaround for the issue by enforcing a Singleton Instance of the AHK class. However, the issue exists for the situations where two instances of AHK with the same content are loaded. If there's a way to destruct/remove the loaded contents, it would be great. (I tried refresh and terminate without any luck)

The AutoHotkey Engine was never really meant to be loaded multiple times, so it should be a singleton instance. I will fix this in the library.

Super. Thanks :)