Sign in to follow this  
Followers 0
lhw

Map 7zG progress bar to GUI?

18 posts in this topic

#1 ·  Posted (edited)

How could i map 7ZG progress bar to GUI just like there is no script about this one at the moment,really want to learn

anyone could help on this ,thanks in advance.

Edited by lhw

Share this post


Link to post
Share on other sites



Search for _7zRead UDF!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Search for _7zRead UDF!

Thank you so much,its my 1st progressbar,so happy with that, but i'm still confused with luli's 7ZSFXmaker, its 7zG.exe work at the backgroud,7zG has its own progressbar,how could he use GUI progressbar instead with 7zG progressbar? i also use 7ZG progressbar before use 7zread UDF,

BTW i have a newbie question,whats the right place to hold UDFs? as i use a locale edtion created by some autoit fans in my country,it has two folders INCLUDE and USERINCLUDE ,both work for me,Just want be sure about this, thanks again.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Maybe using something like this >>

BTW i have a newbie question,whats the right place to hold UDFs? as i use a locale edtion created by some autoit fans in my country,it has two folders INCLUDE and USERINCLUDE ,both work for me,Just want be sure about this, thanks again.

Personally I just add the UDF's from Examples to the "Include" folder. But be careful when updating AutoIt in the future! Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Maybe using something like this >> ?do=embed' frameborder='0' data-embedContent>

hi Guinness ,i'm trying to get 7ZG progress bar handle but get nothing( no handle return, no position return )via learning from this ?do=embed' frameborder='0' data-embedContent>

my codes just like below

Run(@ComSpec & ' /c ' & '7zg.exe' & $mk_commandline & '"' & $Target & '"' & ' ' & '"' & $Source & '\*' & '"' & ' -x!Thumbs.db', '', @SW_HIDE)
        $handle = ControlGetHandle ("[CLASS:#32770; INSTANCE:0]", "", "[CLASS:msctls_progress32; INSTANCE:1]")
        ConsoleWrite("Progress bar handle: " & $handle & @CRLF)
        $msg = _SendMessage($handle,$PBM_GETPOS,0,0)
        ConsoleWrite("Position: " & $msg & "%" & @CRLF)
        ..........

need some help on this,thanks

lhw

Edited by lhw

Share this post


Link to post
Share on other sites

I did this after you posted, so it worked back then with 7-Zip 9.20 on Win7 x64 >>

#include <SendMessage.au3>
#include <ProgressConstants.au3>
#include <Array.au3>

Global $iPercentageBefore

While 1
    $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
    $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
    $iPercentage = Round($iMsg / 315)
    If $iPercentage <> $iPercentageBefore Then
        $iPercentageBefore = $iPercentage
        ConsoleWrite("Position: " & $iPercentage & "%" & @CRLF)
    EndIf
    Sleep(20)
WEnd

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I did this after you posted, so it worked back then with 7-Zip 9.20 on Win7 x64 >>

#include <SendMessage.au3>
#include <ProgressConstants.au3>
#include <Array.au3>

Global $iPercentageBefore

While 1
    $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
    $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
    $iPercentage = Round($iMsg / 315)
    If $iPercentage <> $iPercentageBefore Then
        $iPercentageBefore = $iPercentage
        ConsoleWrite("Position: " & $iPercentage & "%" & @CRLF)
    EndIf
    Sleep(20)
WEnd

Share this post


Link to post
Share on other sites

I did this after you posted, so it worked back then with 7-Zip 9.20 on Win7 x64 >>

#include <SendMessage.au3>
#include <ProgressConstants.au3>
#include <Array.au3>

Global $iPercentageBefore

While 1
    $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
    $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
    $iPercentage = Round($iMsg / 315)
    If $iPercentage <> $iPercentageBefore Then
        $iPercentageBefore = $iPercentage
        ConsoleWrite("Position: " & $iPercentage & "%" & @CRLF)
    EndIf
    Sleep(20)
WEnd

it works with 7z921beta under win7x86 , but only cause GUI dead, ill give it further try until move the bar to the GUI, this is cool

have a nice day

lhw:)

Share this post


Link to post
Share on other sites

but only cause GUI dead

Could you explain a little further, I'm not following.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Could you explain a little further, I'm not following.

Solved my fault,thank you so much, now it much colse perfect :unsure: ,and the way also work with 7zg extracting

with the respects to you

lhw

