panuys Posted February 7, 2011 Share Posted February 7, 2011 expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include #include #include #include #include #include Global Const $TitleTxt = "EEPROM Tests", $Ver = "101.00" Global $AssyType Global $inpHPartNum, $inpHSerialNum Global $TestRes Global $inpSerialNum[4], $inpPartNum[4] Global $SerLabel[4], $PartLabel[4] Global $btnExit, $btnStart ;Opt("GUIDataSeparatorChar", "|") Opt("GUICloseOnESC", 1) ;Create main window.----------------------------------------------------------------------------- Opt("GUIOnEventMode", 1) ;1: enable OnEventMode GUICreate($TitleTxt, 500, 540) ;create main dialog box GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;if [EXIT] is pressed then exit GUICtrlCreateLabel ("Script Rev - "&$Ver, 1010, 3, 90) ;display rev label GUICtrlSetColor(-1,0xff0000) ; red ;Create ComboBox ----------------------------------------------------------------------------------------------- GUICtrlCreateLabel ("Assembly to Test", 80, 10, 82) $AssyType = GUICtrlCreateCombo ( "", 170, 10, 108, 88) GUICtrlSetData(-1, "747-1111|747-2222|747-3333","747-2222") $btnStart = GUICtrlCreateButton ("START", 75, 370 ,80, 25) ;Create Start button GUICtrlSetOnEvent($btnStart, "StartClicked") $btnExit = GUICtrlCreateButton ("EXIT", 300, 370, 80, 25) ;Create Exit button GUICtrlSetOnEvent($btnExit, "CLOSEClicked") ;Top Level Assy ----------------------------------------------------------------------------------- GUICtrlCreateLabel ("TOP Part Number", 210, 60, 98) $inpHPartNum = GUICtrlCreateInput ( GUICtrlRead($AssyType), 310, 60, 75, 18) ;Create Input for Part Number GUICtrlCreateLabel ("TOP Serial Number", 210, 40, 98) $inpHSerialNum = GUICtrlCreateInput ( "", 310, 40, 50, 18) ;Create Input for Serial Number GUICtrlSetLimit(-1, 6) ; to limit the entry to 6 chars GUICtrlSetOnEvent($inpHSerialNum, "StartClicked") $TestRes = GUICtrlCreateEdit("", 10, 410, 400, 120, BitOr($ES_AUTOVSCROLL,$WS_VSCROLL,$WS_HSCROLL)) GUICtrlSetLimit ( $TestRes, 1000000 ) GUICtrlSetOnEvent($TestRes, "StartClicked") ; WHY shows when [START] not clicked yet GUICtrlSetOnEvent($AssyType, "SetUpApp") GUISetState () ; Just idle around While 1 Sleep(10) WEnd Func CLOSEClicked() Exit EndFunc Func SetUpApp() Local $j GUICtrlSetData($TestRes, "") ;clear for new data entry GUICtrlSetData($inpHSerialNum, "") ;clear for new data entry Local $top = 110 For $j = 1 to 3 $PartLabel[$j] = GUICtrlCreateLabel ("Part Number_Bd" & $j, 190, $top, 98) $inpPartNum[$j] = GUICtrlCreateInput (StringTrimRight(GUICtrlRead($AssyType),2), 282, $top, 85, 18) $SerLabel[$j] = GUICtrlCreateLabel ("Serial Number_Bd" & $j, 10, $top, 98) $inpSerialNum[$j] = GUICtrlCreateInput ( "", 110, $top, 70, 18) ; WHY previous selected asy. SN shows GUICtrlSetOnEvent($inpSerialNum[$j], "StartClicked") $top = $top + 30 ; controls spacing Next $j = 0 EndFunc ;SetUpApp Func StartClicked() ;[Start] clicked GUICtrlSetData($TestRes, "") ;clear for new data entry GUICtrlSetData($TestRes, StringFormat("TOP Serial Number=%s\r\n", GUICtrlRead($inpHSerialNum)), 1) Local $i For $i = 1 To 3 ;The for loop only works the first selection from ComboBox. GUICtrlSetData($TestRes, StringFormat("Serial Number_Bd" & $i & "=%s\r\n", GUICtrlRead($inpSerialNum[$i])), 1) Next $i= 0 EndFunc ;StartClicked ; --------------------------------------------------------------------------------------------------------This script has the following bugs: Data are shown in the EDIT CONTROL area (Should Be only when the START button is clicked). All INPUT CONTROLs are OK only the first time when any item selected from the drop-down of the ComboBox but the following attemps, why instead of BLANK before any data entry, previous values are shown after the CONTROLs are BLANK for awhile? and why the Board Serial Number are not accepted. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2011 Moderators Share Posted February 7, 2011 panuys, Welcome to the AutoIt forum. Data are shown in the EDIT CONTROL area (Should Be only when the START button is clicked).Then you need to remove the GUICtrlSetOnEvent(ControlID, "StartClicked") lines from everything other than the "Start" button. why instead of BLANK before any data entry, previous values are shown after the CONTROLs are BLANK for awhile?Because you are creating new inputs each time and the old ones are showing through. The easy way to solve this is to delete the labels and inputs each time you run the SetUpApp function. A better way to solve it would be to create the labels and inputs only once and then empty them each time. I hope this does what you want now - look for the <<<<<<<<<<<<<<< lines: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global Const $TitleTxt = "EEPROM Tests", $Ver = "101.00" Global $AssyType Global $inpHPartNum, $inpHSerialNum Global $TestRes Global $inpSerialNum[4], $inpPartNum[4] Global $SerLabel[4], $PartLabel[4] Global $btnExit, $btnStart ;Opt("GUIDataSeparatorChar", "|") Opt("GUICloseOnESC", 1) ;Create main window.----------------------------------------------------------------------------- Opt("GUIOnEventMode", 1) ;1: enable OnEventMode GUICreate($TitleTxt, 500, 540) ;create main dialog box GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ;if [EXIT] is pressed then exit GUICtrlCreateLabel("Script Rev - " & $Ver, 1010, 3, 90) ;display rev label GUICtrlSetColor(-1, 0xff0000) ; red ;Create ComboBox ----------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Assembly to Test", 80, 10, 82) $AssyType = GUICtrlCreateCombo("", 170, 10, 108, 88) GUICtrlSetData(-1, "747-1111|747-2222|747-3333", "747-2222") GUICtrlSetOnEvent($AssyType, "SetUpApp") $btnStart = GUICtrlCreateButton("START", 75, 370, 80, 25) ;Create Start button GUICtrlSetOnEvent($btnStart, "StartClicked") ; This is where you register "StartClicked" <<<<<<<<<<<<<<<<<<< $btnExit = GUICtrlCreateButton("EXIT", 300, 370, 80, 25) ;Create Exit button GUICtrlSetOnEvent($btnExit, "CLOSEClicked") ;Top Level Assy ----------------------------------------------------------------------------------- GUICtrlCreateLabel("TOP Part Number", 210, 60, 98) $inpHPartNum = GUICtrlCreateInput(GUICtrlRead($AssyType), 310, 60, 75, 18) ;Create Input for Part Number GUICtrlCreateLabel("TOP Serial Number", 210, 40, 98) $inpHSerialNum = GUICtrlCreateInput("", 310, 40, 50, 18) ;Create Input for Serial Number GUICtrlSetLimit(-1, 6) ; to limit the entry to 6 chars ;GUICtrlSetOnEvent($inpHSerialNum, "StartClicked") ; Delete this <<<<<<<<<<<<<<<<<<<<<<<<<<<< $TestRes = GUICtrlCreateEdit("", 10, 410, 400, 120, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetLimit($TestRes, 1000000) ;GUICtrlSetOnEvent($TestRes, "StartClicked") ; WHY shows when [START] not clicked yet ; Delete this <<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() ; Just idle around While 1 Sleep(10) WEnd Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked Func SetUpApp() ;Local $j ; variables in For...Next loops are automatically Local <<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetData($TestRes, "") ;clear for new data entry GUICtrlSetData($inpHSerialNum, "") ;clear for new data entry Local $top = 110 For $j = 1 To 3 GUICtrlDelete($PartLabel[$j]) ; Delete previous control <<<<<<<<<<<<<<<<<<<<<<<<<<<< $PartLabel[$j] = GUICtrlCreateLabel("Part Number_Bd" & $j, 190, $top, 98) GUICtrlDelete($inpPartNum[$j]) ; Delete previous control <<<<<<<<<<<<<<<<<<<<<<<<<<<< $inpPartNum[$j] = GUICtrlCreateInput(StringTrimRight(GUICtrlRead($AssyType), 2), 282, $top, 85, 18) GUICtrlDelete($SerLabel[$j]) ; Delete previous control <<<<<<<<<<<<<<<<<<<<<<<<<<<< $SerLabel[$j] = GUICtrlCreateLabel("Serial Number_Bd" & $j, 10, $top, 98) GUICtrlDelete($inpSerialNum[$j]) ; Delete previous control <<<<<<<<<<<<<<<<<<<<<<<<<<<< $inpSerialNum[$j] = GUICtrlCreateInput("", 110, $top, 70, 18) ; WHY previous selected asy. SN shows ;GUICtrlSetOnEvent($inpSerialNum[$j], "StartClicked") ; Delete this <<<<<<<<<<<<<<<<<<<<<<<<<<<< $top = $top + 30 ; controls spacing Next ;$j = 0 EndFunc ;==>SetUpApp Func StartClicked() ;[Start] clicked GUICtrlSetData($TestRes, "") ;clear for new data entry GUICtrlSetData($TestRes, StringFormat("TOP Serial Number=%s\r\n", GUICtrlRead($inpHSerialNum)), 1) ;Local $i ; variables in For...Next loops are automatically Local <<<<<<<<<<<<<<<<<<<<<<<<<<<<< For $i = 1 To 3 ;The for loop only works the first selection from ComboBox. GUICtrlSetData($TestRes, StringFormat("Serial Number_Bd" & $i & "=%s\r\n", GUICtrlRead($inpSerialNum[$i])), 1) Next ;$i = 0 EndFunc ;==>StartClicked 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...
panuys Posted February 8, 2011 Author Share Posted February 8, 2011 Thank you very much. All clear! Work great! Link to comment Share on other sites More sharing options...
panuys Posted February 9, 2011 Author Share Posted February 9, 2011 Now, how can I use inputs from a scanner instead of manually enter data onto inputs? 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