DTools Posted January 6, 2014 Share Posted January 6, 2014 Hi All, This is my first time writing here, and I hope to get some assistant with an issue I'm facing. I created a GUI window with a button that calls a function in a Loop. The problem is that I cannot click on anything during the running function even not to close the GUI window. I'm trying to understand if there is any way to run this function in a loop and still be able to close the windows with the X even though the function is still running. I understand that I can use the "HotKeySet" but it's not what I'm searching for. I'm adding a code example of what I'm trying to do that will simulate the process and the problem, in this case I cannot close the window, only from the tray. Thanks in advance! #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $FileInput, $listview, $GenButton, $FileInputRead, $Line1, $Line2, $Line3 Call("ListUpdate") Func ListUpdate() GUICreate("",300,300,Default) $listview = GUICtrlCreateListView("Test",Default,Default,300,200,$LVS_NOSORTHEADER) $Line1 = "Line1" $Line2 = "Line2" $Line3 = "Line3" $GenButton = GUICtrlCreateButton("Show Lines",5,200,200) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GenButton _GenList() EndSwitch WEnd EndFunc Func _GenList() _GUICtrlListView_DeleteAllItems($listview) $SetLine = GUICtrlCreateListViewItem($Line1,$listview) $SetLine = GUICtrlCreateListViewItem($Line2,$listview) $SetLine = GUICtrlCreateListViewItem($Line3,$listview) Sleep(5000) Call("_GenList") EndFunc Link to comment Share on other sites More sharing options...
jaberwacky Posted January 7, 2014 Share Posted January 7, 2014 Two things. The five second sleep and the infinite loop created by call(_GenList) Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
DTools Posted January 7, 2014 Author Share Posted January 7, 2014 Thanks for the answer jaberwocky6669, I know it's because call(_GenList), i need this loop. The main idea is to refresh and update this list based on dynamic variables that will change. But still I want to be able to close this window with the X, or creating more buttons and function that will work in parallel. Link to comment Share on other sites More sharing options...
jaberwacky Posted January 7, 2014 Share Posted January 7, 2014 k, well, good luck with that Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
DTools Posted January 7, 2014 Author Share Posted January 7, 2014 Thanks, So can anyone knows how to do refresh GUICtrlCreateListView in a function without getting the primary GUI window Stuck? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2014 Moderators Share Posted January 7, 2014 DTools, if there is any way to run this function in a loop and still be able to close the windows with the X even though the function is still runningReturning to the initial request, you can do it like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <MenuConstants.au3> Global $fInterrupt = False $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Run Func", 10, 10, 80, 30) GUISetState() GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton _Run_Func() EndSwitch WEnd Func _Run_Func() ConsoleWrite("Entering infinite loop" & @CRLF) While 1 Sleep(10) If $fInterrupt Then ConsoleWrite("Interrupting function" & @CRLF) Exit EndIf WEnd EndFunc Func _WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam) Switch $wParam Case $SC_CLOSE ConsoleWrite("[X] clicked" & @CRLF) $fInterrupt = True EndSwitch EndFuncYou might also like to look at the Interrupting a running function tutorial in the Wiki. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DTools Posted January 9, 2014 Author Share Posted January 9, 2014 Hi, I Already work with this procedure and it didn't helped in my case, the window was still stuck. Anyway I found a solution to this issue. (Some workaround) I Added another combo menu (GUICtrlCreateCombo) to the GUI that can be changed during the running function, And also few lines in the looping function to check the value in this menu, and stop the loop if needed. Also I added the HotKeySet to configure "ESC" to exit when the function is running if needed. Thanks for you help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now