Func MakeData()
    $pid = Run('7zg.exe' & $mk_commandline & '"' & $Target & '"' & ' ' & '"' & $Source & '\*' & '"' & ' -x!Thumbs.db', '', @SW_HIDE); use 'run' without @comspec
 While ProcessExists($pid)
    $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
    $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
    $iPercentage = Round($iMsg /256)
    If $iPercentage <> $iPercentageBefore Then
        $iPercentageBefore = $iPercentage
        ;ConsoleWrite("Position: " & $iPercentage & "%" & @CRLF)
        GUICtrlSetData($MKdataProgress, $iPercentage) ;send the percentage to progressbar on the GUI
    EndIf
    Sleep(20)
WEnd
Msgbox(0, '', 'Successfully!'
EndFunc
Edited by lhw

Share this post


Link to post
Share on other sites

Ah OK. When I tested I ran 7-Zip manually this is why I didn't add any Run() command.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

lhw this is why I did in the end and the Percentage should be a little more accurate >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <SendMessage.au3>
#include <ProgressConstants.au3>

_7Zip_Extract("C:\Example.7z", "C:\Extract", "")

Func _7Zip_Extract($sZipFile, $sDestinationFolder = @ScriptDir, $sPassword = "")
    Local $hHandle, $iMsg, $iPercentage, $iPercentageBefore, $iPID, $s7ZipExe = @ProgramFilesDir & "\7-Zip\7zG.exe"
    If StringRight($sDestinationFolder, 1) <> "\" Then
        $sDestinationFolder &= "\"
    EndIf
    If FileExists($sDestinationFolder) = 0 Then
        DirCreate($sDestinationFolder)
    EndIf
    If $sPassword <> "" Then
        $sPassword = "-p" & '"' & $sPassword & '" '
    EndIf
    $iPID = Run('"' & $s7ZipExe & '" x "' & $sZipFile & '" ' & $sPassword & "-y -o" & '"' & $sDestinationFolder & '"', "", @SW_SHOW)
    While ProcessExists($iPID)
        $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
        $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
        $iPercentage = Round($iMsg / 201.76)
        If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage < 100 Then
            $iPercentageBefore = $iPercentage
            ConsoleWrite("Percentage: " & $iPercentage & "%" & @CRLF)
        EndIf
        Sleep(20)
    WEnd
    Return $iPercentage
EndFunc   ;==>_7Zip_Extract

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

lhw this is why I did in the end and the Percentage should be a little more accurate >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <SendMessage.au3>
#include <ProgressConstants.au3>

_7Zip_Extract("C:\Example.7z", "C:\Extract", "")

Func _7Zip_Extract($sZipFile, $sDestinationFolder = @ScriptDir, $sPassword = "")
    Local $hHandle, $iMsg, $iPercentage, $iPercentageBefore, $iPID, $s7ZipExe = @ProgramFilesDir & "\7-Zip\7zG.exe"
    If StringRight($sDestinationFolder, 1) <> "\" Then
        $sDestinationFolder &= "\"
    EndIf
    If FileExists($sDestinationFolder) = 0 Then
        DirCreate($sDestinationFolder)
    EndIf
    If $sPassword <> "" Then
        $sPassword = "-p" & '"' & $sPassword & '" '
    EndIf
    $iPID = Run('"' & $s7ZipExe & '" x "' & $sZipFile & '" ' & $sPassword & "-y -o" & '"' & $sDestinationFolder & '"', "", @SW_SHOW)
    While ProcessExists($iPID)
        $hHandle = ControlGetHandle(WinGetTitle("[CLASS:#32770]"), "", "[CLASS:msctls_progress32; INSTANCE:1]")
        $iMsg = _SendMessage($hHandle, $PBM_GETPOS, 0, 0)
        $iPercentage = Round($iMsg / 201.76)
        If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage < 100 Then
            $iPercentageBefore = $iPercentage
            ConsoleWrite("Percentage: " & $iPercentage & "%" & @CRLF)
        EndIf
        Sleep(20)
    WEnd
    Return $iPercentage
EndFunc   ;==>_7Zip_Extract

Thank you Guiness,will improve my codes with yours and how did you guess out there is a 7zip unpacker on my GUI :>

i also got a little problem about this that ControlGetHandle wont work if exist another window with the same class name,

eg. Internet Download Manager,i checked the main program IDM.exe via Autoit windows info tool, IDM.EXE has the same name class 'class:#23770', i gusess thats why ControlGetHandle wont work unless kill idm.exe from process list,is there a trick than can avoid this :unsure:

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Well, since yesterday I have been having a little play around with these Functions today and decided that the _SendMessage() to find the position of the ProgressBar was a little unreliable. I decided to therefore capture the Window Title e.g. 10% C:\Test.zip and then use a SRE to get the Percentage i.e. 10.

Also you can get the Window Handle using the PID, so this should solve the problem with Internet Download Manager. Have a look at the revised code >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

_7Zip_Extract("C:\Example.7z", "C:\Extract\", "")

Func _7Zip_Extract($sZipFile, $sDestination, $sPassword = "")
    Local $aPercentage, $hHandle, $iPercentage = 0, $iPercentageBefore, $iPID, $s7ZipExe = @ProgramFilesDir & "\7-Zip\7zG.exe"

    $iPID = Run('"' & $s7ZipExe & '" x "' & $sZipFile & '" ' & $sPassword & "-y -o" & '"' & $sDestination & '"', "", @SW_SHOW)
    Sleep(500) ; I don't know why but a Sleep() has to be there for the 7-Zip Handle to be found.
    $hHandle = _WinGetHandleByPID($iPID)

    While ProcessExists($iPID)
        $aPercentage = StringRegExp(WinGetTitle($hHandle), '(?s)(?i)\A(.*?)%', 3)
        If @error = 0 Then
            $iPercentage = $aPercentage[0]
        EndIf
        If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage < 100 Then
            $iPercentageBefore = $iPercentage
            ConsoleWrite("Percentage: " & $iPercentage & "%" & @CRLF)
        EndIf
        Sleep(20)
    WEnd
    Return $iPercentage
EndFunc   ;==>_7Zip_Extract

Func _WinGetHandleByPID($iPID, $iReturnArray = 0, $iVisibleOnly = 1) ; Taken From: http://www.autoitscript.com/forum/topic/126406-disable-red-x/page__view__findpost__p__877649 And By SmOke_N
    If IsInt($iPID) = 0 Then
        $iPID = ProcessExists($iPID)
    EndIf

    Local $aWinList = WinList()
    Local $aReturn[$aWinList[0][0] + 1], $iAdd

    For $A = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$A][1]) = $iPID Then
            If $iVisibleOnly Then
                If BitAND(WinGetState($aWinList[$A][1]), 2) Then
                    If $iReturnArray = 0 Then
                        Return $aWinList[$A][1]
                    EndIf
                    $iAdd += 1
                    $aReturn[$iAdd] = $aWinList[$A][1]
                EndIf
            Else
                If $iReturnArray = 0 Then
                    Return $aWinList[$A][1]
                EndIf
                $iAdd += 1
                $aReturn[$iAdd] = $aWinList[$A][1]
            EndIf
        EndIf
    Next
    If Not $iAdd Then
        Return SetError(1, 0, -1)
    EndIf
    ReDim $aReturn[$iAdd + 1]
    $aReturn[0] = $iAdd
    Return $aReturn
