Jump to content

Program to Update my progarm small problem...


Recommended Posts

When I click Cancel on the FileOpenDialog, I want it to exit the program, and not return rest of code. Such as saying update was complete when you cancel.

#include <GuiConstants.au3>

Dim $File_Location = @ScriptDir & "\Data\dellquicklaunch.ini"
Dim $data_Location = @ScriptDir & "\Data\"

DirGetSize($data_Location)
If @error = 1 Then
    DirCreate($data_Location)
EndIf

;-------Creates the Main Gui-------
$GUI_Main = GUICreate("Super Update", 200, 50)

;-----Creates Button on GUI------
$GetUpdate = GUICtrlCreateButton("Get Update", 30, 10)
$SendUpdate = GUICtrlCreateButton("Send Update", 95, 10)

GUISetIcon("Super.ico")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            CleanExit()
        Case $GetUpdate
            GetUpdate()
        Case $SendUpdate
            $Pass = "temp"
            $PassAsk = InputBox("Auth Required", "Please Enter Password", "", "*", 100, 125)
            If $PassAsk = $Pass Then
                SendUpdate()
            Else
                MsgBox(262160, "ERROR", "Incorrect Password")
                Exit
            EndIf
        Case Else
            ;-------------;
    EndSwitch

WEnd


Func GetUpdate()
    $CheckFirstRun = IniRead($File_Location, "SuperUpdate", "PathToFile", "")
    If $CheckFirstRun = "" Then
        $UpdatePath = "F:\Super Launch\"
        $PathtoFile = FileOpenDialog("Please Select file to be updated.", @ScriptDir, "Executables (*.exe)", 1, "SuperLaunch.exe")
        $PathtoUpdate = FileOpenDialog("Please Select the update file.", $UpdatePath, "Executables (*.exe)", 1, "SuperLaunch.exe")
        FileCopy($PathtoUpdate, $PathtoFile, 1)
        IniWrite($File_Location, "SuperUpdate", "PathToFile", $PathtoFile)
        IniWrite($File_Location, "SuperUpdate", "PathToUpdate", $PathtoUpdate)
        MsgBox(0, "Success", "The update was successful.")
    Else
        $PathtoFile = IniRead($File_Location, "SuperUpdate", "PathToFile", "")
        $PathtoUpdate = IniRead($File_Location, "SuperUpdate", "PathToUpdate", "")
        FileCopy($PathtoUpdate, $PathtoFile, 1)
        MsgBox(0, "Success", "The update was successful.")
        Exit
    EndIf
EndFunc   ;==>GetUpdate


Func SendUpdate()
    $CheckFirstRun = IniRead($File_Location, "SuperUpdate", "PathToUpdateFile", "")
    If $CheckFirstRun = "" Then
        $UpdatePath = "F:\Super Launch\"
        $PathtoUpdateFile = FileOpenDialog("Please Select the file update.", @ScriptDir, "Executables (*.exe)", 1, "SuperLaunch.exe")
        $PathtoSendUpdate = FileOpenDialog("Please Select the update file.", $UpdatePath, "Executables (*.exe)", 1, "SuperLaunch.exe")
        FileCopy($PathtoUpdateFile, $PathtoSendUpdate, 1)
        IniWrite($File_Location, "SuperUpdate", "PathToUpdateFile", $PathtoUpdateFile)
        IniWrite($File_Location, "SuperUpdate", "PathToSendUpdate", $PathtoSendUpdate)
        MsgBox(0, "Success", "The update was sent successfully.")
    Else
        $PathtoUpdateFile = IniRead($File_Location, "SuperUpdate", "PathToUpdateFile", "")
        $PathtoSendUpdate = IniRead($File_Location, "SuperUpdate", "PathToSendUpdate", "")
        FileCopy($PathtoUpdateFile, $PathtoSendUpdate, 1)
        MsgBox(0, "Success", "The update was sent successfully.")
        Exit
    EndIf
EndFunc   ;==>SendUpdate


;-----Close Program-----
Func CleanExit()
    GUISetState(@SW_HIDE)
    Exit
EndFunc   ;==>CleanExit
Link to comment
Share on other sites

If you look at the example of FileOpenDialog in Autoit Help, it has the case of user cancel handled.

DoH!

Thanks!

Okay I got that to work... Now I would like to make it check file version. But it only returns version of autoit. How do I control the version of my program when it's compiled?

Would I have to use Resource Hacker for this? Or is there a way to do it within the program.

Edited by Klexen
Link to comment
Share on other sites

DoH!

Thanks!

Okay I got that to work... Now I would like to make it check file version. But it only returns version of autoit. How do I control the version of my program when it's compiled?

Would I have to use Resource Hacker for this? Or is there a way to do it within the program.

Yes and no, but kind of maybe... :whistle:

Open SciTE and select Help\SciTE Help. Go down in the contents to Extra Utilities\AutoIt3Wrapper. That help page tells you all about it. The changes can be implemented in compiler directives to the wrapper, but depend on have ResHacker.exe downloaded to the AutoIt3Wrapper directory:

You need to download reshacker.exe to the AutoIt3Wrapper subdirectory to enable the resource update function.

:lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...