Что нового

отображение Progress Bar'а при запуске скрипта

Maxlinus

Новичок
Сообщения
40
Репутация
1
есть скрипт который запускается не очень быстро, в нем присутствует распаковка файлов и на появление окна программы уходит некоторое время, соответственно на разных пк по разному.

подскажите как сделать отображение Progress Bar'а на загрузку программы.
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
Maxlinus
если это управляемая распаковка, то может быть есть возможность ее отобразить в окне. как в случае с UDF 7z.
если fileinstall, то раскинь проценты на каждый извлекаемый элемент.
так что за метод распаковки?
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
Maxlinus
сколько файлов? каков размер каждого?может лучше использовать 7z udf?
если код не секретный, выложи его.
 
A

Alofa

Гость
Maxlinus наверно логичнее вам будет создать некий ProgressBar ожидания, к примеру такой:
Код:
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

Local $iSleep = 20, $iWidth = 250, $iHeight = 25
Local $hGUI = GUICreate('', $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Local $ProgressBar = GUICtrlCreateProgress(0, 0, $iWidth, $iHeight, $PBS_MARQUEE)
GUISetState()
GUIRegisterMsg($WM_TIMER, "PlayProgressBar")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)

; ...
Sleep(5000) ; Здесь работает фукция "FileInstall()"
; ...
GUIRegisterMsg($WM_TIMER, '')

; ... Продолжение кода скрипта

Func PlayProgressBar()
	GUICtrlSetData($ProgressBar, 0)
EndFunc   ;==>PlayProgressBar

... но если хотите чего-нибудь по красивее, тогда:
https://www.autoitscript.com/forum/topic/150545-gdi-animated-loading-screens-build-2014-06-20-32-examples/
 
Автор
M

Maxlinus

Новичок
Сообщения
40
Репутация
1
код не секретный , это переделаный немного ChunkVNC

Код:
#AutoIt3Wrapper_Run_Obfuscator=Y
#Obfuscator_Parameters=/StripOnly

; #RequireAdmin

; Disable the scripts ability to pause.
Break(0)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ServiceControl.au3>
#include <ScreenCapture.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <WinAPIEx.au3>

; Exit if the script hasn't been compiled
If Not @Compiled Then
	MsgBox(0, "ERROR", 'Script must be compiled before running!', 5)
	Exit
EndIf


Dim $File_Location2 = @ProgramFilesDir & "\InstantSupport\instantsupport.ini"


; Language strings.
$str_Program_Title = 					"HELPDESK"
$str_Button_InstallService = 			"Установить как службу"
$str_Button_Exit =						"Выход"
$str_MsgBox_Information = 				"Информация"
$str_MsgBox_ExitInstantSupport = 		"Вы действиетльного хотите выйти"
$str_MsgBox_ServiceInstallation = 		"Установка службы"
$str_MsgBox_Error =						"Error"
$str_MsgBox_RemoveService =				"Удалить службу и программу?"
$str_ServiceEnterAnIDNumber = 			"Введеите новый ID или оставьте предложенный:"
$str_ServiceInvalidID = 				"Invalid ID entered, установка службы отменена."
$str_ServiceProxy =						"Service installation not supported when using HTTP Proxy."
$str_ErrorInstallService =				"Installing service requires administrator privileges."
$str_ErrorStopService =					"Stopping VNC services requires administrator privileges."
$str_ErrorUnknownCommand =				"Unknown command."
$str_ErrorRepeaterConnectionFailed = 	"Нет соединения с сервером. Возможно проблемы с интернетом"
$str_EndSupportSession =				"Вы действительно хотите выйти?"
$str_CloseOtherVNCServers =				"На компьютере обнаружен другой запущенный VNC сервер, для продолжения он будет закрыт. Продолжить?"
;$str_CloseOtherVNCServers =				"Another VNC server is running which must be stopped. Try to stop other VNC server?"
$str_ver = "STARTv1.08c.exe"

; Global Vars.
Global $ExtractFiles = True
Global $GenerateID = True
Global $LanMode = False
Global $IDNumber = 123456
Global $WorkingPath = @AppDataDir & "\InstantSupport_Temp_Files"

Global $ProxyEnabled = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable")

