#include <ProgressConstants.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Memory.au3>
Opt("WinTitleMatchMode", -2)
Opt("TrayAutoPause", 0)
Global $hLastWnd
Global Const $tagPBRANGE = "int iLow;int iHigh"
Global $hProgress, $iTemp, $iCurr
While Sleep(10)
$hProgress = ControlGetHandle(" - ABoo", "", "[CLASS:TProgressBar; INSTANCE:1]")
If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "Пример", "Окно не найдено")
$iTemp = _GUICtrlProgress_GetPercent($hProgress)
If $iTemp <> $iCurr Then
$iCurr = $iTemp
TrayTip("Пример", $iCurr & "%", 10, $TIP_ICONASTERISK)
EndIf
WEnd
Func _GUICtrlProgress_GetPercent($hWnd)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
Local $aRange = _GUICtrlProgress_GetRange($hWnd)
Local $iPerc = ($aRange[0] + $aRange[1]) / 100
Return Int(_GUICtrlProgress_GetPos($hWnd) / $iPerc)
EndFunc ;==>_GUICtrlProgress_GetPercent
Func _GUICtrlProgress_GetPos($hWnd)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
Local $iRet = _SendMessage($hWnd, $PBM_GETPOS, 0, 0, 0, "wparam", "lparam", "uint")
Return SetError(@error, @extended, $iRet)
EndFunc ;==>_GUICtrlProgress_GetPos
Func _GUICtrlProgress_GetRange($hWnd)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
Local $tPBRANGE = DllStructCreate($tagPBRANGE)
If _WinAPI_InProcess($hWnd, $hLastWnd) Then
_SendMessage($hWnd, $PBM_GETRANGE, False, $tPBRANGE, 0, "wparam", "struct*")
Else
Local $iSize = DllStructGetSize($tPBRANGE), $tMemMap
Local $pMemory = _MemInit($hWnd, $iSize, $tMemMap)
_SendMessage($hWnd, $PBM_GETRANGE, False, $pMemory, 0, "wparam", "ptr")
_MemRead($tMemMap, $pMemory, $tPBRANGE, $iSize)
_MemFree($tMemMap)
EndIf
Local $aRet[2] = [DllStructGetData($tPBRANGE, "iLow"), DllStructGetData($tPBRANGE, "iHigh")]
Return SetError(@error, @extended, $aRet)
EndFunc ;==>_GUICtrlProgress_GetRange