ControlGetPos problems Topic is solved

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

ControlGetPos problems

21 Oct 2018, 15:20

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, can anyone help me with this?
andremarasca
Posts: 14
Joined: 21 Oct 2018, 14:52

Re: ControlGetPos problems

22 Oct 2018, 04:22

I forgot to mention: My S.O. is the windows 10 and my ahk version is the v1.1.30.00
andremarasca
Posts: 14
Joined: 21 Oct 2018, 14:52

Re: ControlGetPos problems

22 Oct 2018, 07:20

I was able to solve the problem in a different way, first I used the code in: https://autohotkey.com/docs/commands/ControlGetPos.htm

Code: Select all

F7::
Loop
{
    Sleep, 100
    MouseGetPos, , , WhichWindow, WhichControl
    ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow%
    ToolTip, %WhichControl%`nX%X%`tY%Y%`nW%W%`t%H%
    Clipboard = %WhichControl%
}
return
And I discovered another name for Edit1 that is: ToolbarWindow323

Finally, I arranged the code:

Code: Select all

F6::
if WinActive("ahk_class CabinetWClass")
{
	ControlGetPos, x, y, w, h, ToolbarWindow323, ahk_class CabinetWClass
	MouseClick, Left, x + 0.95 * w, y + h/2, 1, 0
	Sleep, 100
	ControlGetText, OutputVar, Edit1, ahk_class CabinetWClass
	ToolTip, %OutputVar%
	Sleep, 500
	ToolTip
}
return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: ControlGetPos problems  Topic is solved

22 Oct 2018, 07:36

without hijacking the mouse:

Code: Select all

#If WinActive("ahk_class CabinetWClass")
F6::
	ControlGetText address, ToolbarWindow323, ahk_class CabinetWClass
	address := StrReplace(address, "Address: ")
	MsgBox % address
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 56 guests