ControlGetPos BUG

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
andremarasca
Posts: 14
Joined: 21 Oct 2018, 14:52

ControlGetPos BUG

22 Oct 2018, 05:53

[Moderator's note: Topic moved from Bug Reports.]

Hi, I'm having trouble solving a problem with the following code:

Code: Select all

F6::
if WinActive("ahk_class CabinetWClass")
{
	ControlGetPos, x, y, w, h, Edit1, ahk_class CabinetWClass
	MouseClick, Left, x + w, y + h/2, 1, 0
	Sleep, 100
	ControlGetText, OutputVar, Edit1, ahk_class CabinetWClass
	ToolTip, %OutputVar%
	Sleep, 500
	ToolTip
}
return
The ahk_class CabinetWClass refers to explorer.exe, in any folder. The Edit1 is the box that contains the full path to the current directory. I'am just want copy the full path.

The problem is this: The AHK can not find control Edit1 in ahk_class CabinetWClass if I have never clicked on Edit1. That is, if I open a folder and never click Edit1, the AHK can not find Edit1, but if I click at least once on edit1 then the AHK can always find Edit1 until I close all the folders, after that the problem comes back. It seems that AHK loses reference to Edit1.
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: ControlGetPos BUG

22 Oct 2018, 09:30

I don't see an EDIT1 field in windows explorer. Not when it starts, not when I select a file and not even when I choose RENAME (which opens an edit field of sorts).
andremarasca
Posts: 14
Joined: 21 Oct 2018, 14:52

Re: ControlGetPos BUG

22 Oct 2018, 10:52

I solved my problem in another way: https://autohotkey.com/boards/viewtopic ... 76&t=58136

Code: Select all

#IfWinActive, ahk_class CabinetWClass
F6::
	ControlGetText address, ToolbarWindow323, ahk_class CabinetWClass
	address := StrReplace(address, "Endereço: ")
	ToolTip, %address%
	Sleep, 500
	ToolTip
return
#IfWinActive
But still, Edit1 contains bug, can not retrieve text by Control Edit1

Image
Attachments
Edit1.png
(170.15 KiB) Not downloaded yet
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: ControlGetPos BUG

28 Oct 2018, 08:10

I stand corrected. I found the EDIT1 control. But, it appears it only exists after clicking the toolbar that shows one's location. And clicking that toolbar may change one's location.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: ControlGetPos BUG

03 Nov 2018, 01:59

Like joefiesta said, Edit1 does not exist until you have focused the address bar. You can't retrieve information from a control that doesn't exist. This is clearly not a bug.

An external tool such as Spy++ can be used to verify that the control does not exist until you focus the address bar. In fact, the Edit control is part of a ComboBoxEx control.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Decar, doodles333, mikeyww, Tupper and 216 guests