Holen Sie sich den Wert für die `Position`-Eigenschaft aus einer Delphi TProgressBar-Klasseninstanz mit AutoHotkey (ahk).

515
mpag

Ich möchte den aktuellen PositionEigenschaftswert (Fortschritt) von erhalten TProgressBar1, der ein Kind eines TProgressFrame1Enkels und eines Enkels TPanel1innerhalb eines bestimmten TProgressDlgFensters ist. TProgressBarist eine in Delphi definierte Klasse und TProgressBar1ist eine bestimmte Instanz, die AutoHotkey mit seiner eigenen "sieht" HWnd.

Kann man den TProgressBar1.PositionWert mit AutoHotkey aus einer externen Anwendung beziehen?

ich habe es versucht

; 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%kommt leer raus, %B%ist aber in der TatTProgressBar1

Es sieht aus wie in nativen Delphi, dies würde ungefähr so ​​aussehen (von hier )

 aPB := TProgressBar(FindComponent('Progress')) ; curValue := aPB.Position 

Delphi codeusage doc für die Eigenschaft Link zeigt an, dass so etwas
curValue := TProgressBar1.Positionfunktionieren würde,

Benutze ich so etwas

  1. ComObjGet? oder
  2. TProgressBar1.__Get(Position)? oder
  3. SendMesssage, 0x03E6, clh_%A_Index%, 0x03330600 ;*? (und / oder eines der oben genannten mit ...)
  4. cpy := TProgressBar1.Clone() zuerst?

WM_DDE_REQUEST = 0x03E6
TProgressBarhat einen PropertiesWert vonDelphi00001514 0x03330600 (53675520)

Ich habe seither einige Iterationen von 3 und 4 ausprobiert, aber ich mache es vielleicht falsch, da es keinen Hinweis darauf gibt, dass das MyMessageMonitor(unten) jemals aufgerufen wird. Folgendes habe ich ausprobiert:

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 } 
3

0 Antworten auf die Frage