DigDeep Posted January 27, 2017 Share Posted January 27, 2017 Not sure what am I doing wrong here... I want to click on the $Lable1 to get the $Button1 (This works) When the Button comes up, I want to click it to get msgbox or whatever actions needed. (This does not work) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #Region $Form2 = GUICreate("Form2", 350, 198, 766, 621) $Label1 = GUICtrlCreateLabel("Label1", 32, 24, 108, 33) GUISetState(@SW_SHOW) #EndRegion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label1 $Button1 = GUICtrlCreateButton("Button1", 136, 144, 75, 25) Select Case $Button1 = MouseClick($MOUSE_CLICK_LEFT) MsgBox(0, '', 'Button Selected') EndSelect EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 27, 2017 Moderators Share Posted January 27, 2017 DigDeep, Perhaps like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Cretae placeholder for non-existent button - otherwise it will fire on every pass through the idle loop Global $Button1 = 9999 $Form2 = GUICreate("Form2", 350, 198, 766, 621) $Label1 = GUICtrlCreateLabel("Label1", 32, 24, 108, 33) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Label1 ;Disable label GUICtrlSetState($Label1, $GUI_DISABLE) ; Create button $Button1 = GUICtrlCreateButton("Button1", 136, 144, 75, 25) Case $Button1 ; Delete button GUICtrlDelete($Button1) ; Display MsgBox MsgBox($MB_SYSTEMMODAL, '', 'Button Selected') ; Re-enable label GUICtrlSetState($Label1, $GUI_ENABLE) EndSwitch WEnd 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...
DigDeep Posted January 27, 2017 Author Share Posted January 27, 2017 (edited) Hi Melba, I think it was because of the Global $Button1 not declaring at the top was creating the issue. I was able to get it your way now. Sorry had to take more time here but I tried to adjust it again but it went off again for not displaying the msgbox. 1. I am using Select and not Switch format. 2. When Lable is clicked it will check if the testing.txt file exists or not. If yes then it will get the Button. 3. When the Button is clicked it will display the msgbox. If I remove the 'If Fileexists' and below that Select part, it works fine. Something like this... While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Label1 ;~ If FileExists('C:\Temp\testing.txt') Then $Button1 = GUICtrlCreateButton("Button1", 136, 144, 75, 25) ;~ Select Case $nMsg = $Button1 ; Display MsgBox MsgBox($MB_SYSTEMMODAL, '', 'Button Selected') ;~ EndSelect ;~ EndIf EndSelect WEnd But I want the button to show only if the file exists and then the msgbox when button is clicked. And the below one does not work... #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Cretae placeholder for non-existent button - otherwise it will fire on every pass through the idle loop Global $Button1 = 9999 $Form2 = GUICreate("Form2", 350, 198, 766, 621) $Label1 = GUICtrlCreateLabel("Label1", 32, 24, 108, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Label1 If FileExists('C:\Temp\testing.txt') Then $Button1 = GUICtrlCreateButton("Button1", 136, 144, 75, 25) Select Case $nMsg = $Button1 ; Display MsgBox MsgBox($MB_SYSTEMMODAL, '', 'Button Selected') EndSelect EndIf EndSelect WEnd Edited January 27, 2017 by DigDeep Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 27, 2017 Moderators Share Posted January 27, 2017 DigDeep, Why the second Select structure? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Cretae placeholder for non-existent button - otherwise it will fire on every pass through the idle loop Global $Button1 = 9999 $Form2 = GUICreate("Form2", 350, 198, 766, 621) $Label1 = GUICtrlCreateLabel("Label1", 32, 24, 108, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Label1 If FileExists('C:\Temp\testing.txt') Then $Button1 = GUICtrlCreateButton("Button1", 136, 144, 75, 25) EndIf Case $nMsg = $Button1 ; Display MsgBox MsgBox($MB_SYSTEMMODAL, '', 'Button Selected') EndSelect WEnd 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...
DigDeep Posted January 27, 2017 Author Share Posted January 27, 2017 Thank you Melba. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 27, 2017 Moderators Share Posted January 27, 2017 DigDeep, Glad I could help. 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...
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