MariusN Posted November 25, 2011 Share Posted November 25, 2011 Am i doing this correct? Seems like the "bar" takes forever to complete... (I'm using "GUICtrlCreateProgress" b.t.w ) For $I = 0 To 100 Step 25 GUICtrlSetData($pb, $I) RunWait('TAKEOWN /f ' & '"' & $Select0 & '"' & ' /r /d y', "", @SW_HIDE) Next PS: If i do a straight RunWait('TAKEOWN /f ' & '"' & $Select0 & '"' & ' /r /d y') ......it takes about half the time to finish... thank folks... Link to comment Share on other sites More sharing options...
KaFu Posted November 25, 2011 Share Posted November 25, 2011 (edited) Runwait() waits for the run to complete. What you do in the loop above is to run it 4 times. If the takeown program returns progress data to the console you could read the stdout stream, but as not many console programs do this there is just no way to estimate the overall runtime. As a workaround create the progres control with the $PBS_MARQUEE flag set to indicate that something is happening, here's a piece of pseudo-code: #include <SENDMESSAGE.AU3> $c_Progress = GUICtrlCreateProgress(9, 35, 340, 17, $PBS_MARQUEE) $h_Progress = GUICtrlGetHandle($c_Progress) _SendMessage($h_Progress, $PBM_SETMARQUEE, True, 0) RunWait('TAKEOWN /f ' & '"' & $Select0 & '"' & ' /r /d y', "", @SW_HIDE) _SendMessage($h_Progress, $PBM_SETMARQUEE, False, 0) Edited November 25, 2011 by KaFu MariusN 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MariusN Posted November 25, 2011 Author Share Posted November 25, 2011 Runwait() waits for the run to complete. What you do in the loop above is to run it 4 times. If the takeown program returns progress data to the console you could read the stdout stream, but as not many console programs do this there is just no way to estimate the overall runtime. As a workaround create the progres control with the $PBS_MARQUEE flag set to indicate that something is happening, here's a piece of pseudo-code: #include <SENDMESSAGE.AU3> $c_Progress = GUICtrlCreateProgress(9, 35, 340, 17, $PBS_MARQUEE) $h_Progress = GUICtrlGetHandle($c_Progress) _SendMessage($h_Progress, $PBM_SETMARQUEE, True, 0) RunWait('TAKEOWN /f ' & '"' & $Select0 & '"' & ' /r /d y', "", @SW_HIDE) _SendMessage($h_Progress, $PBM_SETMARQUEE, False, 0) Thx KaFu...will def look into this. I had the same idea with the "stdout"....tried it, but didnt work with "takeown.exe" from Win7... Link to comment Share on other sites More sharing options...
MariusN Posted November 25, 2011 Author Share Posted November 25, 2011 Quite a fancy "move" you got there I used your code and also changed "(@SW_HIDE)" to @SW-Disable....works like a charm ...thx KaFu Link to comment Share on other sites More sharing options...
MariusN Posted November 26, 2011 Author Share Posted November 26, 2011 (edited) I'm still having trouble with long "progress bars"...This is my current code. believe that a command gets excecuted 4x when using GUICtrlCreateProgress,is there a way around it? Some kind of "if then" or something? Any ideas would be apreciated folks...This is my current code --->For $I = 0 To 100 Step 10 GUICtrlSetData($pb, $I) $copy = DirCopy($Select1, @HomeDrive & "" & "Junk", 1) Next Edited November 26, 2011 by MariusN Link to comment Share on other sites More sharing options...
KaFu Posted November 26, 2011 Share Posted November 26, 2011 (edited) DirCopy() is a blocking function, it returns only when the copy operation has finished 100% (or failed ).If you want to implement progress feedback you'll have to do it on your own. Melba23's excellent comes in handy there ...#include <guiconstantsex.au3> #include <progressconstants.au3> ; #include <array.au3> #include <recfilelisttoarray.au3> GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar = GUICtrlCreateProgress(10, 30, 200, 20) GUICtrlSetColor(-1, 32250); not working with Windows XP Style $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() Do $msg = GUIGetMsg() If $msg = $button Then GUICtrlSetData($button, "Stop") $a_Files = _RecFileListToArray(@WindowsDir & "Help", "*", 1, 1, 0, 1) ; _ArrayDisplay($a_Files) For $i = 1 To $a_Files[0] GUICtrlSetData($progressbar, ($i / $a_Files[0])*100) FileCopy(@WindowsDir & "Help" & $a_Files[$i], @ScriptDir & "Help" & $a_Files[$i], 9) Next GUICtrlSetData($button, "Start") EndIf Until $msg = $GUI_EVENT_CLOSE Edited November 26, 2011 by KaFu MariusN 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
MariusN Posted November 26, 2011 Author Share Posted November 26, 2011 Holly Macaroni...Do I still have a lot to learn...thx KaFu Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now