Jump to content
Sign in to follow this  
eJan

If/EndIf, Case/Else...

Recommended Posts

eJan

I need help to finish script which will update EditPlus with saved settings.

Way 1:

1. EditPlus exist (OK)

Posted Image

2. EditPlus doesn't exist (OK)

Posted Image

3. EditPlus open folder, wrong selected (OK)

Posted Image

4. EditPlus open folder, [cancel] (OK)

Posted Image

5. EditPlus open folder, [cancel] (BAD)

Posted Image

Way 2:

1. EditPlus exist (OK)

Posted Image

2. EditPlus doesn't exist (OK)

Posted Image

3. EditPlus open folder, [cancel] (BAD)

Posted Image

4. EditPlus open folder, [cancel] (BAD)

Posted Image

5. EditPlus open folder, good selected (OK)

Posted Image

Script (complete is in attachment)

;

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

#NoTrayIcon

#include <File.au3>

#include <GUIConstants.au3>

$regpath = RegRead("HKEY_CURRENT_USER\Software\ES-Computing\EditPlus 2\Install", "Path")

; -----------------------------------------------------------------

$string = StringTrimRight($regpath, 1)  ; delete 1 char

; -----------------------------------------------------------------

; ---------------------- not

$program = "EditPlus"

$file = "editplus.ini"

; ---------------------- used

Dim $chkboxID[2]Dim $chkbox[2]

Dim $s_TempFile

$grp = _TempFile()

$btn = _TempFile()

$cls = _TempFile()

$edit = _TempFile()

FileInstall("group.bmp", $grp)

FileInstall("update.bmp", $btn)

FileInstall("close.bmp", $cls)

FileInstall("editplus.ini", $edit)

If FileExists($string) = 0 Then

   GUICreate($program, 170, 57)

   $search = GUICtrlCreateLabel($program & " was not found." & @CRLF & "Would you like to select location?", 2, 4, 165, 28, $SS_SUNKEN)

   GUICtrlSetBkColor($search, 0xF0EDE3)

   $yes = GUICtrlCreateButton("YES", 39, 36, 34, 18, $BS_FLAT)

   $no = GUICtrlCreateButton("NO", 94, 36, 34, 18, $BS_FLAT)

   GUISetState(@SW_SHOW)

   While 1

      $msg = GUIGetMsg()

      Select

         Case $msg = $yes

            GUISetState(@SW_HIDE)

            ExitLoop

         Case $msg = $no Or $msg = $GUI_EVENT_CLOSE

            GUISetState(@SW_HIDE)

            FileDelete($grp)

            FileDelete($btn)

            FileDelete($cls)

            FileDelete($edit)

            Exit

      EndSelect

   WEnd

   $message = "Select location"

   ; -------------------------------------------------------------------------------- change

   $open = FileSelectFolder($message, @ProgramFilesDir, -1, @ProgramFilesDir & "\EditPlus 2")

   ; -------------------------------------------------------------------------------- change

   If @error Then

      GUICreate($program, 170, 57)

      $cancel = GUICtrlCreateLabel("No location selected." & @CRLF & "Would You like to retry?", 2, 4, 165, 28, $SS_SUNKEN)

      GUICtrlSetBkColor($cancel, 0xF0EDE3)

      $yes = GUICtrlCreateButton("YES", 39, 36, 34, 18, $BS_FLAT)

      $no = GUICtrlCreateButton("NO", 94, 36, 34, 18, $BS_FLAT)

      GUISetState(@SW_SHOW)

      While 1

         $msg = GUIGetMsg()

         Select

     Case $msg = $yes

        GUISetState(@SW_HIDE)

               $message = "Select location"

               ; -------------------------------------------------------------------------------- change

               $open = FileSelectFolder($message, @ProgramFilesDir, -1, @ProgramFilesDir & "\EditPlus 2")

               ; -------------------------------------------------------------------------------- change

            Case $msg = $no Or $msg = $GUI_EVENT_CLOSE

               GUISetState(@SW_HIDE)

               FileDelete($grp)

               FileDelete($btn)

               FileDelete($cls)

               FileDelete($edit)

               Exit

         EndSelect

      WEnd

   Else

      If FileExists($open & "\editplus.ini") Then

         $string = StringReplace($open, "|", @CRLF)

      Else

         GUICreate($program, 170, 57)

         $cancel = GUICtrlCreateLabel("This is not a valid location." & @CRLF & "Would You like to retry?", 2, 4, 165, 28, $SS_SUNKEN)

         GUICtrlSetBkColor($cancel, 0xF0EDE3)

         $yes = GUICtrlCreateButton("YES", 39, 36, 34, 18, $BS_FLAT)

         $no = GUICtrlCreateButton("NO", 94, 36, 34, 18, $BS_FLAT)

         GUISetState(@SW_SHOW)

         While 1

            $msg = GUIGetMsg()

            Select

               Case $msg = $yes

                  GUISetState(@SW_HIDE)

                  $message = "Select location"

                  ; -------------------------------------------------------------------------------- change

                  $open = FileSelectFolder($message, @ProgramFilesDir, -1, @ProgramFilesDir & "\EditPlus 2")

                  ; -------------------------------------------------------------------------------- change

                  If FileExists($open & "\editplus.ini") Then

                     $string = StringReplace($open, "|", @CRLF)

                     ExitLoop

                  Else

                     GUICreate($program, 170, 57)

                     $cancel = GUICtrlCreateLabel("This is not a valid location." & @CRLF & "Would You like to retry?", 2, 4, 165, 28, $SS_SUNKEN)

                     GUICtrlSetBkColor($cancel, 0xF0EDE3)

                     $yes = GUICtrlCreateButton("YES", 39, 36, 34, 18, $BS_FLAT)

                     $no = GUICtrlCreateButton("NO", 94, 36, 34, 18, $BS_FLAT)

                     GUISetState(@SW_SHOW)

                  EndIf

                 

               Case $msg = $no Or $msg = $GUI_EVENT_CLOSE

                  GUISetState(@SW_HIDE)

                  FileDelete($grp)

                  FileDelete($btn)

                  FileDelete($cls)

                  FileDelete($edit)

                  Exit

            EndSelect

         WEnd

      EndIf

   EndIf

