XabiK Posted June 27, 2013 Posted June 27, 2013 Hi all, This is my first post in the AutoIt forum... I'm a newbie, but I used AutoIt to develop an internal tool in my company; long to explain, but we need to convert some CAD files (3D models and drawings) into a new format, and instead of click, click, select, etc. thousands of times, I tried to use AutoIt. I managed to do all the conversion, but I wanted to put some 'icing on the cake', creating a form to let the user select what type of conversion he/she wants to do. Actually, it's my first form, and it's driving me nuts! It's very easy: one combo box with 3 different options. When the user selects one option from the combo box, an explanation appears, and he/she can click 'OK'. The thing is... I can't click on the button (it's not working) I suppose it's just a silly mistake of mine, but I can't find it, and I've read a lot of tutorials, forum posts, etc... Can someone help me? Code follows: expandcollapse popup#region Include #include-once #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #endregion Include #region AutoItSetOption Opt("GUIOnEventMode", 1) #endregion AutoItSetOption #region Input Form definition Local $frmInput = GUICreate("Conversion tool", 300, 200, -1, -1) Local $lblTitle = GUICtrlCreateLabel("Please, select elements to convert:", 65, 15, 170, 17, $SS_CENTER) Local $acmbMode[3] $acmbMode[0] = "Convert drawings and parts" $acmbMode[1] = "Only convert parts" $acmbMode[2] = "Convert drawings and assemblies" Local $cmbMode = GUICtrlCreateCombo("", 45, 45, 210, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetOnEvent(-1, "_cmbModeFunction") ;Set the combo box's function GUICtrlSetData(-1, $acmbMode[0] & "|" & $acmbMode[1] & "|" & $acmbMode[2]) Local $alblExplanation[3] $alblExplanation[0] = "Parts and drawings" & @LF & "will be converted and linked" $alblExplanation[1] = "Only parts will be converted" $alblExplanation[2] = "Assemblies and drawings" & @LF & "will be converted and linked" & @LF & @LF & "Assemblies must exist on input folder!" Local $lblExplanation = GUICtrlCreateLabel("", 45, 90, 210, 100, $SS_CENTER) Local $btnOK = GUICtrlCreateButton("&OK", 125, 160, 50, 25) GUICtrlSetOnEvent(-1, "_btnOKFunction") ;Set the button's function GUICtrlSetState(-1, $GUI_DISABLE) GUISetOnEvent($GUI_EVENT_CLOSE, "_frmExitGUIFunction") ;What function to call when we try close the GUI #endregion Input Form definition GUISetState(@SW_SHOW) Local $astrMode[3] $astrMode[0] = "3D+2D" $astrMode[1] = "3D" $astrMode[2] = "ASSY+2D" Global $strMode = $astrMode[0] ;Endless While loop to keep the GUI Open While 1 Sleep(10); So we don't use heaps of CPU WEnd #region Event functions Func _cmbModeFunction() For $i = 0 To 2 If GUICtrlRead($cmbMode) = $acmbMode[$i] Then $strMode = $astrMode[$i] GUICtrlSetData($lblExplanation, $alblExplanation[$i]) GUICtrlSetState($btnOK, $GUI_ENABLE) ExitLoop EndIf Next EndFunc ;==>_cmbModeFunction Func _btnOKFunction() MsgBox(64, "Mode...", $strMode) ;Check! GUIDelete() ;It closes the window EndFunc ;==>_btnOKFunction Func _frmExitGUIFunction() Exit ;Exit the program EndFunc ;==>_frmExitGUIFunction #endregion Event functions MsgBox(65, "Return value...", $strMode) ;Final check ($strMode is used after) Thanks in advance!
Moderators JLogan3o13 Posted June 27, 2013 Moderators Posted June 27, 2013 Look at these three lines. You are disabling the button: Local $btnOK = GUICtrlCreateButton("&OK", 125, 160, 50, 25) GUICtrlSetOnEvent(-1, "_btnOKFunction") ;Set the button's function GUICtrlSetState(-1, $GUI_DISABLE) <------------- "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Moderators Solution Melba23 Posted June 27, 2013 Moderators Solution Posted June 27, 2013 XabiK,Welcome to the AutoIt forum. I suppose it's just a silly mistake of mineIndeed it is - but a very easy one to make. Your $lblExplanation label is very large and overlaps with the button - as AutoIt now cannot tell which should be actioned (because labels can be clicked too) it reacts to neither. Two solutions: either shorten your label so the 2 controls do not overlap or remove the $SS_NOTIFY style from the label when you create it. I think the first is the way to go. 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
XabiK Posted June 27, 2013 Author Posted June 27, 2013 XabiK, Welcome to the AutoIt forum. Indeed it is - but a very easy one to make. Your $lblExplanation label is very large and overlaps with the button - as AutoIt now cannot tell which should be actioned (because labels can be clicked too) it reacts to neither. Two solutions: either shorten your label so the 2 controls do not overlap or remove the $SS_NOTIFY style from the label when you create it. I think the first is the way to go. M23 Thanks a lot!!! I didn't notice the size of the label control because I didn't use Koda (BTW, it's a wonderful tool) Yeah: I did modify the label size and button position... it works!!! BR
XabiK Posted June 27, 2013 Author Posted June 27, 2013 (edited) Look at these three lines. You are disabling the button: Local $btnOK = GUICtrlCreateButton("&OK", 125, 160, 50, 25) GUICtrlSetOnEvent(-1, "_btnOKFunction") ;Set the button's function GUICtrlSetState(-1, $GUI_DISABLE) <------------- Hi! Thanks for your interest... but the '$GUI_DISABLE' thing it's a feature, not a bug Actually, I enable the button a bit later, when the user selects an actual option from the combo box: ... If GUICtrlRead($cmbMode) = $acmbMode[$i] Then $strMode = $astrMode[$i] GUICtrlSetData($lblExplanation, $alblExplanation[$i]) GUICtrlSetState($btnOK, $GUI_ENABLE) <------------- ExitLoop ... EndIf Edited June 27, 2013 by XabiK
Moderators Melba23 Posted June 27, 2013 Moderators Posted June 27, 2013 XabiK,Top tip: Colour your labels when you create a GUI - then you can see exactly where they are. Remove the colouring when you have it all ready to run. 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
Moderators JLogan3o13 Posted June 27, 2013 Moderators Posted June 27, 2013 Serves me right for reading through too fast, I missed your enabling of the button completely Glad you were able to get it worked out. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Moderators Melba23 Posted June 27, 2013 Moderators Posted June 27, 2013 JLogan3o13,I felt the same when I read your post - until I went back and checked. 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
Normonator Posted June 27, 2013 Posted June 27, 2013 I personally like to add $SS_SUNKEN as a style to my labels to see the borders while testing. [member='That Guy']~~Normonator~~
meisandy Posted June 27, 2013 Posted June 27, 2013 XabiK,Top tip: Colour your labels when you create a GUI - then you can see exactly where they are. Remove the colouring when you have it all ready to run. M23 Nice tip! I shall have to remember that for the next time I'm creating a GUI. Presumably this is also handy for any control that allows you to set a background colour and might get confused with the main window. By the way OP, nice hint. Very... helpful
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