Sometimes, when I use the KeePass auto type, I get this error screen and KeePass blocks until I close the error window:
specified cast is not valid
I am now runnig KeePass with the debug option and got some more information. It looks like it has to to with this plugin. I just upgraded from version 6.9.0.0 to 6.9.1.0, so maybe the problem is solved now. I did not find any tickets regarding this subject, so I will post the error info here anyway:
KeePass
Specified cast is not valid.
InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
at Accessibility.IAccessible.get_accRole(Object varChild)
at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
at WebAutoType.ChromeBrowserUrlReader.GetDocument()
at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
Accessibility
OK
Is this indeed a bug in WebAutoType?
Last edit: Alex Frost 2025-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is certainly coming from WebAutoType, but I don't know whether it's a bug or not. Does it only happen with a specific website? Are there steps you can take which make it happen reliably?
From the stack trace you've supplied it does not look like something WebAutoType can fix, as it's happening internally within the Windows accessibility code, but it should at least be possible to trap it and not crash when it happens, instead just failing to auto-type.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This seems to happen randomly on various sites, hard to reproduce 😔. When it happens and I close the error window, I can just pres CTRL+ALT+A on my keyboard again for that same site and it just works fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My default browser is Edge, but I do use Chrome (and even some other browsers). Next time, I will pay attention which browser is concerns as it indeed might be browser specific.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for reporting back. I have created a possible workaround fix, as you say that if you just try again on the same site then it works. With the attached, WebAutoType will detect the error and automatically retry once to see if it is just an intermittent fault. If it still fails, the error will be reported normally.
If you try this, and still see the error, then the only other option may be to have it simply ignore it, but having it silently fail to find the window is not necessarily an improvement on reporting the error anyway.
Hi, I have the update installed, but the auto retry does not seem to work. I get a sound notification when I tried the autotype in Chrome, but still had to go to KeePass and click 'OK' in the message window 😁
I just got the error with Edge! So ti happens both wih Edge as with Chrome (but of course, Edge runs on Chromium). The auto retry fix does nor work, because you explicitly click the 'OK' button in the error Window. I guess it is more of the same, but here is the error window message
KeePass
Specified cast is not valid.
InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
at Accessibility.IAccessible.get_accRole(Object varChild)
at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable1 role, String customRole, Nullable1 hasState, Nullable1 hasNotState)
at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
at WebAutoType.ChromeBrowserUrlReader.GetDocument()
at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
Accessibility
OK
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for reporting back. That's a shame that automatic retrying isn't going to help then. This might be something that has to be fixed on Chrome, unfortunately.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. what do you mean with 'something that has to be fixed on Chrome'? That is why I reported that I had the issue with Edge this time 😁
I use Firefox, Brave and Ghostery too, but not that often. As soon as I encounter the problems on one of those, I will report it too.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I mean that Chrome (well, Chromium) will have to fix it on their side, so that the accessibility request no longer throws that error. It did not use to, hopefully they will fix it in the future. Edge is just another Chrome variant so if Chrome fixes it the fix will end up in Edge too.
Firefox is not a Chrome variant, so is not affected. Brave is another Chrome.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sometimes, when I use the KeePass auto type, I get this error screen and KeePass blocks until I close the error window:
specified cast is not valid
I am now runnig KeePass with the debug option and got some more information. It looks like it has to to with this plugin. I just upgraded from version 6.9.0.0 to 6.9.1.0, so maybe the problem is solved now. I did not find any tickets regarding this subject, so I will post the error info here anyway:
KeePass
Specified cast is not valid.
InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
at Accessibility.IAccessible.get_accRole(Object varChild)
at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable
1 role, String customRole, Nullable
1 hasState, Nullable1 hasNotState) at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable
1 role, String customRole, Nullable1 hasState, Nullable
1 hasNotState)at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
at WebAutoType.ChromeBrowserUrlReader.GetDocument()
at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
Accessibility
OK
Is this indeed a bug in WebAutoType?
Last edit: Alex Frost 2025-05-13
This is certainly coming from WebAutoType, but I don't know whether it's a bug or not. Does it only happen with a specific website? Are there steps you can take which make it happen reliably?
From the stack trace you've supplied it does not look like something WebAutoType can fix, as it's happening internally within the Windows accessibility code, but it should at least be possible to trap it and not crash when it happens, instead just failing to auto-type.
This seems to happen randomly on various sites, hard to reproduce 😔. When it happens and I close the error window, I can just pres CTRL+ALT+A on my keyboard again for that same site and it just works fine.
OK, thanks for letting me know. If it doesn't actually cause KeePass to crash out or stop working then it's not so serious, but still irritating.
Is it Chrome that you are using, or one of the other Chrome-based browsers?
My default browser is Edge, but I do use Chrome (and even some other browsers). Next time, I will pay attention which browser is concerns as it indeed might be browser specific.
Just had the issue this morning... With Chrome...
Will let you know as soon as (and if) I experience the issue with Edge too.
Thanks for reporting back. I have created a possible workaround fix, as you say that if you just try again on the same site then it works. With the attached, WebAutoType will detect the error and automatically retry once to see if it is just an intermittent fault. If it still fails, the error will be reported normally.
If you try this, and still see the error, then the only other option may be to have it simply ignore it, but having it silently fail to find the window is not necessarily an improvement on reporting the error anyway.
Hi, I have the update installed, but the auto retry does not seem to work. I get a sound notification when I tried the autotype in Chrome, but still had to go to KeePass and click 'OK' in the message window 😁
Last edit: Alex Frost 2025-06-10
I just got the error with Edge! So ti happens both wih Edge as with Chrome (but of course, Edge runs on Chromium). The auto retry fix does nor work, because you explicitly click the 'OK' button in the error Window. I guess it is more of the same, but here is the error window message
KeePass
Specified cast is not valid.
InvalidCastException (0x80004002) @ System.Object get_accRole(System.Object)
at Accessibility.IAccessible.get_accRole(Object varChild)
at WebAutoType.AccessibleObjectHelper.AccessibleObjectMatchesConditions(IAccessible accessibleObject, Nullable
1 role, String customRole, Nullable
1 hasState, Nullable1 hasNotState) at WebAutoType.AccessibleObjectHelper.FindChild(IAccessible parent, Nullable
1 role, String customRole, Nullable1 hasState, Nullable
1 hasNotState)at WebAutoType.ChromeBrowserUrlReader.TryGetAccessibleDocFromRenderWindow(IntPtr chromeRenderHwnd)
at WebAutoType.ChromeBrowserUrlReader.GetDocument()
at WebAutoType.BrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.ChromeBrowserUrlReader.GetBrowserFocusUrl(Boolean& passwordFieldFocussed)
at WebAutoType.WebAutoTypeExt.AutoType_SequenceQueriesBegin(Object sender, SequenceQueriesEventArgs e)
at KeePass.Util.AutoType.GetSequencesForWindowBegin(IntPtr hWnd, String strWindow)
at KeePass.Util.AutoType.PerformGlobal(List`1 lSources, ImageList ilIcons, String strSeq)
at KeePass.Forms.MainForm.ExecuteGlobalAutoType(String strSeq)
Accessibility
OK
Thanks for reporting back. That's a shame that automatic retrying isn't going to help then. This might be something that has to be fixed on Chrome, unfortunately.
Hi. what do you mean with 'something that has to be fixed on Chrome'? That is why I reported that I had the issue with Edge this time 😁
I use Firefox, Brave and Ghostery too, but not that often. As soon as I encounter the problems on one of those, I will report it too.
Thanks.
I mean that Chrome (well, Chromium) will have to fix it on their side, so that the accessibility request no longer throws that error. It did not use to, hopefully they will fix it in the future. Edge is just another Chrome variant so if Chrome fixes it the fix will end up in Edge too.
Firefox is not a Chrome variant, so is not affected. Brave is another Chrome.
Yeah, both Chromium. Realized that after I posted. All clear 😁
Last edit: Alex Frost 2025-06-29