EndIf

GUICreate($program, 226, 88)

$group = GUICtrlCreatePic($grp, 2, 4, 221, 81)

GUICtrlSetStyle($group, $WS_DISABLED)

$text = GUICtrlCreateLabel($string, 8, 10, 209, 29, $SS_SUNKEN)

GUICtrlSetBkColor($text, 0xF0EDE3)

$progress = GUICtrlCreateProgress(8, 43, 209, 16, $PBS_SMOOTH)

GUICtrlSetColor($progress, 0xFF7900)

$chkboxID[0] = GUICtrlCreatePic($btn, 83, 63, 60, 17)

$chkbox[0] = $GUI_UNCHECKED

GUISetState(@SW_SHOW)

While 1

   $msg = GUIGetMsg()

   Select

      Case $msg = $GUI_EVENT_CLOSE

         GUISetState(@SW_HIDE)

         FileDelete($grp)

         FileDelete($btn)

         FileDelete($cls)

         FileDelete($edit)

         Exit

      Case $msg = $chkboxID[0]

         SetCheckBox($chkboxID[0], $chkbox[0])

   EndSelect

WEnd

Func SetCheckBox($id, ByRef $val)

   If $val = $GUI_UNCHECKED Then

      ; ----------------- change ( $String..

      FileCopy($edit, $string & "\editplus.ini", 1)

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "First Run", "REG_DWORD", "0")

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "Full Screen", "REG_DWORD", "0")

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "Function List", "REG_BINARY", "00000000000000000000000000000000")

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "Language", "REG_DWORD", "0")

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "Placement", "REG_BINARY", "2c0000000200000003000000ffffffffffffffffffffffffffffffff58000000580000005803000086020000")

      RegWrite("HKCU\Software\ES-Computing\EditPlus 2\Install", "Window List", "REG_BINARY", "00000000000000000000000000000000")

      ; ----------------- change .. or $file)

      For $i = 1 To 100 Step 3.3

         Sleep(1)

         GUICtrlSetData($progress, $i, $i)

         If $i > 98 Then

            GUICtrlSetImage($id, $cls)

         EndIf

      Next

      $val = $GUI_CHECKED

      GUICtrlDelete($progress)

      $text2 = GUICtrlCreateLabel("UPDATE SUCCESSFUL", 8, 43, 209, 16, $SS_CENTER + $SS_SUNKEN)

      GUICtrlSetColor($text2, 0xF0EDE3)

      GUICtrlSetBkColor($text2, 0xFF7900)

   Else

      GUISetState(@SW_HIDE)

      FileDelete($grp)

      FileDelete($btn)

      FileDelete($cls)

      FileDelete($edit)

      Exit

   EndIf

EndFunc

Few days searching for solution, and i think the point must be in Func, but the Functions i use is copied. Another thing maybe exist easyer solution to delete all _TempFile()'s in one line (not to repeating del$1, del$2, del$3...)

script_pics.rar

Edited by eJan

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×