Ktulu789 Posted March 31, 2019 Share Posted March 31, 2019 Hi people! How are you doing? I have a GUI I created that has some buttons. I monitor them with While...GUIGetMsg...Switch...Case Is that the only way to monitor clicks or buttons pressed? The GUI simply has some Labels, one has a counter. One button counts one more and updates the label, the other resets the counter to zero and shows a message first. The problem is that the message appears for a split second and then the counter at 1 is shown. I want it to stop until the next click on the button. I tried to nest While...GUIGetMsg...Switch...Case inside the other While...GUIGetMsg.... and it simply stops responding, no click works. Maybe I'm wrong But I think I remember there was another way to monitor buttons clicks. AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S Link to comment Share on other sites More sharing options...
BugFix Posted March 31, 2019 Share Posted March 31, 2019 Look this: OnEventMode Best Regards BugFix Link to comment Share on other sites More sharing options...
Subz Posted March 31, 2019 Share Posted March 31, 2019 You could use Adlibregister to monitor if the button was clicked or not, for example: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $g_bStart = False, $g_iCount = 0 GUICreate("Counter Example", 200, 65) Global $g_idCounter = GUICtrlCreateLabel("", 5, 5, 190, 20, BitOR($SS_CENTERIMAGE, $SS_CENTER)) Global $g_idStart = GUICtrlCreateButton("Start", 5, 30, 95, 30) Global $g_idReset = GUICtrlCreateButton("Reset", 100, 30, 95, 30) GUISetState() AdlibRegister("_Counter", 1000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $g_idStart $g_bStart = $g_bStart = False ? True : False GUICtrlSetData($g_idStart, $g_bStart = False ? "Start" : "Stop") Case $g_idReset $g_bStart = False GUICtrlSetData($g_idCounter, "") EndSwitch WEnd Func _Counter() Switch $g_bStart Case True GUICtrlSetData($g_idCounter, $g_iCount) $g_iCount += 1 Case False ;~ Do nothing EndSwitch EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 1, 2019 Moderators Share Posted April 1, 2019 Ktulu789, You should be able to do what you want within a GUIGetMsg loop. Please post the code you have tried (see here how to do it) and then we can see what exactly why you are having problems. 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...
Ktulu789 Posted April 14, 2019 Author Share Posted April 14, 2019 Hi guys! Thanks for your replies! I was using a GUIGetMsg loop and changed for GUICtrlSetOnEvent from GUIOnEventMode. Anyway the error was some loops that recalled themselves, hence skipping steps. The original code was using MsgBox to show the messages and I changed them to a GUI to avoid reflashing the window on screen. It was something like "message" Enter Message with counter 45 times Enter everytime Closing message. Enter (There were 30something messages, they repeated 45 times each to allow me to count). Sometimes I needed to restart a loop of 45 or jump to the next/previous message and I had hotkeys for that which worked after dismissing the current MsgBox. When I changed the MsgBoxes for the GUI and started replacing the next/previous MsgBoxes it just went to the next thing in line. Bad code. Anyway I wanted to find the GUIOnEventMode method and couldn't find it on the help file easily (as in GUICreate related. Normally you create a GUI and then want to add functional buttons and stuff, but in the Related section only appears GUIGetMsg). I fixed the parts that recalled the message functions from the previous/next functions and averything is fine. Also the While 1 GUIGetMsg polling is gone thanks to you! Sorry for the late response, work and study make things harder AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S 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