Jump to content

Semi unresponsive button


Nety
 Share

Recommended Posts

Hello, first post here but been using AutoIT for a month or so now. I have a problem with a button in a GUI window. Basically it does not always respond to a click. Sometimes it will respond instantly but other times you might have to click it two or three times before it responds. To me the loop is small so should no be causing an issue but apparently it is. This is the section of code that is causing the issue.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GUIComboBox.au3>
Opt('MustDeclareVars', 1)

Local $iSel, $sText, $OK, $Msg, $return
Local $hGUI = GUICreate("Window name", 372, 200)
GUICtrlCreateLabel("Text", 60, 20)
GUICtrlCreateLabel("More text", 5, 40)
Local $DirCombo = GUICtrlCreateCombo("Select the workstation name and click OK", 60, 80, 250)
$OK = GUICtrlCreateButton("OK", 150, 110, 50)

; populate Combo
Local $sDrive = StringLeft($Profiles, 3)
Local $avDirs = _FileListToArray($Profiles, "*", 2)
For $n = 1 To $avDirs[0]
    _GUICtrlComboBox_AddString($DirCombo, $avDirs[$n])
Next

; Selection Control
While 1
    GUISetState(@SW_SHOW)
    While 1
        $Msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $Msg = $OK
                ExitLoop
            Case Else
        EndSelect
    WEnd
    $iSel = _GUICtrlComboBox_GetCurSel($DirCombo)
    _GUICtrlComboBox_GetLBText($DirCombo, $iSel, $sText)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Msg = $OK
            If FileExists("e:\Profiles\" & $sText & "\path and file") Then
                GUIDelete()
            ; If workstation is valid and profiles exist then they are restored.
                $return = RunWait("long app path", @SW_MAXIMIZE)
                    Select
                        ; If restore is sucessful then success message is given.
                        ; Workstation is then rebooted after a three second delay.
                        Case  $return = 0
                            MsgBox(0, "window name", "No Errors, successful" & @CRLF & "files will be removed")
                            DirRemove("path", 1)
                            DirRemove("path", 1)
                            FileDelete("path")
                            SplashTextOn("window name", "The workstation is now rebooting", -1, -1, -1, -1, 4, "", 24)
                            Sleep(3000)
                            Run("shutdown.exe -r -t 0", "", @SW_HIDE)
                            Exit
                        ; If any other error is given message is shown and application exits.
                        Case Else
                            MsgBox(0, "window name", "Error returned" & @CRLF & "Do NOT continue"& @CRLF & "Error Returned "& $return & " Please check Log file")
                            Exit
                    EndSelect
                ExitLoop
            Else
                MsgBox(0, "window name", "Folder exists but file" & @CRLF & "Please check selection and file exists")
            EndIf
        Case Else
    EndSwitch
WEnd

Can anyone see anything that is obviously wrong with the code?

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...