Jump to content

Problems getting my script to close


Recommended Posts

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion

#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include "RecFileListToArray.au3"

Global $font = "Arial"
Global $GUI_BGC = "0x660000"

$GUI = GUICreate("C21 Chicago's Finest", 800, 600) ; creates window
GUISetBkColor($GUI_BGC)

   Opt("GuiOnEventMode", 1)

$BuyerV = GUICtrlCreateButton("Buyers", 50, 50, 100, 30) ;creates buttons
$BEvent = GUICtrlSetOnEvent($BuyerV, "Buyers") ;assigns event to button
$SellerV = GUICtrlCreateButton("Sellers", 50, 100, 100, 30)
$SEvent = GUICtrlSetOnEvent($SellerV, "Sellers")
$RenterV = GUICtrlCreateButton("Renters", 50, 150, 100, 30)
$REvent = GuiCtrlSetOnEvent($RenterV, "Renters")
$list = GUICtrlCreateList("", 200, 50, 300, 290)

GUISetState()

While 1
Sleep(1000) ;less cpu
WEnd

Func Buyers()
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc

Func Sellers()
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseSellers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc

Func Renters() 
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseRentals", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc

GUISetState()

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

I'm having problems getting my script to close, it worked before (I hadn't had much of the code in there as I do now), and ever since I've been updating the script - it suddenly stopped allowing me to exit. I now have to end task through the task manager.

Edited by enigmaforceiv
Link to comment
Share on other sites

Link to comment
Share on other sites

@enigmaforceiv

1. If you use GuiOnEventMode, then you should use SetOnEvent funcs.

2. You have set 2 main whiles, so the script is blocked to the 1st while and the 2nd while is never executed, so you can't close the GUI

And I have cleaned other things, so here you go :

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion

#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include "RecFileListToArray.au3"

Global $font = "Arial"
Global $GUI_BGC = "0x660000"

Opt("GuiOnEventMode", 1)
Opt("GUICoordMode", 3)

$GUI = GUICreate("C21 Chicago's Finest", 800, 600) ; creates window
GUISetBkColor($GUI_BGC)
GUISetFont(9, 1000, 0, $font)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$BuyerV = GUICtrlCreateButton("Buyers", 50, 50, 100, 30) ;creates buttons
$BEvent = GUICtrlSetOnEvent($BuyerV, "Buyers") ;assigns event to button
$SellerV = GUICtrlCreateButton("Sellers", 50, 100, 100, 30)
$SEvent = GUICtrlSetOnEvent($SellerV, "Sellers")
$RenterV = GUICtrlCreateButton("Renters", 50, 150, 100, 30)
$REvent = GUICtrlSetOnEvent($RenterV, "Renters")
$list = GUICtrlCreateList("", 200, 50, 300, 290)

GUISetState()

While 1
Sleep(1000) ;less cpu
WEnd

Func Buyers()
GUICtrlSetData($list, "")
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc   ;==>Buyers

Func Sellers()
GUICtrlSetData($list, "")
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseSellers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc   ;==>Sellers

Func Renters()
GUICtrlSetData($list, "")
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseRentals", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc   ;==>Renters

Func _Exit()
Exit
EndFunc   ;==>_Exit

Br, FireFox.

Link to comment
Share on other sites

take.

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion


#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <RecFileListToArray.au3>

Global $font = "Arial"
Global $GUI_BGC = "0x660000"

$GUI = GUICreate("C21 Chicago's Finest", 800, 600) ; creates window
GUISetBkColor($GUI_BGC)

Opt("GuiOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGui")


$BuyerV = GUICtrlCreateButton("Buyers", 50, 50, 100, 30) ;creates buttons
$BEvent = GUICtrlSetOnEvent($BuyerV, "Buyers") ;assigns event to button
$SellerV = GUICtrlCreateButton("Sellers", 50, 100, 100, 30)
$SEvent = GUICtrlSetOnEvent($SellerV, "Sellers")
$RenterV = GUICtrlCreateButton("Renters", 50, 150, 100, 30)
$REvent = GUICtrlSetOnEvent($RenterV, "Renters")
$list = GUICtrlCreateList("", 200, 50, 300, 290)

GUISetState()

While 1
Sleep(1000) ;less cpu
WEnd

Func Buyers()
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseBuyers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc ;==>Buyers

Func Sellers()
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseSellers", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc ;==>Sellers

Func Renters()
GUICtrlSetData($list, "")
Opt("GUICoordMode", 3)
GUISetFont(9, 1000, 0, $font)
Sleep(10)
$FileList = _FileListToArray("C:DropboxCentury21Client DatabaseRentals", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next
EndFunc ;==>Renters

GUISetState()

Func ExitGui()
Exit ; Exit the program
EndFunc ;==>ExitGui
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...