problems with ControlSetText Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ttttt
Posts: 9
Joined: 01 Jun 2017, 03:59

problems with ControlSetText

10 Jan 2018, 05:07

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!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: problems with ControlSetText

10 Jan 2018, 07:03

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.
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: problems with ControlSetText  Topic is solved

10 Jan 2018, 07:38

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
Last edited by noname on 10 Jan 2018, 08:07, edited 1 time in total.
ttttt
Posts: 9
Joined: 01 Jun 2017, 03:59

Re: problems with ControlSetText

10 Jan 2018, 07:44

I was going to fiddle with Explorer window title but noname's snippet works perfect!
Thanks guys!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: TAC109 and 135 guests