Sign in to follow this  
Followers 0
enigmaforceiv

Problems getting my script to close

6 posts in this topic

#1 ·  Posted (edited)

#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

Share this post


Link to post
Share on other sites



put the includes again to test the code.

Share this post


Link to post
Share on other sites

Sorry, had them collapsed.

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks again everyone!

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  
Followers 0