randym Posted August 26, 2015 Share Posted August 26, 2015 (edited) I used Koda to design a form, I set it up so that all but the first field is disabled. I click in the first field to get focus, and enter data. No problem. If I then hit 'Enter' - my code runs that enables the other fields and sets defaults and the like. However, if I hit 'Tab' instead, then all that happens is the data in the field is high-lited and the code associated with the field is never run. Is this as it should be, or have I done something wrong.Weird thing is, once the other fields are enabled, it looks like 'Tab' works, but 'Enter' does not .... - I am confused.Randyexpandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $arr = [] ; NOTE this creates an array of size 1 with an empty string Global $Start, $End #Region ### START Koda GUI section ### Global $CharmROG_Form = GUICreate("Charm City ROG Automation", 566, 302, -1, -1) Global $Label1 = GUICtrlCreateLabel("Receipt No", 8, 16, 58, 17) Global $Label2 = GUICtrlCreateLabel("PO No", 208, 16, 36, 17) Global $Label3 = GUICtrlCreateLabel("Inv No", 384, 16, 36, 17) Global $ML_ReceiptNo = GUICtrlCreateInput("Receipt Number", 72, 16, 121, 21) Global $ML_PONo = GUICtrlCreateInput("Purchase Order", 256, 16, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $ML_InvNo = GUICtrlCreateInput("Invoice Number", 424, 16, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $Label4 = GUICtrlCreateLabel("Start Line", 8, 48, 49, 17) Global $Label5 = GUICtrlCreateLabel("End Line", 200, 48, 46, 17) Global $ML_StartLine = GUICtrlCreateInput("Starting Detail Dist Line", 72, 48, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $ML_EndLine = GUICtrlCreateInput("Ending Detail Dist Line", 256, 48, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $Checkbox1 = GUICtrlCreateCheckbox("Existing ROG", 384, 48, 161, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) GUICtrlSetState(-1, $GUI_DISABLE) Global $Input1 = GUICtrlCreateInput("Lot Date", 72, 80, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $List1 = GUICtrlCreateList("", 201, 80, 183, 175) GUICtrlSetData(-1, "Lot Dates") GUICtrlSetState(-1, $GUI_DISABLE) Global $Label6 = GUICtrlCreateLabel("Lot Date", 12, 80, 49, 17) Global $Button1 = GUICtrlCreateButton("Process", 456, 264, 89, 25) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ML_ReceiptNo GUICtrlSetData($ML_PONo, GUICtrlRead($ML_ReceiptNo)) GUICtrlSetData($ML_InvNo, GUICtrlRead($ML_ReceiptNo)) EnableForm() GUICtrlSetState($ML_EndLine, $GUI_FOCUS) GUISetState(@SW_SHOW) Case $ML_StartLine Validate_StartEnd () Case $ML_EndLine Validate_StartEnd() EndSwitch WEnd Func EnableForm() GUICtrlSetState($ML_PONo, $GUI_ENABLE) GUICtrlSetState($ML_InvNo, $GUI_ENABLE) GUICtrlSetData($ML_StartLine, 1) GUICtrlSetState($ML_StartLine, $GUI_ENABLE) GUICtrlSetData($ML_EndLine, 1) GUICtrlSetState($ML_EndLine, $GUI_ENABLE) GUICtrlSetState($Checkbox1, $GUI_ENABLE) GUICtrlSetState($Input1, $GUI_ENABLE) ;GUICtrlSetState($List1, $GUI_ENABLE) GUICtrlSetState($Button1, $GUI_ENABLE) GUISetState(@SW_SHOW) EndFunc ;==>EnableForm Func Validate_StartEnd() Get_StartEnd() If $End < $Start Then GUICtrlSetData($ML_EndLine, $Start) GUISetState(@SW_SHOW) EndIf EndFunc ;==>Validate_StartEnd Func Get_StartEnd() $Start = GUICtrlRead($ML_StartLine) $End = GUICtrlRead($ML_EndLine) EndFunc ;==>Get_StartEnd Edited August 26, 2015 by randym Further research shed new info And the sign said 'Long Hairded Creepy People Need Not Apply' ... So I stuffed my hair up under my hat and I went in to ask him why? Link to comment Share on other sites More sharing options...
spudw2k Posted August 26, 2015 Share Posted August 26, 2015 Looks like the event firing from the control (I assuming the event is CHANGED) doesn't fire when you Tab off the control. You might have to write your own handler to fire your code upon changed or lost focus events. You'll also want to put in some logic to verify the validity of the Receipt #. Just my two cents.Google "autoit $WM_COMMAND GUIRegisterMsg" to see some examples. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Skysnake Posted August 27, 2015 Share Posted August 27, 2015 Maybe see this entry? FAQ {enter} like TabI suspect that the Tab merely moves to the next control, whereas Enter presses the default button. Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
jguinch Posted August 27, 2015 Share Posted August 27, 2015 Here is a way :expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $arr = [] ; NOTE this creates an array of size 1 with an empty string Global $Start, $End #Region ### START Koda GUI section ### Global $CharmROG_Form = GUICreate("Charm City ROG Automation", 566, 302, -1, -1) Global $Label1 = GUICtrlCreateLabel("Receipt No", 8, 16, 58, 17) Global $Label2 = GUICtrlCreateLabel("PO No", 208, 16, 36, 17) Global $Label3 = GUICtrlCreateLabel("Inv No", 384, 16, 36, 17) Global $ML_ReceiptNo = GUICtrlCreateInput("Receipt Number", 72, 16, 121, 21) Global $ML_PONo = GUICtrlCreateInput("Purchase Order", 256, 16, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $ML_InvNo = GUICtrlCreateInput("Invoice Number", 424, 16, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $Label4 = GUICtrlCreateLabel("Start Line", 8, 48, 49, 17) Global $Label5 = GUICtrlCreateLabel("End Line", 200, 48, 46, 17) Global $ML_StartLine = GUICtrlCreateInput("Starting Detail Dist Line", 72, 48, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $ML_EndLine = GUICtrlCreateInput("Ending Detail Dist Line", 256, 48, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $Checkbox1 = GUICtrlCreateCheckbox("Existing ROG", 384, 48, 161, 25, BitOR($GUI_SS_DEFAULT_CHECKBOX, $BS_RIGHTBUTTON)) GUICtrlSetState(-1, $GUI_DISABLE) Global $Input1 = GUICtrlCreateInput("Lot Date", 72, 80, 121, 21) GUICtrlSetState(-1, $GUI_DISABLE) Global $List1 = GUICtrlCreateList("", 201, 80, 183, 175) GUICtrlSetData(-1, "Lot Dates") GUICtrlSetState(-1, $GUI_DISABLE) Global $Label6 = GUICtrlCreateLabel("Lot Date", 12, 80, 49, 17) Global $Button1 = GUICtrlCreateButton("Process", 456, 264, 89, 25) GUICtrlSetState(-1, $GUI_DISABLE) $dummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [ ["{TAB}", $dummy] ] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ML_StartLine Validate_StartEnd () Case $ML_EndLine Validate_StartEnd() Case $dummy If ControlGetHandle($CharmROG_Form, "", ControlGetFocus($CharmROG_Form) ) = GUICtrlGetHandle($ML_ReceiptNo) Then GUISetAccelerators("") GUICtrlSetData($ML_PONo, GUICtrlRead($ML_ReceiptNo)) GUICtrlSetData($ML_InvNo, GUICtrlRead($ML_ReceiptNo)) EnableForm() GUICtrlSetState($ML_EndLine, $GUI_FOCUS) GUISetState(@SW_SHOW) EndIf EndSwitch WEnd Func EnableForm() GUICtrlSetState($ML_PONo, $GUI_ENABLE) GUICtrlSetState($ML_InvNo, $GUI_ENABLE) GUICtrlSetData($ML_StartLine, 1) GUICtrlSetState($ML_StartLine, $GUI_ENABLE) GUICtrlSetData($ML_EndLine, 1) GUICtrlSetState($ML_EndLine, $GUI_ENABLE) GUICtrlSetState($Checkbox1, $GUI_ENABLE) GUICtrlSetState($Input1, $GUI_ENABLE) ;GUICtrlSetState($List1, $GUI_ENABLE) GUICtrlSetState($Button1, $GUI_ENABLE) GUISetState(@SW_SHOW) EndFunc ;==>EnableForm Func Validate_StartEnd() Get_StartEnd() If $End < $Start Then GUICtrlSetData($ML_EndLine, $Start) GUISetState(@SW_SHOW) EndIf EndFunc ;==>Validate_StartEnd Func Get_StartEnd() $Start = GUICtrlRead($ML_StartLine) $End = GUICtrlRead($ML_EndLine) EndFunc ;==>Get_StartEnd randym 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
spudw2k Posted August 27, 2015 Share Posted August 27, 2015 Here is a way :Clever work around Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
randym Posted August 28, 2015 Author Share Posted August 28, 2015 Thanks jguinch - it is a clever work around... I saw in the documentation I was reading about doing something like this, but you turning my gui into a working example really brought it home. And the sign said 'Long Hairded Creepy People Need Not Apply' ... So I stuffed my hair up under my hat and I went in to ask him why? 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