EndFunc   ;==>_WinGetHandleByPID

Thank you Guiness,will improve my codes with yours and how did you guess out there is a 7zip unpacker on my GUI

You're Welcome! And it's guinness :unsure: but I don't mind. I hope this code works for you. Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Well, since yesterday I have been having a little play around with these Functions today and decided that the _SendMessage() to find the position of the ProgressBar was a little unreliable. I decided to therefore capture the Window Title e.g. 10% C:\Test.zip and then use a SRE to get the Percentage i.e. 10.

Also you can get the Window Handle using the PID, so this should solve the problem with Internet Download Manager. Have a look at the revised code >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

_7Zip_Extract("C:\Example.7z", "C:\Extract\", "")

Func _7Zip_Extract($sZipFile, $sDestination, $sPassword = "")
    Local $aPercentage, $hHandle, $iPercentage = 0, $iPercentageBefore, $iPID, $s7ZipExe = @ProgramFilesDir & "\7-Zip\7zG.exe"

    $iPID = Run('"' & $s7ZipExe & '" x "' & $sZipFile & '" ' & $sPassword & "-y -o" & '"' & $sDestination & '"', "", @SW_SHOW)
    Sleep(500) ; I don't know why but a Sleep() has to be there for the 7-Zip Handle to be found.
    $hHandle = _WinGetHandleByPID($iPID)

    While ProcessExists($iPID)
        $aPercentage = StringRegExp(WinGetTitle($hHandle), '(?s)(?i)\A(.*?)%', 3)
        If @error = 0 Then
            $iPercentage = $aPercentage[0]
        EndIf
        If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage < 100 Then
            $iPercentageBefore = $iPercentage
            ConsoleWrite("Percentage: " & $iPercentage & "%" & @CRLF)
        EndIf
        Sleep(20)
    WEnd
    Return $iPercentage
EndFunc   ;==>_7Zip_Extract

Func _WinGetHandleByPID($iPID, $iReturnArray = 0, $iVisibleOnly = 1) ; Taken From: http://www.autoitscript.com/forum/topic/126406-disable-red-x/page__view__findpost__p__877649 And By SmOke_N
    If IsInt($iPID) = 0 Then
        $iPID = ProcessExists($iPID)
    EndIf

    Local $aWinList = WinList()
    Local $aReturn[$aWinList[0][0] + 1], $iAdd

    For $A = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$A][1]) = $iPID Then
            If $iVisibleOnly Then
                If BitAND(WinGetState($aWinList[$A][1]), 2) Then
                    If $iReturnArray = 0 Then
                        Return $aWinList[$A][1]
                    EndIf
                    $iAdd += 1
                    $aReturn[$iAdd] = $aWinList[$A][1]
                EndIf
            Else
                If $iReturnArray = 0 Then
                    Return $aWinList[$A][1]
                EndIf
                $iAdd += 1
                $aReturn[$iAdd] = $aWinList[$A][1]
            EndIf
        EndIf
    Next
    If Not $iAdd Then
        Return SetError(1, 0, -1)
    EndIf
    ReDim $aReturn[$iAdd + 1]
    $aReturn[0] = $iAdd
    Return $aReturn