; Create unique working path if our default directory already exists. (Possible InstantSupport is already running)
If FileExists( @AppDataDir & "\InstantSupport_Temp_Files" ) Then
	$WorkingPath = @AppDataDir & "\InstantSupport_Temp_Files_" & Random( 100000, 999999,1 )
EndIf


; Command line args.
If $cmdline[0] > 0 Then
	Switch $cmdline[1]

		Case "-installservice"
			If IsAdmin() Then

				InstallService()
				Exit

			Else

				MsgBox( 0, $str_MsgBox_Error, $str_ErrorInstallService, 30 )
				Exit

			EndIf

		Case "-removeservice"
			If IsAdmin() Then

				RemoveService()
				Exit

			Else
				; Elevate to admin to remove.
				ShellExecuteWait( @ScriptFullPath, "-removeservice", @ScriptDir, "runas")
				Exit

			EndIf

		Case "-stopservices"
			If IsAdmin() Then

				StopServices()
				Exit

			Else

				MsgBox( 0, $str_MsgBox_Error, $str_ErrorStopService, 30 )
				Exit

			EndIf

		Case Else
			MsgBox( 0 , $str_MsgBox_Error, $str_ErrorUnknownCommand, 30 )
			Exit

	EndSwitch
EndIf


; Extract files.
If $ExtractFiles Then

	DirCreate( $WorkingPath )

	FileInstall( "InstantSupport_Files\instantsupport.ini", $WorkingPath & "\instantsupport.ini", 1 )
	FileInstall( "InstantSupport_Files\logo.jpg", $WorkingPath & "\logo.jpg", 1 )
	FileInstall( "InstantSupport_Files\SecureVNCPlugin.dsm", $WorkingPath & "\SecureVNCPlugin.dsm", 1 )
	FileInstall( "InstantSupport_Files\ultravnc.ini", $WorkingPath & "\ultravnc.ini", 1 )
	FileInstall( "InstantSupport_Files\winvnc.exe", $WorkingPath & "\InstantSupportVNC.exe", 1 )
	FileInstall( "InstantSupport_Files\vnc_drv.exe", $WorkingPath & "\vnc_drv.exe", 1 )
	FileInstall( "InstantSupport_Files\helpdesk_fixkey.exe", $WorkingPath & "\helpdesk_fixkey.exe", 1 )
	


	; Unblock InstantSupport.exe to prevent "Windows Security" messages.
	;ShellExecuteWait($WorkingPath & "\unblock.js", "", @ScriptDir, "")

	FileCopy( @ScriptDir & "\" & @ScriptName, $WorkingPath & "\InstantSupport.exe", 9 )

EndIf
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
Код:
If $ExtractFiles Then
	DirCreate($WorkingPath)
	ProgressOn('Подготовка', 'Распаковка ресурсов')
	ProgressSet(5)
	FileInstall("InstantSupport_Files\instantsupport.ini", $WorkingPath & "\instantsupport.ini", 1)
	ProgressSet(14)
	FileInstall("InstantSupport_Files\logo.jpg", $WorkingPath & "\logo.jpg", 1)
	ProgressSet(28)
	FileInstall("InstantSupport_Files\SecureVNCPlugin.dsm", $WorkingPath & "\SecureVNCPlugin.dsm", 1)
	ProgressSet(42)
	FileInstall("InstantSupport_Files\ultravnc.ini", $WorkingPath & "\ultravnc.ini", 1)
	ProgressSet(56)
	FileInstall("InstantSupport_Files\winvnc.exe", $WorkingPath & "\InstantSupportVNC.exe", 1)
	ProgressSet(70)
	FileInstall("InstantSupport_Files\vnc_drv.exe", $WorkingPath & "\vnc_drv.exe", 1)
	ProgressSet(84)
	FileInstall("InstantSupport_Files\helpdesk_fixkey.exe", $WorkingPath & "\helpdesk_fixkey.exe", 1)
	ProgressSet(95)
	FileCopy(@ScriptDir & "\" & @ScriptName, $WorkingPath & "\InstantSupport.exe", 9)
	ProgressSet(100)
	Sleep(500)
	ProgressOff()
EndIf
 
Верх