Hobbyist Posted July 19, 2014 Posted July 19, 2014 In my GUI I have an Input Box that after entering data moves the focus to a ComboBox where a selection is to be entered. Upon hitting the enter key the data from the Input Box and the selection in the ComboBox are supposed to be moved to a Listview. But when I hit the enter key at the Input Box stage the data gets entered into the Listview and doesn't wait for my selection at the ComboBox. I have tried different scenarios of _WinAPI, Focus, _ispressed etc but nothing seems to be working to a solution. I have just learned a ComboBox has three parts: the combo, the edit, the drop down. From what I read I believe the focus from the Input Box to the Combo is going to the edit box, if that matters. Any suggestions on how to proceed would be appreciated. Thanks from a noo bee.
BrewManNH Posted July 19, 2014 Posted July 19, 2014 Post your script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Developers Jos Posted July 19, 2014 Developers Posted July 19, 2014 Stoex, any reason you created a new membername? In case you want help with an script it does help to post a snippet that shows the issue. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators Melba23 Posted July 19, 2014 Moderators Posted July 19, 2014 Jos,Stoex and I have already discussed that - it is another member of the same family. 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
Developers Jos Posted July 19, 2014 Developers Posted July 19, 2014 Stoex and I have already discussed that - it is another member of the same family. I am fine with a Happy family. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Hobbyist Posted July 20, 2014 Author Posted July 20, 2014 Two people using the same sign on was hazardous - HA! Any way its just me, myself and I. We were trying to learn this Autoit together but I think it got the best of him. To the post.... Here is part of the code that I believe is part of my problem but I am not as versed in this scripting as the vast majority of posters. expandcollapse popupcEnterPressed = GUICtrlCreateDummy() _GUICtrlComboBox_GetComboBoxInfo($hcombo, $tInfo) $hEdit = DllStructGetData($tInfo, "hEdit") $hlist = DllStructGetData($tInfo, "hList") While 1 blah blah blah code - - - - Case $AEamounts $AEmoney = GUICtrlRead ( $AEamounts ) if ($AEmoney/$AEmoney) = 1 And _IsPressed("0D") Then GUICtrlSetState ($hcombo, $GUI_FOCUS) EndIf if ($AEmoney/$AEmoney) <> 1 Then MsgBox($MB_SYSTEMMODAL, "Information", "Must Be Number ") _aeReset () EndIf Case $cEnterPressed If _WinAPI_GetFocus() = $hEdit Then $MMM =_GUICtrlComboBox_GetCurSel($combo_b) _GUICtrlComboBox_GetLBText($combo_b, $MMM, $NNN) GUICtrlCreateListViewItem(GUICtrlRead($hcombo)&"|"& $NNN &"|"& $AEmoney, $List1) _GUICtrlComboBox_ShowDropDown($hcombo, False) GUICtrlSetState ($hcombo, $GUI_FOCUS) EndIf I think what is happening is when the focus moves to the Combobox(edit), the code following the "if" immediately executes NOT allowing me to type my selection or expand the list box, highlight and hit enter for my selection. Now using the mouse works great - focus happens, expand list box, make selection and click - everything is fine. So I think I know what is wrong but I really don't know how to get it to do what i want. I tried something like: If _IsPressed("0D") = True And _WinAPI_GetFocus() = $hEdit Then "execute the script" I thought that would allow me to type my selection or arrow through the list box and select AND then hit enter and then the balance of the code would work. NADA.
BrewManNH Posted July 20, 2014 Posted July 20, 2014 I would like to suggest posting a script that runs that demonstrates the problem you're having. Trying to trouble shoot your problem with such a small section of your code is like trying to paint a room through a keyhole. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Hobbyist Posted July 20, 2014 Author Posted July 20, 2014 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> #include <Misc.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> #include <ColorConstants.au3> #include <EditConstants.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Autoit Trys\Vendors Trials\My combo Form Test.kxf $main = GUICreate("Vendor Category Selection", 680, 401, 150, 100) $combo_b = GUICtrlCreateCombo("", 10, 26, 70, 25) GUICtrlSetData(-1, "a|B|C|D|E|F|G") $AEamounts = GUICtrlCreateInput("", 96, 26, 70, 21); $hcombo = GUICtrlCreateCombo("", 274, 26, 300, 25) GUICtrlSetData(-1, "a|L|M|N|Na|O|P") $List1 = GUICtrlCreateListview("", 192, 72, 470, 260,$LVS_SINGLESEL, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT) GUICtrlSetBkColor($List1, $COLOR_aqua) _GUICtrlListView_AddColumn($list1, "Vendor",290) _GUICtrlListView_AddColumn($list1, "Category", 90) _GUICtrlListView_AddColumn($list1, "Amount", 160) $Button12 = GUICtrlCreateButton("Save Files", 10, 60, 158, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xE3E3E3) $Button13 = GUICtrlCreateButton("Delete Record", 10, 100, 158, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xE3E3E3) $Label1 = GUICtrlCreateLabel("Your Entries", 390, 53, 73, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) $Label2 = GUICtrlCreateLabel("Category", 16, 8, 54, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel(" Amount", 104, 8, 50, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("Vendor", 392, 8, 44, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $fComboSelected = False GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) Global $tInfo, $fComboActive = False Global $fComboActive2 = False _GUICtrlComboBox_GetComboBoxInfo($hcombo, $tInfo) $hEdit = DllStructGetData($tInfo, "hEdit") $hlist = DllStructGetData($tInfo, "hList") $cEnterPressed = GUICtrlCreateDummy() $cEnterPressed2 = GUICtrlCreateDummy() GUISetState() Global $aAccelKeys[1][2] = [["{ENTER}", $cEnterPressed]] GUISetAccelerators($aAccelKeys) global $mycounter = _GUICtrlListView_GetItemCount ( $List1 ) Global $MMM Global $NNN Global $AEmoney While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP If $fComboActive2 Then GUICtrlSetState ($AEamounts, $GUI_FOCUS) EndIf If $fComboActive Then $MMM =_GUICtrlComboBox_GetCurSel($combo_b) _GUICtrlComboBox_GetLBText($combo_b, $MMM, $NNN) GUICtrlCreateListViewItem(GUICtrlRead($hcombo)&"|"& $NNN &"|"& $AEmoney , $List1) _GUICtrlComboBox_SetCurSel ( $hcombo , -1 ) _GUICtrlComboBox_SetCurSel ( $combo_b , -1 ) $fComboActive = False _GUICtrlComboBox_ShowDropDown($hcombo, False) _aeReset () EndIf _blanker() Case $cEnterPressed If _WinAPI_GetFocus() = $hEdit Then $MMM =_GUICtrlComboBox_GetCurSel($combo_b) _GUICtrlComboBox_GetLBText($combo_b, $MMM, $NNN) GUICtrlCreateListViewItem(GUICtrlRead($hcombo)&"|"& $NNN &"|"& $AEmoney, $List1) _GUICtrlComboBox_ShowDropDown($hcombo, False) GUICtrlSetState ($hcombo, $GUI_FOCUS) GUICtrlRead ( $List1 ) EndIf _aeReset () ;_blanker() Case $AEamounts $AEmoney = GUICtrlRead ( $AEamounts ) if ($AEmoney/$AEmoney) = 1 And _IsPressed("0D") Then ; checking for number entry GUICtrlSetState ($hcombo, $GUI_FOCUS) EndIf if ($AEmoney/$AEmoney) <> 1 Then MsgBox($MB_SYSTEMMODAL, "Information", "Must Be Number ") _aeReset () EndIf Case $List1 Case $Button12 Case $Button13 Global $zzzz =_GUICtrlListView_GetSelectedIndices ( $List1 ) DoubleClickFunc() EndSwitch If _GUICtrlComboBox_GetDroppedState($hcombo) = True Then $fComboActive = True EndIf If _GUICtrlComboBox_GetDroppedState($combo_b) = True Then $fComboActive2 = True EndIf WEnd Func _Edit_Changed($hcombo) ; <<<<<<<<<<<<<<<<<<<<< _GUICtrlComboBox_AutoComplete($hcombo) ; <<<<<<<<<<<<<<<<<<<<< EndFunc ;==>_Edit_Changed Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $iCode Case $CBN_EDITCHANGE Switch $iIDFrom Case $hcombo _Edit_Changed($hcombo) ; <<<<<<<<<<<<<<<<<<<<< Case $combo_b _Edit_Changed($combo_b) ; <<<<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Blanker() ; trying to catch blank field global $blankcount $blankcount = _GUICtrlListView_GetItemCount ( $List1 ) for $i = (($blankcount) -1) to 0 step -1 if (_GUICtrlListView_GetItemText ( $List1, $i )) = "" then _GUICtrlListView_DeleteItem ( $List1, $i ) EndIf Next EndFunc Func DoubleClickFunc() ; for the delete button Global $DoubleClicked = False GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") local $msgText = GUICtrlRead(GUICtrlRead($List1)) local $msgText2 = StringTrimRight ( $msgText, 3 ) local $msgCheck = MsgBox(4, "OK to : ", "Delete Entry: " & $msgText2) If $msgCheck = 6 then _GUICtrlListView_DeleteItemsSelected ( $List1 ) EndIf EndFunc Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $List1 And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSG EndFunc Func _aeReset () ; for resetting all fields to blank in anticipation of the next entry $NNN = "" GUICtrlSetData($AEamounts, "") $AEMoney =0.0 GUICtrlSetState ($combo_b, $GUI_FOCUS) _GUICtrlComboBox_SetCurSel ( $combo_b , -1 ) _GUICtrlComboBox_SetCurSel ( $hcombo , -1 ) EndFunc BrewManNH- You are right. Here is the code. To see what I am talking about do these two scenarios: One; 1st Combo click and make selection Amount Input - enter number BUT click to 2nd Combobox (DON't press enter to enter Amount) Using mouse, click open the list view of the 2nd Combobox, make selection. Or start typing selection and the editbox populates choices(if matching typing) Result: ListView gets updated as desired. AND ALL the fields(of input/selection) are reset to blank. This is the desired outcome. Two: 1st Combo click and make selection. Amount input - enter number/USE Enter key Result: Focus moves to 2nd Combobox BUT it updates the ListView BEFORE a selection can be made in the 2nd Combobox. Not desired outcome. Thanks for any suggestions. Its gotta be possible, but i am not seeing it.
Moderators Melba23 Posted July 20, 2014 Moderators Posted July 20, 2014 Hobbyist,Try checking to see if you have a selection in the second combo before actioning the {ENTER} press:Case $cEnterPressed If _WinAPI_GetFocus() = $hEdit And GUICtrlRead($hcombo) Then ; <<<<<<<<<<<<<<<<<<<<<<<<Now you will not create the ListView item until you have a selection in each combo and you press {ENTER} with focus on the input. 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
Hobbyist Posted July 24, 2014 Author Posted July 24, 2014 Thanks M23!!! That helps a lot. I didn't think of that, but can now see its importance.
Moderators Melba23 Posted July 25, 2014 Moderators Posted July 25, 2014 Hobbyist,Always helps to have another pair of eyes look at the problem - glad I could be of assistance. 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
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