Catastrophic failure - Specifically: HWND Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dwilbank
Posts: 43
Joined: 15 Mar 2020, 12:59

Catastrophic failure - Specifically: HWND

Post by dwilbank » 31 Jan 2023, 21:47

Every code I try that involves Com or HWND crashes with a catastrophic failure.

Nowhere near or in the code does it say that I need extra libraries or a version like Autohotkey-L...

but is that the case?

This is just the latest code I can't run on Win 10 using my v1.1.33.02

Code: Select all

^F1::
WinGet, WinID, ID, ahk_class CabinetWClass
CurrentPath := ExplorerPath(WinID)
MsgBox, % CurrentPath
return

ExplorerPath(_hwnd)
{
   for w in ComObjCreate("Shell.Application").Windows
      if (w.hwnd = _hwnd)
      {
         path := StrReplace(w.LocationURL, "file:///")
         return StrReplace(path, "%20", " ")
      }
}
}
Last edited by dwilbank on 31 Jan 2023, 22:39, edited 1 time in total.

User avatar
mikeyww
Posts: 26947
Joined: 09 Sep 2014, 18:38

Re: Catastrophic failure - Specifically: HWND

Post by mikeyww » 31 Jan 2023, 21:52

code I can't run
This is really not a problem description. It does not describe what happens, or what should happen.

You can use the script to display the value of your clipboard as well as what your function returns. You currently have no idea, so this will help with the troubleshooting.

User avatar
boiler
Posts: 16963
Joined: 21 Dec 2014, 02:44

Re: Catastrophic failure - Specifically: HWND

Post by boiler » 31 Jan 2023, 22:25

dwilbank wrote: Nowhere near or in the code does it say that I need extra libraries or a version like Autohotkey-L...
That's what you're running. AHK v1.1+ is AutoHotkey_L.

dwilbank
Posts: 43
Joined: 15 Mar 2020, 12:59

Re: Catastrophic failure - Specifically: HWND

Post by dwilbank » 31 Jan 2023, 22:41

Then it must my version of Windows, or my installation of Directory Opus I guess.
Nothing with .hwnd has worked for me. Trying to access it causes a literal crash.
Last edited by dwilbank on 31 Jan 2023, 23:15, edited 1 time in total.

User avatar
mikeyww
Posts: 26947
Joined: 09 Sep 2014, 18:38

Re: Catastrophic failure - Specifically: HWND

Post by mikeyww » 31 Jan 2023, 22:57

From my perspective, if a problem cannot be described, then a solution to the problem cannot be devised.

What is "accessing if"? What crashes? Is there an error message? What are you trying to achieve? Have you displayed your variables & function returns? What is shown there?

You can post script revisions in new replies. That makes the thread easier to follow than if you go back and modify an earlier post after replies have already been generated.

dwilbank
Posts: 43
Joined: 15 Mar 2020, 12:59

Re: Catastrophic failure - Specifically: HWND  Topic is solved

Post by dwilbank » 31 Jan 2023, 23:10

For those following, the AHK script and its variables have nothing to do with the problem.

It's a Microsoft code issue. Enumeration through the different window.hwnds apparently causes a Catastrophic Error, and it takes some error catching blocks like I found at the bottom of on this page

https://www.autohotkey.com/boards/viewtopic.php?t=69925

Post Reply

Return to “Ask for Help (v1)”