Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
Zach47
Posts: 13
Joined: 15 Nov 2021, 10:05

Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?

23 Jun 2023, 22:20

Hi,
I know a window of "ahk_class CabinetWClass" can be navigated to a spesific folder path by creating a ComObject.
But I couldn't make a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject.
Does anyone know how to do it? :)

Code: Select all


    path_folder_target := 'C:\'
    explorerHwnd := WinActive("ahk_class CabinetWClass") or WinActive("ahk_class #32770")
    if (explorerHwnd)
    {
        for window in ComObject("Shell.Application").Windows
        {
            if (window.hwnd == explorerHwnd)
            {
                window.navigate(path_folder_target)
            }
        }
    }

neogna2
Posts: 600
Joined: 15 Sep 2016, 15:44

Re: Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?

24 Jun 2023, 04:44

If you mean a "Save As", "Open" etcetera window from an external application then I don't know of any COM way to do that.

But you can interact with the window in other ways to set a folder path.

Code: Select all

ControlFocus("Edit1", "A")
ControlSetText("C:\some folder", "Edit1", "A")
ControlSend("{Enter}", "Edit1", "A") ; apply the path to make the Save As window navigate to it
Based on suggestions in this v1 thread on this topic viewtopic.php?t=82488

Though in my experience some such windows can vary in subtle ways that might require more conditions and special cases in the code.
sashaatx
Posts: 351
Joined: 27 May 2021, 08:27
Contact:

Re: Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?

24 Jun 2023, 07:02

Zach47 wrote:
23 Jun 2023, 22:20
Hi,
I know a window of "ahk_class CabinetWClass" can be navigated to a spesific folder path by creating a ComObject.
But I couldn't make a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject.
Does anyone know how to do it? :)

Code: Select all


    path_folder_target := 'C:\'
    explorerHwnd := WinActive("ahk_class CabinetWClass") or WinActive("ahk_class #32770")
    if (explorerHwnd)
    {
        for window in ComObject("Shell.Application").Windows
        {
            if (window.hwnd == explorerHwnd)
            {
                window.navigate(path_folder_target)
            }
        }
    }

https://github.com/Descolada/UIA-v2
https://github.com/samfisherirl
? /Easy-Auto-GUI-for-AHK-v2 ? /Useful-AHK-v2-Libraries-and-Classes : /Pulovers-Macro-Creator-for-AHKv2 :
WKen
Posts: 200
Joined: 21 Feb 2023, 00:01

Re: Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?

24 Jun 2023, 07:19

Code: Select all

#HotIf WinActive("ahk_class #32770")
^o::
{
  path := "D:\"
  if(ControlGetText("ToolbarWindow324", "A") = "Address: " . path)
     return

  ControlHide("Edit1", "A")
  sleep 10
  ControlSetText(path, "Edit1", "A")
  sleep 50
  ControlFocus("Edit1", "A")
  sleep 50
  ControlSend("{enter}", "Edit1", "A")
  sleep 50
  if(ControlGetText("Edit1", "A") = path)
  {
     ControlFocus("Edit1", "A")
	 sleep 50
     ControlSend("{enter}", "Edit1", "A")
  }
  ControlShow("Edit1", "A")
  return
}
#HotIf
User avatar
Zach47
Posts: 13
Joined: 15 Nov 2021, 10:05

Re: Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?

24 Jun 2023, 08:39

Thank you very much. :thumbup:
neogna2 wrote:
24 Jun 2023, 04:44
If you mean a "Save As", "Open" etcetera window from an external application then I don't know of any COM way to do that.

But you can interact with the window in other ways to set a folder path.

Code: Select all

ControlFocus("Edit1", "A")
ControlSetText("C:\some folder", "Edit1", "A")
ControlSend("{Enter}", "Edit1", "A") ; apply the path to make the Save As window navigate to it
Based on suggestions in this v1 thread on this topic viewtopic.php?t=82488

Though in my experience some such windows can vary in subtle ways that might require more conditions and special cases in the code.
User avatar
Zach47
Posts: 13
Joined: 15 Nov 2021, 10:05

Re: Can a window of ''ahk_class #32770" to be navigated to a spesific folder path by creating a ComObject or using dll?  Topic is solved

24 Jun 2023, 08:40

Thank you for your help. :D
WKen wrote:
24 Jun 2023, 07:19

Code: Select all

#HotIf WinActive("ahk_class #32770")
^o::
{
  path := "D:\"
  if(ControlGetText("ToolbarWindow324", "A") = "Address: " . path)
     return

  ControlHide("Edit1", "A")
  sleep 10
  ControlSetText(path, "Edit1", "A")
  sleep 50
  ControlFocus("Edit1", "A")
  sleep 50
  ControlSend("{enter}", "Edit1", "A")
  sleep 50
  if(ControlGetText("Edit1", "A") = path)
  {
     ControlFocus("Edit1", "A")
	 sleep 50
     ControlSend("{enter}", "Edit1", "A")
  }
  ControlShow("Edit1", "A")
  return
}
#HotIf

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: moltenchees and 45 guests