Ciantic / VirtualDesktopAccessor

DLL for accessing Windows 11/10 Virtual Desktop features from e.g. AutoHotkey
MIT License
782 stars 93 forks source link

Sometimes Crash with 0xC0000005 #57

Closed ZhuangQu closed 1 year ago

ZhuangQu commented 1 year ago

My system is Windows 11. I wrote an AutoHotkey script which executes GetDesktopCount, GetCurrentDesktopNumber and GetDesktopName for 16 consecutive times every 100 ms. After running for about 1 hour, AutoHotkey crashes with 0xC0000005 and then loses response.

Ciantic commented 1 year ago

Why are you calling it every 100ms for an hour? There is event listener which triggers when you change desktop.

I've even gotten explorer.exe to crash if I call some of the functions too many times, something goes wrong somewhere.

ZhuangQu commented 1 year ago

I call the DLL so frequently to know whether the desktop has changed. The listener will crash when I add a desktop in taskview, so I dare not use it.

ZhuangQu commented 1 year ago

I add

ProcessSetPriority("Realtime")

to my AutoHotkey script and it doesn't crash anymore. I don't know why so.

Ciantic commented 1 year ago

Do you add and remove a lot of desktops every day?

Listener is a way to go here, but I do need to find the crash and fix it.

I have 16 desktops at all times, I don't add and remove these practically ever so it's a rare occasion for me.

ZhuangQu commented 1 year ago

Yes! And I found that raising the process priority can solve the problem, so I close it.