我想Position
从中获取当前(进度)属性值,它是特定窗口中的TProgressBar1
子窗口TProgressFrame1
和孙窗口。是 Delphi 中定义的类,是 AutoHotkey 通过自己的“看到”的特定实例。TPanel1
TProgressDlg
TProgressBar
TProgressBar1
HWnd
是否可以TProgressBar1.Position
使用 AutoHotkey 从外部应用程序获取值?
我试过了
; AutoHotkey Version: 1.1.22.07
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
GroupAdd, MyGroup, ahk_exe [partial path of executable], , , ahk_exe explorer.exe ; exclude any explorer windows open to that path.
WinGet, x, List, ahk_group MyGroup
Loop, %x% ; This application has 68-73 windows, most hidden, when it runs
{
this_id := x%A_Index%
WinGetTitle wtit, ahk_id %this_id%
WinGet, clh, ControlListHwnd, ahk_id %this_id% ;%wtit%, %wtxt%
StringSplit, clh_, clh, `n
Loop, %clh_0% ; the 0th entry contains the size of the array this loop iteration. Don't want to loop through all in %clh_ as previous iterations may have stored more values at haven't been cleared.
{
clh_cur := clh_%A_Index%
IfEqual, cl_%A_Index%, TProgressBar1
{
B := cl_%A_Index% ; TProgressBar1
C := %B%.Position ; Expecting something like 60 (percent). I could also divide by %B%.Max to make sure what the range is, assuming I could get values like this.
MsgBox "%B% is %C% percent complete"
}
}
}
return
%C%
结果一片空白,而%B%
实际上TProgressBar1
在原生 Delphi 中,它看起来像(来自这里)
aPB := TProgressBar(FindComponent('Progress')) ;
curValue := aPB.Position
该属性的 Delphi 代码使用文档关联表示类似的东西
curValue := TProgressBar1.Position
会起作用
我是否可以使用类似
ComObjGet
? 或者TProgressBar1.__Get(Position)
? 或者SendMesssage, 0x03E6, clh_%A_Index%, 0x03330600 ;*
?(和/或以上任何一项......)cpy := TProgressBar1.Clone()
第一的?
消息 WM_DDE_请求= 0x03E6的
TProgressBar
值为Properties
Delphi00001514 0x03330600 (53675520)
此后,我尝试了 3 和 4 的一些迭代,但我可能做错了,因为没有证据表明MyMessageMonitor
(下面) 被调用过。以下是我尝试过的:
WM_DDE_INITIATE := 0x3E0
WM_DDE_TERMINATE:= 0x3E1
WM_DDE_ADVISE := 0x3E2
WM_DDE_UNADVISE := 0x3E3
WM_DDE_ACK := 0x3E4
WM_DDE_DATA := 0x3E5
WM_DDE_REQUEST := 0x3E6
WM_DDE_POKE := 0x3E7
WM_DDE_EXECUTE := 0x3E8
OnMessage(0x03E05, "MyMessageMonitor") ; WM_DDE_DATA by MSDN's definition
OnMessage(WM_DDE_DATA, "MyMessageMonitor") ; WM_DDE_DATA there's a post "correcting" MSDN's value at bottom, so may as well look for both
OnMessage(0x03E4, "MyMessageMonitor") ; WM_DDE_ACK
...
; IfEqual block innards
nAppli := DllCall("GlobalAddAtom", "str", [application exe name, minus .exe], "Ushort")
nDDE_Topic := DllCall("GlobalAddAtom", "str", [application exe name, minus .exe], "Ushort")
SendMessage, WM_DDE_INITIATE, A_ScriptHwnd, nAppli | nDDE_Topic << 16,,ahk_id %clh_cur%
B := cl_%A_Index%
Bh := clh_%A_Index%
C := %Bh%.Clone()
D := %C%.__Get("Position")
E := IsObject(%C%)
F := %Bh%["Position"]
SendMessage, 0x03E6, A_ScriptHwnd, 0x03330600, cl_%A_Index%, ahk_id %this_id% ; send WM_DDE_REQUEST from current window to TProgressBar1
MsgBox "%B% has position value %D% or %F%. %B% an object? %E%" ; brings up box with "TProgressBar1 has position value or . TProgressBar1 an object? 0"
DllCall("DeleteAtom", "Ushort", nAppli)
DllCall("DeleteAtom", "Ushort", nDDE_Topic)
...
OnMessage(0x03E05, "")
OnMessage(0x03E5, "") ; WM_DDE_DATA
OnMessage(WM_DDE_ACK, "") ; 0x03E4
return
MyMessageMonitor(wParam, lParam, msg, hwnd)
{
MsgBox "w: " . wParam . " l: " . lParam . " msg: " . msg . " hwnd: " . hwnd
return
}