EndFunc   ;==>_WinGetHandleByPID

You're Welcome! And it's guinness ;) but I don't mind. I hope this code works for you.

Sorry for my typo, already tried this,its only got 1-2 data during extracting and got nothing during compressing

i have hooked up with progressbar for a couple of days without a perfect solution untill i use ProcessGetStats two days ago

here is an eaxmple scripts for testing 7zG extracting and compressing included a function heavily based on yours, honestly this should be my first function as i just found i wrote too much fake function :>

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
GUICreate("ProgressBar tEST", 220, 100)
$progressbar = GUICtrlCreateProgress(10, 10, 200, 20)
$btn = GUICtrlCreateButton("do", 140, 70, 70, 20)   
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            $ExtrTarget = 'C:\data'
            $ExtrSource = 'C:\test.7z'
            $UnPack_line = ' x -y -o' & '"'& $ExtrTarget & '"' & ' ' & '"'& $ExtrSource & '"'
            $PackSource = 'C:\data'
            $PackTarget = 'C:\test.7z'
            $Pack_line = ' a -t7z -mx=9 ' & '"'& $PackTarget & '"' & ' ' & '"'& $PackSource & '"' & '\*'
            _GetPIODataSend2Bar('7zg.exe', $Pack_line, DirGetSize('C:\data'), $progressbar);;;for testing 7z pack
            ;_GetPIODataSend2Bar('7zg.exe', $UnPack_line, FileGetSize('C:\test.7z'), $progressbar);;;for testing 7z unpack
            GUICtrlSetData($progressbar, 100)
            MsgBox(0, '', 'Successfully')
            GUICtrlSetData($progressbar, 0)
    EndSwitch
WEnd

Func _GetPIODataSend2Bar($Execute, $Commandline, $Param, $Ctrl)
    Local $Pid, $PIOData, $iPercentage, $iPercentageBefore
    $Pid = Run ($Execute & $Commandline, '', @SW_HIDE)
    While ProcessExists($Pid)
        $PIOData = ProcessGetStats($Execute, 1)
        If @error Then 
           MsgBox(0, '', 'Cant get I/O info from current process')
        Else
            $iPercentage = Round($PIOData[3]/$Param*100)
            If $iPercentage <> $iPercentageBefore And $iPercentage > 0 And $iPercentage <= 100 Then
               ConsoleWrite('->-' & $iPercentage & @CRLF)
               GUICtrlSetData($Ctrl , $iPercentage)
            EndIf
        EndIf
    WEnd
    Return $iPercentage
EndFunc

i had to say 'ProcessGetStas' is pretty cool,already tried 7zg, 7z, 7za,mkisofs,readcd with it, now i got a perfect progressbar :unsure:

Edited by lhw

Share this post


Link to post
Share on other sites

Nice I have never used ProcessGetStats, will have a look as well.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Nice I have never used ProcessGetStats, will have a look as well.

so far i found

$array[3] get how much bytes read from source during the process

$array[4] get how much bytes wrtitten to target

not sure understand 0,1,2,5

Share this post


Link to post
Share on other sites

I am also in need of progressbar while 7zip extract archives. I tried the code posted here. It works but the progress reaches 100% even when actual extraction is taking place.

Any help?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0