Page 1 of 1

problems with ControlSetText

Posted: 10 Jan 2018, 05:07
by ttttt
Hi everyone. I'm trying to open an address in the active Explorer window (Win10).
I have this code:

Code: Select all

#k::
IfWinActive, ahk_exe explorer.exe
{
	ControlGetText, curPath, Edit1, A
	MsgBox, %curPath% ;shows current path
	ControlSetText, Edit1, C:\, A
	ControlSend, Edit1, {Enter}, A
}
return
But this works only once. Iif I browse to a different folder and hit #k in the message box I see "C:\" and not the actual current path, like AHK didn't get the updated Edit1 field..?

First launch:
Shows correct current path, re-addresses to C:\
Image

Second launch:
I browsed to a different folder and launched script but %curPath% shows C:\ and nothing happens
Image

What am I missing?
Many thanks!

Re: problems with ControlSetText

Posted: 10 Jan 2018, 07:03
by BoBo
Let's guess it would be more reliable if you configure your Explorer window to show the full path in its window title. That's a single click at its settings and should be easily to capture using AHK.

Re: problems with ControlSetText  Topic is solved

Posted: 10 Jan 2018, 07:38
by noname
These are some code snippets i collected unfortunately without source .....

Code: Select all

#k::
IfWinActive, ahk_exe explorer.exe
    {
    WinHWND := WinActive("A")
    for item in ComObjCreate("Shell.Application").Windows
    currentpath := item.Document.Folder.Self.Path
       msgbox % currentpath

    for Item in ComObjCreate("Shell.Application").Windows
    if (Item.HWND = WinHWND)
    item.navigate("c:\")
    }
return

Re: problems with ControlSetText

Posted: 10 Jan 2018, 07:44
by ttttt
I was going to fiddle with Explorer window title but noname's snippet works perfect!
Thanks guys!