Atakanbasturk Posted February 1, 2020 Posted February 1, 2020 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <StringConstants.au3> #include <Math.au3> Update() Func Update() GUISetState(@SW_SHOW) $AboutGUI = GUICreate("K-Lite Mega Codec Pack", 250, 170) $Iconfile = (@ScriptDir & "\icon.ico") GuiSetIcon($Iconfile) $Download = GUICtrlCreateButton("İNDİR", 10, 90, 50, 25, $WS_GROUP) $Kaldir = GUICtrlCreateButton("KALDIR", 100, 90, 50, 25, $WS_GROUP) $OK = GUICtrlCreateButton("KAPAT", 190, 90, 50, 25, $WS_GROUP) $label1 = GUICtrlCreateLabel("Yüklü Sürüm:", 10, 12, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label2 = GUICtrlCreateLabel("Güncel Sürüm:", 10, 37, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label4 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 12, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label4, $color_maroon) $label5 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 37, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label5, $color_maroon) $label6 = GUICtrlCreateLabel("Dosya Boyutu:", 10, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label6, $color_black) $label7 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label7, $color_maroon) $label8 = GUICtrlCreateLabel("MB", 145, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label8, $color_black) $data = InetRead("https://www.free-codecs.com/download_soft.php?d=b266a17c71a7b5ff7882b40e6c935a23&s=42&r=&f=k_lite_mega_codec_pack.htm") $iBytesRead = @extended $byte = Round($iBytesRead/1048576, 2) $Sversion = FileGetVersion($data) If FileExists(@ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe") Then $dosyayolu = @ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe" $version = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\KLiteCodecPack_is1", "DisplayVersion") GUICtrlSetData($label4, $version) GUICtrlSetColor($label4, $color_green) Else GUICtrlSetData($label4, "Yüklü Değil") GUICtrlSetColor($label4, $color_red) EndIf If $data Then GUICtrlSetData($label7, $byte) GUICtrlSetColor($label7, $color_green) GUICtrlSetData($label5, $Sversion) GUICtrlSetColor($label5, $color_blue) EndIf GUISetState() While 1 Switch GUIGetMsg() Case -3 GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $OK GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $Kaldir Run($dosyayolu) Case $Download $_DownloadPercent=0 $_ProgressBar = GUICtrlCreateProgress ( 10, 125, 200, 20 ) $_Label = GUICtrlCreateLabel ($_DownloadPercent & ' %', 215, 128, 40,20 ) GUISetState ( @SW_SHOW ) $_FinalUrl = 'https://www.free-codecs.com/download_soft.php?d=b266a17c71a7b5ff7882b40e6c935a23&s=42&r=&f=k_lite_mega_codec_pack.htm' $_TempPath = @DesktopDir & "\test.exe" $_FileSize = InetGetSize ( $_FinalUrl ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do Sleep ( 500 ) $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 100 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) GUICtrlSetData ( $_Label, $_DownloadPercent & ' %') EndIf Until $_InfoData[2] = True $label9 = GUICtrlCreateLabel ( 'İndirme Tamamlandı !', 10, 150, 350, 20 ) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label9, $color_black) EndSwitch WEnd EndFunc My point is, showing K-lite Mega Codec Pack version on any computer, checking program's web site in background and showing latest exe's version number, exe's size and downloading latest version with progress bar. I can get file size from link, but I can't get file version. I read many post about getting file version from links but I can't solve the problem. I want to find file version in GUI without download file to anywhere. Sorry, for Turkish parts. I can translate if you want. Edited February 1, 2020 by Atakanbasturk Code updated.
Nine Posted February 1, 2020 Posted February 1, 2020 It is normal that it doesn't work. FileGetVersion requires a filename. You provide $data (the result of InetRead) which is a binaryString representing content of the download. Very far from a filename. Since you are downloading the file already, use InetGet, save the file into a temporary folder, get the file version. If user choose to DOWNLOAD it, just install it, you have the file locally then. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Atakanbasturk Posted February 2, 2020 Author Posted February 2, 2020 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <StringConstants.au3> #include <Math.au3> GUISetState(@SW_SHOW) $AboutGUI = GUICreate("K-Lite Mega Codec Pack", 250, 170) $Iconfile = (@ScriptDir & "\icon.ico") GuiSetIcon($Iconfile) $Download = GUICtrlCreateButton("İNDİR", 10, 90, 50, 25, $WS_GROUP) $Kaldir = GUICtrlCreateButton("KALDIR", 100, 90, 50, 25, $WS_GROUP) $OK = GUICtrlCreateButton("KAPAT", 190, 90, 50, 25, $WS_GROUP) $label1 = GUICtrlCreateLabel("Yüklü Sürüm:", 10, 12, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label2 = GUICtrlCreateLabel("Güncel Sürüm:", 10, 37, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label4 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 12, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label4, $color_maroon) $label5 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 37, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label5, $color_maroon) $label6 = GUICtrlCreateLabel("Dosya Boyutu:", 10, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label6, $color_black) $label7 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label7, $color_maroon) $label8 = GUICtrlCreateLabel("MB", 145, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label8, $color_black) $data = InetRead("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm") $iBytesRead = @extended $byte = Round($iBytesRead/1048576, 2) $sFilePath = (@TempDir & "\test.exe") $hDownload = InetGet("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm", $sFilePath,1,1) Sleep(500) InetClose($hDownload) $Sversion = FileGetVersion($sFilePath, ("ProductVersion")) GUICtrlSetData($label5, $Sversion) GUICtrlSetColor($label5, $color_blue) If FileExists(@ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe") Then $dosyayolu = @ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe" $version = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\KLiteCodecPack_is1", "DisplayVersion") GUICtrlSetData($label4, $version) GUICtrlSetColor($label4, $color_green) Else GUICtrlSetData($label4, "Yüklü Değil") GUICtrlSetColor($label4, $color_red) EndIf If $data Then GUICtrlSetData($label7, $byte) GUICtrlSetColor($label7, $color_green) EndIf GUISetState() While 1 Switch GUIGetMsg() Case -3 GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $OK GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $Kaldir Run($dosyayolu) Case $Download $_DownloadPercent=0 $_ProgressBar = GUICtrlCreateProgress ( 10, 125, 200, 20 ) $_Label = GUICtrlCreateLabel ($_DownloadPercent & ' %', 215, 128, 40,20 ) GUISetState ( @SW_SHOW ) $_FinalUrl = 'https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm' $_TempPath = @DesktopDir & "\K-lite Mega Codec Pack.exe" $_FileSize = InetGetSize ( $_FinalUrl ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do Sleep ( 500 ) $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 100 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) GUICtrlSetData ( $_Label, $_DownloadPercent & ' %') EndIf Until $_InfoData[2] = True $label9 = GUICtrlCreateLabel ( 'İndirme Tamamlandı !', 10, 150, 350, 20 ) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label9, $color_black) EndSwitch WEnd I managed to get file version but now when I press to F5, script is waiting like 10 seconds for activate. I think it's because InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) and $hDownload = InetGet("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm", $sFilePath,1,1) because it's waiting for reload from site. Ok but, I want GUI start, wait reload and tell me file version. Whey GUI starting late? Edited February 2, 2020 by Atakanbasturk
Atakanbasturk Posted February 2, 2020 Author Posted February 2, 2020 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <StringConstants.au3> #include <Math.au3> GUISetState(@SW_SHOW) $AboutGUI = GUICreate("K-Lite Mega Codec Pack", 250, 170) $Iconfile = (@ScriptDir & "\icon.ico") GuiSetIcon($Iconfile) GUISetState(@SW_ENABLE) GUISetState(@SW_SHOWNORMAL) $Download = GUICtrlCreateButton("İNDİR", 10, 90, 50, 25, $WS_GROUP) $Kaldir = GUICtrlCreateButton("KALDIR", 100, 90, 50, 25, $WS_GROUP) $OK = GUICtrlCreateButton("KAPAT", 190, 90, 50, 25, $WS_GROUP) GUICtrlSetState ($Download,$GUI_DISABLE) GUICtrlSetState ($Kaldir,$GUI_DISABLE) GUICtrlSetState ($OK,$GUI_DISABLE) GUICtrlCreateProgress ( 10, 125, 200, 20 ) $label1 = GUICtrlCreateLabel("Yüklü Sürüm:", 10, 12, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label2 = GUICtrlCreateLabel("Güncel Sürüm:", 10, 37, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label4 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 12, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label4, $color_maroon) $label5 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 37, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label5, $color_maroon) $label6 = GUICtrlCreateLabel("Dosya Boyutu:", 10, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label6, $color_black) $label7 = GUICtrlCreateLabel("Sorgulanıyor...", 110, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label7, $color_maroon) $data = InetRead("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm") $iBytesRead = @extended $byte = Round($iBytesRead/1048576, 2) $sFilePath = (@TempDir & "\test.exe") $hDownload = InetGet("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm", $sFilePath,0,1) Sleep(2000) InetClose($hDownload) $Sversion = FileGetVersion($sFilePath, ("ProductVersion")) GUICtrlSetData($label5, $Sversion) GUICtrlSetColor($label5, $color_blue) GUICtrlSetState ($Download,$GUI_ENABLE) GUICtrlSetState ($Kaldir,$GUI_ENABLE) GUICtrlSetState ($OK,$GUI_ENABLE) If FileExists(@ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe") Then $dosyayolu = @ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe" $version = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\KLiteCodecPack_is1", "DisplayVersion") GUICtrlSetData($label4, $version) GUICtrlSetColor($label4, $color_green) Else GUICtrlSetData($label4, "Yüklü Değil") GUICtrlSetColor($label4, $color_red) EndIf If $data Then GUICtrlSetData($label7, $byte & " MB") GUICtrlSetColor($label7, $color_green) EndIf GUISetState() While 1 Switch GUIGetMsg() Case -3 GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $OK GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $Kaldir Run($dosyayolu) Case $Download $_DownloadPercent=0 $_ProgressBar = GUICtrlCreateProgress ( 10, 125, 200, 20 ) $_Label = GUICtrlCreateLabel ($_DownloadPercent & ' %', 215, 128, 40,20 ) $_Label1 = GUICtrlCreateLabel ("İNDİRİLİYOR...", 10, 150, 200,20 ) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($_Label1, $color_black) $_FinalUrl = 'https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm' $_TempPath = @ScriptDir & "\K-lite Mega Codec Pack.exe" $_FileSize = InetGetSize ( $_FinalUrl ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 0, 1 ) Local $_InfoData Do Sleep ( 500 ) $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 100 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) GUICtrlSetData ( $_Label, $_DownloadPercent & ' %') EndIf Until $_InfoData[2] = True $label9 = GUICtrlCreateLabel ( 'İndirme Tamamlandı !', 10, 150, 350, 20 ) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label9, $color_black) EndSwitch WEnd Now it looks like complete. Do you guys see any problematic part for your experienced eyes? Edited February 2, 2020 by Atakanbasturk Code updated.
Nine Posted February 2, 2020 Posted February 2, 2020 (edited) You shouldn't do both InetRead and InetGet in the first part of the script. They are simply redondant and create a long unnecessary delay. The InetGet is perfect for your needs. Use InetGetSize if you want to get the size of the file. Or even better FileGetSize after the InetGet. The GUISetState(@SW_SHOW) at the beginning of the script is useless. I do not understand why you REDOWNLOAD the file again when the user press download button. Since you already got the file at the beginning of the script ? I already told you about it, just install the file if the user wants to. And use Ctrl-T to tidy your script so it would make it more readable. Edited February 2, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Atakanbasturk Posted February 2, 2020 Author Posted February 2, 2020 Thanks man. I will regard your suggestions and change my script. But script don't install file 2 times. First to get server file version(is there any update or not), download file for 1 second (for a few kilobytes) from link and read installed version from regedit. If user want to download full file, he/she can. If versions are same, you can choose not to download. At least it's the idea
Nine Posted February 2, 2020 Posted February 2, 2020 $hDownload = InetGet("https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm", $sFilePath,0,1) $_FinalUrl = 'https://www.free-codecs.com/download_soft.php?d=f651918c26a1ec3c5ca50403c8ec2622&s=42&r=&f=k_lite_mega_codec_pack.htm' Those are perfectly identical URL that you download (inetget) two times if user choose to install. Not counting the inetread... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Atakanbasturk Posted February 2, 2020 Author Posted February 2, 2020 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <StringConstants.au3> #include <Math.au3> #include <ButtonConstants.au3> #include <WinAPIDiag.au3> #include <WinAPIDlg.au3> #include <WinAPISys.au3> $AboutGUI = GUICreate("K-Lite Mega Codec Pack", 250, 170) GUISetBkColor($COLOR_WHITE) $Iconfile1 = (@ScriptDir & "\icon7.ico") $pic1 = (@ScriptDir & "\green.jpg") $pic2 = (@ScriptDir & "\red.jpg") GUISetIcon($Iconfile1) $pic = GUICtrlCreateButton("", 176, 12, 64, 64, $BS_ICON) GUICtrlSetImage($pic, $Iconfile1) GUISetState(@SW_ENABLE) GUISetState(@SW_SHOWNORMAL) $Download = GUICtrlCreateButton("İNDİR", 10, 90, 50, 25, $WS_GROUP) $Kaldir = GUICtrlCreateButton("KALDIR", 100, 90, 50, 25, $WS_GROUP) $OK = GUICtrlCreateButton("KAPAT", 190, 90, 50, 25, $WS_GROUP) GUICtrlSetState($Download, $GUI_DISABLE) GUICtrlSetState($Kaldir, $GUI_DISABLE) GUICtrlSetState($OK, $GUI_DISABLE) GUICtrlCreateProgress(10, 125, 200, 20) $label1 = GUICtrlCreateLabel("Yüklü Sürüm:", 10, 12, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label2 = GUICtrlCreateLabel("Güncel Sürüm:", 10, 37, 140, 17) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label1, $color_black) $label3 = GUICtrlCreateLabel("...", 110, 12, 50, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label3, $color_maroon) $label4 = GUICtrlCreateLabel("...", 110, 37, 50, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label4, $color_maroon) $label5 = GUICtrlCreateLabel("Dosya Boyutu:", 10, 62, 100, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label5, $color_black) $label6 = GUICtrlCreateLabel("...", 110, 62, 50, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label6, $color_maroon) $label7 = GUICtrlCreateLabel(" %", 215, 128, 40, 20) $ProgramFilesDir = EnvGet('ProgramFiles(x86)') if not $ProgramFilesDir then $ProgramFilesDir = @ProgramFilesDir If _WinAPI_IsInternetConnected() Then GUICtrlCreatePic($pic1, 230, 150, 16, 16) $url = "https://www.free-codecs.com/download_soft.php?d=ebc26fd9e0f143f94c2654d5714cc06f&s=42&r=&f=k_lite_mega_codec_pack.htm" $size = InetGetSize($url) $byte = Round($size / 1048576, 2) $path1 = (@TempDir & "\test.exe") $path2 = (@DesktopDir & "\K-lite Mega Codec Pack.exe") $path3 = ($ProgramFilesDir & "\K-Lite Codec Pack\unins000.exe") $hDownload = InetGet($url, $path1, 0, 1) Sleep(2000) InetClose($hDownload) $Sversion = FileGetVersion($path1, ("ProductVersion")) GUICtrlSetData($label4, $Sversion) GUICtrlSetColor($label4, $color_blue) GUICtrlSetState($Download, $GUI_ENABLE) GUICtrlSetState($Kaldir, $GUI_ENABLE) GUICtrlSetState($OK, $GUI_ENABLE) Else GUICtrlCreatePic($pic2, 230, 150, 16, 16) GUICtrlSetState($Download, $GUI_DISABLE) GUICtrlSetState($Kaldir, $GUI_DISABLE) GUICtrlSetState($OK, $GUI_DISABLE) MsgBox($MB_SYSTEMMODAL, "", "İNTERNET YOK!", 10) Exit EndIf If FileExists($path3) Then $version = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\KLiteCodecPack_is1", "DisplayVersion") GUICtrlSetData($label3, $version) GUICtrlSetColor($label3, $color_green) Else GUICtrlSetData($label3, "YOK") GUICtrlSetColor($label3, $color_red) EndIf If $hDownload Then GUICtrlSetData($label6, $byte & " MB") GUICtrlSetColor($label6, $color_green) EndIf GUISetState() While 1 Switch GUIGetMsg() Case -3 GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $OK GUIDelete($AboutGUI) GUISetState(@SW_ENABLE) GUISetState(@SW_RESTORE) ExitLoop Case $Kaldir Run($path3) Case $Download $_DownloadPercent = 0 $_ProgressBar = GUICtrlCreateProgress(10, 125, 200, 20) $label8 = GUICtrlCreateLabel($_DownloadPercent & ' %', 215, 128, 40, 20) $label9 = GUICtrlCreateLabel("İNDİRİLİYOR...", 10, 150, 200, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label9, $color_black) $_Download = InetGet($url, $path2, 0, 1) Local $_InfoData Do Sleep(500) $_InfoData = InetGetInfo($_Download) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round((100 * $_InetGet) / $size) $_DownloadPercent = _Min(_Max(1, $_DownloadPercent), 100) GUICtrlSetData($_ProgressBar, $_DownloadPercent) GUICtrlSetData($label8, $_DownloadPercent & ' %') EndIf Until $_InfoData[2] = True $label10 = GUICtrlCreateLabel('İndirme Tamamlandi!', 10, 150, 200, 20) GUICtrlSetFont(-1, 10, 800, 0, "Segoe UI") GUICtrlSetColor($label10, $color_black) Case $pic ShellExecute("https://www.free-codecs.com/k_lite_mega_codec_pack_download.htm") EndSwitch WEnd Yeah two times. But like I said, first download necessary for server file version. It began automatically when script goes and it takes 2 seconds(Reason of 2 seconds, if user has slow download speed. Normally 0,5 second is enough.). It downloads some kilobytes and FileGetVersion can get freshest server file's product version. Cause like you said, there is no way to find server file version without download. Second download is start when user press "İNDİR"(Turkish for download) and it downloads server file completely. Normally, you can get latest build and install to your pc, right? There is no need to get file version, right? But my project's point is finding k-lite's installed version on pc and latest build's version from official website, compare them (just inform user) and if there is a newer version on web, download latest build. If there is no newer version, user don't download new version. So there is no necessary full download, just some kilobytes. Applied your suggestions to my script, very very thanks for your help. Edited February 2, 2020 by Atakanbasturk
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