Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2022 in all areas

  1. It depends on how you want to display the progress for example, if you have 5 vbscripts and you want the bar to progress each time the new vbscript is executed you could just place your vbscripts into an array and then upon each execution you progress the bar by 100/arraycount for example: #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Local $aVBExample[] = ["Execute VBScript 1","Execute VBScript 2","Execute VBScript 3","Execute VBScript 4","Execute VBScript 5"] GUICreate("Progressbar1", 220, 40, 100, 200) Local $idProgressbar = GUICtrlCreateProgress(10, 10, 200, 20) GUISetState(@SW_SHOW) Local $iProgress = 100/(UBound($aVBExample)) For $i = 0 To UBound($aVBExample) - 1 $iProgressBar = GUICtrlRead($idProgressbar) + $iProgress GUICtrlSetData($idProgressbar, $iProgressBar) MsgBox(4096, "", $aVBExample[$i], 2) Next If your vbscripts take a long time to complete then would recommend using marquee, otherwise the end user may think the script is frozen, for example: #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Local $aVBExample[] = ["Execute VBScript 1","Execute VBScript 2","Execute VBScript 3","Execute VBScript 4","Execute VBScript 5"] GUICreate("Progressbar2", 220, 40, 100, 200) Local $idProgressbar = GUICtrlCreateProgress(10, 10, 200, 20, $PBS_MARQUEE) GUISetState(@SW_SHOW) GUICtrlSendMsg($idProgressbar, $PBM_SETMARQUEE, 1, 50) For $i = 0 To UBound($aVBExample) - 1 MsgBox(4096, "", $aVBExample[$i], 2) Next
    1 point
  2. Why can't you use _FileListToArrayRec (@ScriptDir & "\Plug-ins", "information.ini", 1, 1, 1, 2) then loop through the results?
    1 point
  3. Hi Parsix, with this fragment it is very hard to understand why it freezes. Can you post the whole code?
    1 point
  4. More work to do means more CPU cycles means longer run time. So i think measuring the time it takes to do the work is a good indicator for efficiency. It is good practice on this forum to post runable examples so people don't have to spend much time to play with your code
    1 point
  5. TheAutomator, No, but using the Au3Stripper utility (which is in the full SciTE4AutoIt3 package) does exactly that if you give it the correct parameters. Keep asking them in this thread. M23
    1 point
  6. Example 1: better to just overwrite (A) the variable (same memory location, so the number of (re)writes doesn't matter). But every extra function call costs performance. Example 2: Fastest evaluation uses Switch, not If/Then/Else, e.g., Switch $b_Input Case True ; do something Case Else ; do something else EndSwitch Example 3: AFAIK, boolean "True" is converted to 1, so "While 1" is marginally faster than "While True".
    1 point
  7. Something like this? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> Global $hGUI = GUICreate("ListView example", 300, 250) Global $progress_width = 100 Global $progress_height = 20 Global $bitmap_path = @ScriptDir & "\Progress\" CreateGdipProgress() Global $hListView = _GUICtrlListView_Create($hGUI, "Progress|Task", 10, 10, 280, 230, $LVS_REPORT, $WS_EX_CLIENTEDGE) Global $ilImageList = _GUIImageList_Create($progress_width, $progress_height, 5, 3) Global $tps_reports[4] = ["TPS Reports", "TPS Reports Started", "TPS Reports Halfway!", "TPS Reports Almost!!!"] _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP)) _GUICtrlListView_SetColumnOrder($hListView, "1|0") _GUICtrlListView_SetColumn($hListView, 0, "Progress", 120) _GUICtrlListView_SetColumn($hListView, 1, "Task", 120) For $i = 0 to 100 _GUIImageList_AddBitmap($ilImageList, $bitmap_path & $i & ".bmp") Next _GUICtrlListView_SetImageList($hListView, $ilImageList, 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 1, 1)) _GUICtrlListView_AddSubItem($hListView, 0, "TPS Reports", 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 100, 1)) _GUICtrlListView_AddSubItem($hListView, 1, "Cat Photos", 1) _GUICtrlListView_AddItem($hListView, "", Random(0, 100, 1)) _GUICtrlListView_AddSubItem($hListView, 2, "Code", 1) GUISetState(@SW_SHOW, $hGUI) For $i = 1 to 3 Sleep(1200) _GUICtrlListView_SetItem($hListView, "", 0, 0, 25 * $i) _GUICtrlListView_SetItem($hListView, $tps_reports[$i], 0, 1) Next Sleep(1000) _GUICtrlListView_SetItem($hListView, "", 0, 0, 0) _GUICtrlListView_SetItem($hListView, "TPS Reports JK :)", 0, 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func CreateGdipProgress() _GDIplus_Startup() Local $hWnd_graphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hWnd_bitmap = _GDIPlus_BitmapCreateFromGraphics($progress_width, $progress_height, $hWnd_graphic) Local $hWnd_gdi_buffer = _GDIPlus_ImageGetGraphicsContext($hWnd_bitmap) Local $hWnd_progress_brush = _GDIPlus_BrushCreateSolid(0xFFCACACA) Local $hWnd_font_family = _GDIPlus_FontFamilyCreate("Segoe UI") Local $hWnd_font = _GDIPlus_FontCreate($hWnd_font_family, 10) Local $hWnd_rect = _GDIPlus_RectFCreate(0, 0, $progress_width, $progress_height) Local $hWnd_string_format = _GDIPlus_StringFormatCreate() Local $hWnd_string_brush = _GDIPlus_BrushCreateSolid(0xFF000000) If (Not FileExists($bitmap_path)) Then DirCreate($bitmap_path) _GDIPlus_StringFormatSetAlign($hWnd_string_format, 1) _GDIPlus_StringFormatSetLineAlign($hWnd_string_format, 1) _GDIPlus_GraphicsSetSmoothingMode($hWnd_bitmap, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($hWnd_graphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) For $i = 0 to 100 If (FileExists($bitmap_path & $i & ".bmp")) Then ContinueLoop _GDIPlus_GraphicsClear($hWnd_gdi_buffer, 0xFFF0F0F0) _GDIPlus_GraphicsFillRect($hWnd_gdi_buffer, 1, 0, ($i / 100) * 98, $progress_height, $hWnd_progress_brush) _GDIPlus_GraphicsDrawRect($hWnd_gdi_buffer, 0, 0, $progress_width - 1, $progress_height - 1) _GDIplus_GraphicsDrawStringEx($hWnd_gdi_buffer, $i & "%", $hWnd_font, $hWnd_rect, $hWnd_string_format, $hWnd_string_brush) _GDIPlus_ImageSaveToFile($hWnd_bitmap, $bitmap_path & $i & ".bmp") Next _GDIPlus_GraphicsDispose($hWnd_graphic) _GDIPlus_BitmapDispose($hWnd_bitmap) _GDIPlus_BrushDispose($hWnd_progress_brush) _GDIPlus_FontFamilyDispose($hWnd_font_family) _GDIPlus_FontDispose($hWnd_Font) _GDIPlus_StringFormatDispose($hWnd_string_format) _GDIPlus_BrushDispose($hWnd_string_brush) _GDIPlus_Shutdown() EndFunc I used GDI+ to create some progress bars since we don't have your images. You could use what is created by the script using GDI+ or have your own images instead (just make sure they're .bmp files). Someone said that you can only have an image in the first column of a listview but _GUICtrlListView_SetColumnOrder will change the order. Technically the images are still in the first column (_GUICtrlListView_SetColumn($hListView, 0, "Progress", 120) changes column 0, but what's displayed in column 0 is the task) but it's just displayed opposite.
    1 point
×
×
  • Create New...