How to get status of a button in a window
How to get status of a button in a window
I have a window where I have clicked a button. The processing time of the action behind this button is variable (from a few seconds to a few minutes depending on the data its dealing with). I want to check the status of the button from when it reverts from "greyed out" back to being in a state where it can be pressed again. How can I do this?. I am assuming I have to use the GuiControl calls but would be grateful if someone could point me to some code fragments as to how to get the HWND of the window button and then how to check its state. Thanks.
Re: How to get status of a button in a window
I wrote a little code as follows
Debug returns
For 659106 ControlGetEnabled is 1
Array Length is 0
The number 659106 is the same as Window Spy so its getting the correct window, but the array of controls being returned is 0.
Does that mean I cannot access the button status on this window?
Code: Select all
Hwnd := WinExist("Historical Data")
if Hwnd {
IsEnabled := ControlGetEnabled(Hwnd)
OutputDebug "For " Hwnd " ControlGetEnabled is " IsEnabled "`n"
Controls := WinGetControls("Historical Data")
OutputDebug "Array Length is " Controls.length "`n"
for n in Controls
OutputDebug "Controls are " n "`n"
}
else {
OutputDebug "No Hwnd `n"
}
For 659106 ControlGetEnabled is 1
Array Length is 0
The number 659106 is the same as Window Spy so its getting the correct window, but the array of controls being returned is 0.
Does that mean I cannot access the button status on this window?
Re: How to get status of a button in a window
My amended test harness is as follows:
It returns
For Historical Data, the Hwnd is 659106 and ControlGetEnabled is 1
The Controls array length is 0
Does this mean there are no controls that can be accessed by AutoHotKey.
(BTW, If I run this test harness on Notepad or Windows Explorer I do get names of controls)
Code: Select all
WindowName := "Historical Data"
Hwnd := WinExist(WindowName)
if Hwnd {
OutputDebug "For " WindowName ", the Hwnd is " Hwnd " and ControlGetEnabled is " ControlGetEnabled(Hwnd) "`n"
Controls := WinGetControls(WindowName)
OutputDebug "The Controls array length is " Controls.length "`n"
for n in Controls
OutputDebug "Controls are " n "`n"
}
else {
OutputDebug "For " WindowName ", no Hwnd found`n"
}
For Historical Data, the Hwnd is 659106 and ControlGetEnabled is 1
The Controls array length is 0
Does this mean there are no controls that can be accessed by AutoHotKey.
(BTW, If I run this test harness on Notepad or Windows Explorer I do get names of controls)
Re: How to get status of a button in a window
It is possible. An alternative could be UI Automation, detailed on the forum.