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:
#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!