ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    rolovely
    rolovely
    PSsix Member Super Class II
    PSsix Member Super Class II


    PSsix Game Coder
    จำนวนข้อความ : 193
    ความนิยม : 26
    เข้าร่วมเมื่อ : 15/10/2010
    อายุ : 35
    ที่อยู่ : THAILAND

    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate Empty ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    ตั้งหัวข้อ by rolovely 28/02/11, 11:25 pm

    ก็คือตอนนี้ผมเขียนอยู่โปรแกรมนึง แล้วผมต้องการให้มันคอยเช็คไฟล์ 123.txt ซึ่งอยู่บนเว็บ เช่น [You must be registered and logged in to see this link.]

    พอมันเช็คเสร็จก็ให้มันมาเขียนลง ไฟล์ 456.txt

    คร่าวๆที่ผมทำไว้ คือมันไม่ดึงข้อความมาเก็บไว้ที่ 456.txt ทำไงก็ไม่ดึง

    ตัวอย่างโค็ด รู้ว่ามันไม่ถูกแต่ก็อาจจะนึกออกอยู่บ้าง

    #include <IE.au3>
    #include <Array.au3>

    $oIE = _IELinkGetCollection("http://127.0.0.1/123.txt")
    $file = FileOpen("456.txt", 2)
    FileWriteLine($file, "")
    FileClose($file)

    อีกอย่างนึงนะครับ คือผมไม่อยากให้มันมีบราวเซอร์เด้งขึ้นมา อยากให้มันทำเหมือนกับแพทย์พวกเกมไรงี้อ่ะ คือให้มันดึงข้อมูลมาเก็บไว้ที่เรากำหนดเองเลย

    ยังไงก็ช่วยบอกผมทีนะ อีกอย่าง พวก blog เก่าๆหายไปไหนอ่ะ เข้าไปเจอแต่อันใหม่ จะเอามาประยุกต์ไม่ได้เลยอ่ะครับ

    ไม่คิดจะทำหนังสือ autoit ขึ้นมาหรอครับ em218
    rolovely
    rolovely
    PSsix Member Super Class II
    PSsix Member Super Class II


    PSsix Game Coder
    จำนวนข้อความ : 193
    ความนิยม : 26
    เข้าร่วมเมื่อ : 15/10/2010
    อายุ : 35
    ที่อยู่ : THAILAND

    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate Empty Re: ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    ตั้งหัวข้อ by rolovely 28/02/11, 11:58 pm

    หรือท่าจะให้ดี อยากให้ลองทำแบบนี้ดูอ่ะครับ อิอิ ไปเจอมา

    AutoUpdate.au3
    Code:
    #cs---------------------------------------------------------------------------------------------------------------------------------#
    Student manager project - Auto Updates
    Author : Nguyễn Huy Trường
    Yahoo Address : [You must be registered and logged in to see this link.]
    Do not make illegal copy!
    #ce---------------------------------------------------------------------------------------------------------------------------------#

    #include <config.nht>
    #include <GuiEdit.au3>
    #include <GUIConstantsEx.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <String.au3>
    #include <Array.au3>
    #include <File.au3>

    ;########################################## These are some basic script to use ###############################################

    Func getValue($url)
       $fileDownloadable=InetGet($url, @ScriptDir&"\"&$dataFileName);
       If($fileDownloadable==1) Then
       $returnValue=FileRead(@ScriptDir&"\"&$dataFileName);
       Return $returnValue;
       ElseIf($fileDownloadable==0) Then
       Return -1;
       EndIf
    EndFunc

    Func alert($txt)
       MsgBox(0, $alertTitle, $txt);
    EndFunc

    Func readReg($regKey, $regName)
       Return RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ht3004\"&$regKey,$regName);
    EndFunc
       
    Func writeReg($regKey, $regName, $regValue)
       RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ht3004\"&$regKey,$regName,"REG_SZ",$regValue);
    EndFunc

    Func deleteReg($regKey, $regValue)
       RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\ht3004\"&$regKey,$regValue);
    EndFunc

    Func progressBy($IDOfProgressBar, $valueToProgressBy)
       $aimValue=Execute($currentProgress+$valueToProgressBy);
       If($aimValue>=100) Then
          GUICtrlSetData($IDOfProgressBar,100);
       Else
          While $currentProgress<$aimValue
             GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp));
             $currentProgress+=$percentPerUp;
             Sleep($speedOfUpdate);
          WEnd
       EndIf
       $currentProgress=$aimValue;
    EndFunc

    Func progressTo($IDOfProgressBar,$valueToProgressTo)
       If($valueToProgressTo>=100) Then
          GUICtrlSetData($IDOfProgressBar,100);
       Else
          While $currentProgress<$valueToProgressTo
             GUICtrlSetData($IDOfProgressBar,Execute($currentProgress+$percentPerUp));
             $currentProgress+=$percentPerUp;
             Sleep($speedOfUpdate);
          WEnd
       EndIf
       $currentProgress=$valueToProgressTo;
    EndFunc

    Func downloadFile($fileDownloadLink, $fileDownloadName)
       
       Global $downloadProgress;

       $progressForm=GUICreate("Downloading updates...", 220, 50, 0, 0);
       $downloadProgress=GUICtrlCreateProgress(10, 10, 200, 20);
       GUICtrlSetColor(-1, 32250);
       GUISetState(@SW_SHOW);
       
       $downloadFileSize=InetGetSize($fileDownloadLink);
       $isDownloaded=InetGet($fileDownloadLink, $fileDownloadName, "", 1);
       
       While @InetGetBytesRead<$downloadFileSize;
          progressTo($downloadProgress, @InetGetBytesRead/$downloadFileSize*100);
       WEnd
       
       GUIDelete($progressForm);Aftet delete progressForm, plz set $currentProgress to 0;
       $currentProgress=0;
       
       Return $isDownloaded;
    EndFunc

    Func sizeOf($arrayName)
       SetError(0);
       $index=0;
       Do
          $pop=_ArrayPop($arrayName);
          $index+=1;
       Until @error=1;
       Return $index-1;
    EndFunc

    Func encode($txt, $pass, $lvl)
       Return _StringEncrypt(1, BinaryToString(StringToBinary($txt, $Flag_UTF8), $Flag_ANSI), $pass, $lvl);
    EndFunc

    Func decode($txt, $pass, $lvl)
       Return BinaryToString(StringToBinary(_StringEncrypt(0, $txt, $pass, $lvl), $Flag_ANSI), $Flag_UTF8);
    EndFunc

    ;########################################## End basic script programmed ######################################################


    ;****************************************** Start main script of project *****************************************************
    ;-------------------------------------------------Create a progress bar---------------------------------------------------

    Global $updateProgress

    $progressForm=GUICreate("Checking for updates...", 220, 50, 0, 0);
    $updateProgress=GUICtrlCreateProgress(10, 10, 200, 20);
    GUICtrlSetColor(-1, 32250);
    GUISetState(@SW_SHOW);

    ;-------------------------------------------------Get new and old Version-------------------------------------------------

    $newVersion=getValue($linkCheckVersion);After getValue(), plz delete the file downloaded!
    progressBy($updateProgress,$percentPerAction);
    FileDelete(@ScriptDir&"\"&$dataFileName);

    If Not($newVersion==-1) Then
       progressBy($updateProgress,$percentPerAction);
       $currentVersion=readReg("SM","Version");
       progressBy($updateProgress,$percentPerAction);
       $fileLink=getValue($linkCheckFileUrl);After getValue(), plz delete the file downloaded!
       progressBy($updateProgress,$percentPerAction);
       FileDelete(@ScriptDir&"\"&$dataFileName);
       $newFeatures=getValue($linkCheckNewFeatures);After getValue(), plz delete the file downloaded!
       progressBy($updateProgress,$percentPerAction);
       FileDelete(@ScriptDir&"\"&$dataFileName);
       progressBy($updateProgress,$percentPerAction);

       ;-------------------------------------------------Start check for updates-------------------------------------------------

       GUIDelete($progressForm);Aftet delete progressForm, plz set $currentProgress to 0;
       $currentProgress=0;
       
       If($currentVersion=="") Then
          writeReg("SM","Version",$projectVersion);
       Else
          If(Execute($newVersion)>Execute($currentVersion)) Then
             $downloadConfirm=MsgBox(1, "Thông báo", "Đã có phiên bản mới : "&$newVersion&"."&@LF&"Tính năng cập nhật: "&@LF&$newFeatures&@LF&"Bạn có muốn download?");
             If($downloadConfirm==1) Then
                $downloadable=downloadFile($fileLink, $fileName);
                If($downloadable==0) Then
                   alert("Không thể download bản cập nhật, xin vui lòng thử lại sau!");
                Else
                   writeReg("PM","Version",$newVersion);
                   alert("Đã download xong phiên bản mới! Cập nhật hoàn tất, click OK để tiến hành cài đặt bản mới!");
                   Run($fileName);
                   Exit;
                EndIf
             EndIf
          EndIf
       EndIf
       ;-------------------------------------------------End updates check-------------------------------------------------------
    Else
       progressTo($updateProgress,100);
       GUIDelete($progressForm);
    EndIf

    ;****************************************** End script of this project *******************************************************


    แก้ไขล่าสุดโดย rolovely เมื่อ 01/03/11, 12:00 am, ทั้งหมด 1 ครั้ง
    rolovely
    rolovely
    PSsix Member Super Class II
    PSsix Member Super Class II


    PSsix Game Coder
    จำนวนข้อความ : 193
    ความนิยม : 26
    เข้าร่วมเมื่อ : 15/10/2010
    อายุ : 35
    ที่อยู่ : THAILAND

    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate Empty Re: ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    ตั้งหัวข้อ by rolovely 28/02/11, 11:59 pm

    ส่วนอันนี้ config.nht

    Code:
    ;########################################## These script will declare some variables ##########################################

    Global $alertTitle="Test";                        Declare the title of MsgBox()
    Global $dataFileName="ht3004.nht";                     Declare the file name to save when check version
    Global $projectVersion="1.0";                        Declare the version of project in case of not set
    Global $filePrefix="SMP";                        Declare the file name before the dot
    Global $fileExtension="exe";                        Declare the extension of file
    Global $fileName=$filePrefix&"."&$fileExtension;               Declare the File name
    Global $percentPerAction=Number(100/5);                     Declare the percentage that is up every action
    Global $currentProgress=0;                        Declare the progress of doing nothing
    Global $linkCheckVersion="http://127.0.0.1/version.spatch";            Declare the link to check new version value;
    Global $linkCheckFileUrl="http://127.0.0.1/newVersionFileLink.spatch";         Declare the link that used to download new project
    Global $linkCheckNewFeatures="http://127.0.0.1/newFeatures.spatch";         Declare the link that used to show new update-features
    Global $speedOfUpdate=1;                        Declare the speed (ms) of each up progress
    Global $percentPerUp=0.5;                        Declare the percent to progress each time
    Global Const $Flag_UTF8=4;
    Global Const $Flag_ANSI=1;

    ;########################################## End declaring #####################################################################
    rolovely
    rolovely
    PSsix Member Super Class II
    PSsix Member Super Class II


    PSsix Game Coder
    จำนวนข้อความ : 193
    ความนิยม : 26
    เข้าร่วมเมื่อ : 15/10/2010
    อายุ : 35
    ที่อยู่ : THAILAND

    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate Empty Re: ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    ตั้งหัวข้อ by rolovely 01/03/11, 12:45 am

    ตอนนี้ผมเอามาดัดแปลง คือสามารถดึงไฟล์จากตัวที่เราต้องการได้แล้ว และก็สามารถใช้ได้ปกติละ

    เกิดถ้าดัดแปรงเยอะกว่านี้ กลัวว่ามันจะพัง ก็เลยเอาออกแค่ไม่กี่บรรทัด
    rolovely
    rolovely
    PSsix Member Super Class II
    PSsix Member Super Class II


    PSsix Game Coder
    จำนวนข้อความ : 193
    ความนิยม : 26
    เข้าร่วมเมื่อ : 15/10/2010
    อายุ : 35
    ที่อยู่ : THAILAND

    ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate Empty Re: ช่วยด้วยครับ เรื่องการทำเกี่ยวกับ การ patch file autoupdate

    ตั้งหัวข้อ by rolovely 01/03/11, 01:24 am

    ตอนนี้ดัดแปลงจนเล็กมากๆ ตัดอันไม่สำคัญออกไปให้หมดเลย
    สิ่งที่ตัดออกไป
    เช็คเวอร์ชั่น
    เช็คไฟล์
    เช็คนามสกุล เพราะมันกำหนดได้อยู่แล้ว
    อีกหลายตัวที่ตัดออกไปเลย

      เวลาขณะนี้ 08/05/24, 09:48 am