Digisoul Posted July 8, 2010 Share Posted July 8, 2010 Hello there, here is a little code, which will demonstrate a strange problem, please run this code, to know what i mean its a bit difficult for me to explain it expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $win = False,$exitWin2 = False,$W2 Main() Func Main() win1() While 1 Sleep(100) WEnd EndFunc Func Win1() $Form1 = GUICreate("GUI 1", 311, 142, 360, 224) $Button1 = GUICtrlCreateButton("Start W2", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1,"btnofwin1") GUISetState(@SW_SHOW) EndFunc Func BtnOfWin1() WinWait2() EndFunc Func WinWait2() Win2() While $exitWin2 = False ConsoleWrite("!is this a bug ????"&@CRLF) Sleep(100) WEnd GUIDelete($W2) $exitWin2 = False ConsoleWrite("Ok its working... its not a bug"&@CRLF) EndFunc Func Win2() $W2 = GUICreate("GUI 2", 311, 142, 360, 224) $Button1 = GUICtrlCreateButton("Exit", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1,"btnofwin2") GUISetState(@SW_SHOW) EndFunc Func BtnOfWin2() $exitWin2 = True EndFunc thanks in Advance 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Woddles Posted July 8, 2010 Share Posted July 8, 2010 Are you having a problem with the first GUI not closing? or the 2nd? Link to comment Share on other sites More sharing options...
Digisoul Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) Are you having a problem with the first GUI not closing? or the 2nd?2nd with Exit Button on the GUI.the button is not firing the event! Edited July 8, 2010 by Digisoul 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 8, 2010 Moderators Share Posted July 8, 2010 DigiSoul,It is not a bug. AutoIt will not interrupt a running function with another unless you use a HotKey. You are sitting in the loop in WinWait2(), so as the function is still running, BtnOfWin2() is never called. Just get back to your idle loop and look for the flag there: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $win = False, $exitWin2 = False, $W2 Main() Func Main() win1() While 1 Sleep(100) If $exitWin2 Then $exitWin2 = False GUIDelete($W2) EndIf WEnd EndFunc ;==>Main Func Win1() $Form1 = GUICreate("GUI 1", 311, 142, 360, 224) $Button1 = GUICtrlCreateButton("Start W2", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1, "btnofwin1") GUISetState(@SW_SHOW) EndFunc ;==>Win1 Func BtnOfWin1() WinWait2() EndFunc ;==>BtnOfWin1 Func WinWait2() Win2() EndFunc ;==>WinWait2 Func Win2() $W2 = GUICreate("GUI 2", 311, 142, 360, 224) $Button2 = GUICtrlCreateButton("Exit", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1, "btnofwin2") GUISetState(@SW_SHOW) EndFunc ;==>Win2 Func BtnOfWin2() $exitWin2 = True EndFunc ;==>BtnOfWin2Top Tip: Use Opt("TrayIconDebug", 1) if your script appears to hang like that. It lets you see where the script is when you put your cursor over the tray icon. All clear? 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...
Digisoul Posted July 8, 2010 Author Share Posted July 8, 2010 DigiSoul, It is not a bug. AutoIt will not interrupt a running function with another unless you use a HotKey. You are sitting in the loop in WinWait2(), so as the function is still running, BtnOfWin2() is never called. Just get back to your idle loop and look for the flag there: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $win = False, $exitWin2 = False, $W2 Main() Func Main() win1() While 1 Sleep(100) If $exitWin2 Then $exitWin2 = False GUIDelete($W2) EndIf WEnd EndFunc ;==>Main Func Win1() $Form1 = GUICreate("GUI 1", 311, 142, 360, 224) $Button1 = GUICtrlCreateButton("Start W2", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1, "btnofwin1") GUISetState(@SW_SHOW) EndFunc ;==>Win1 Func BtnOfWin1() WinWait2() EndFunc ;==>BtnOfWin1 Func WinWait2() Win2() EndFunc ;==>WinWait2 Func Win2() $W2 = GUICreate("GUI 2", 311, 142, 360, 224) $Button2 = GUICtrlCreateButton("Exit", 16, 32, 75, 25, $WS_GROUP) GUICtrlSetOnEvent(-1, "btnofwin2") GUISetState(@SW_SHOW) EndFunc ;==>Win2 Func BtnOfWin2() $exitWin2 = True EndFunc ;==>BtnOfWin2 Top Tip: Use Opt("TrayIconDebug", 1) if your script appears to hang like that. It lets you see where the script is when you put your cursor over the tray icon. All clear? M23 Thanks for clearing this concept, my situation is a little different then this basic code, i am actually trying to pause the execution in the SQLite callback, you have any idea ? Anyways thanks for the Tip. 73 108 111 118 101 65 117 116 111 105 116 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