which1 Posted December 24, 2012 Share Posted December 24, 2012 Hi everybody, I'm triyng to alter the behaviour of the ENTER key according to the Tab control which has the focus. Everything works fine till I want the ENTER key to behave "normally", say in $hInput_2 to provoke a carriage return, for instance. Here in the concerned portion of code : #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $hGUI = GUICreate("Test", 500, 500) $_DEFPUSHBUTTON = GUICtrlCreateButton("", -100, -100, 1,1, $BS_DEFPUSHBUTTON) $tab = GUICtrlCreateTab(10, 10, 400, 400) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 100) $tab1 = GUICtrlCreateTabItem("tab 1") $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 100) $tab2 = GUICtrlCreateTabItem("tab 2") $hInput_2 = GUICtrlCreateInput("", 20, 80, 150, 100) GUISetState() $iCurrIndex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $_DEFPUSHBUTTON Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed_0() Case $tab1 _Pressed_1() Case $tab2 ;Problem here Send ("{ENTER}") ;Doens't work properly EndSwitch EndSwitch WEnd Func _Pressed_0() ConsoleWrite("Hit_0" & @CRLF) EndFunc Func _Pressed_1() ConsoleWrite("Hit_1" & @CRLF) EndFunc I hope I wasn't too casual in my researches on the Net ; Thanks for only pointing me a Topic if I was. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 24, 2012 Moderators Share Posted December 24, 2012 which1,How do you determine that the script is not sending {ENTER}? Inputs are funny beasts and pressing enter within them will only fire an event if something has already been entered. Try running this script and press "ENTER" within nothing in the input - the control does not fire. If you now type something in the input and press "ENTER" you get the MsgBox. #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cInput MsgBox(0, "Input", "Fired") EndSwitch WEndM23 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...
which1 Posted December 25, 2012 Author Share Posted December 25, 2012 Melba23,Thank you very much for answering....funny beasts indeed ! I ran your script with the following results :- void input : not fired- populated input : fired- after deleting the input with Backspace : fired a very last time...But so far, this behaviour doens't bother me ; On the contrary, knowing the reaction of a control allows me to use it somehow. So... thanks for the hint ! It remains further that running my piece of script shows that 'tab 2' doens't answer to the ENTER key at all, even with $hInput_2 duly filled up. Though, after pressing n times the ENTER key in tab 2, I get n/2 times Hit_1 on the console whenselecting tab 1. Obviously not what I intended I mean $hInput_2 to be a text input bound to a SQLite database. Therefor, what I wish is the ENTER key to behave ' like usual in a text edit ' when fired from $hInput_2.I'll try to find out by myself how to resolve that point, but maybe you could save me lots of guesswork and head-scratching .Later on, I'd like to specialize the Space Bar aswell, in order to behave in accordance with the focused Edit Control in the focused Tab Control.But I digress. ENTER first ! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 25, 2012 Moderators Share Posted December 25, 2012 which1,Joyeux Noel! Try this and see if it does what you want - ENTER acts as normal on Tab2 and as a default button on the other 2:expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $tab = GUICtrlCreateTab(10, 10, 400, 400) $tabhandle = GUICtrlGetHandle($tab) $tab0 = GUICtrlCreateTabItem("tab 0") $hInput_0 = GUICtrlCreateInput("", 20, 80, 150, 100) $tab1 = GUICtrlCreateTabItem("tab 1") $hInput_1 = GUICtrlCreateInput("", 50, 80, 150, 100) $tab2 = GUICtrlCreateTabItem("tab 2") $hInput_2 = GUICtrlCreateEdit("", 20, 80, 150, 100) GUICtrlCreateTabItem("") $cDummy = GUICtrlCreateDummy() ; Set GUIAccelerators for the button controlIDs, these being Ctrl + y and Ctrl + n Local $aAccelKeys[1][2] = [["{ENTER}", $cDummy]] GUISetAccelerators($aAccelKeys) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed_0() Case $tab1 _Pressed_1() Case $tab2 Send("{ENTER}") ;Doesn't work properly Case $hInput_2 MsgBox(0, "Input 2", "Fired") EndSwitch Case $tab Switch GUICtrlRead($tab, 1) Case $tab0, $tab1 GUISetAccelerators($aAccelKeys) Case $tab2 GUISetAccelerators(0) EndSwitch EndSwitch WEnd Func _Pressed_0() ConsoleWrite("Hit_0" & @CRLF) EndFunc ;==>_Pressed_0 Func _Pressed_1() ConsoleWrite("Hit_1" & @CRLF) EndFunc ;==>_Pressed_1Does that solve your problem? Please ask if anything is unclear. 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...
which1 Posted December 26, 2012 Author Share Posted December 26, 2012 Hi Melba23, I'm sorry I was too late to reciprocate your wishes ; I actually hope you'r enjoying an agreeable Christmas period where never lark or even eagle flew ! Back on earth now (...if I dare say) : the script you proposed looks in a kind of way like a little Christmas present : it does exactly what I was looking for. I first noticed that MsgBox 'Input 2' didn't show up, and I ended up thinking that it was part of the evidence that the process was responding correctly. Case $tab2 GUISetAccelerators(0) => $cDummy not fired => Case $hInput_2 never inspected. Please correct me if I'm misunderstanding. Again thank you for your very nice support! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 26, 2012 Moderators Share Posted December 26, 2012 which1,The MsgBox will never fire on ENTER as I have altered the control to be a multi-line edit control to show that the ENTER key will now operate as itself when on tab2. There are better ways to read the content of the control and then do things than blindly Sending an ENTER key - what do you want to happen to the content of that control and when? 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...
which1 Posted December 26, 2012 Author Share Posted December 26, 2012 Melba23,I'm totally ok with your first sentence : The MsgBox will never fire ...I already had commented the unecessary lines :While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy Switch GUICtrlRead($tab, 1) Case $tab0 _Pressed_0() Case $tab1 _Pressed_1()#cs Case $tab2 Send("{ENTER}") ;Doesn't work properly Case $hInput_2 _Pressed_2() MsgBox(0, "Input 2", "Fired")#ce EndSwitch../...WEndI don't speak about Sending an ENTER key anymore since it was my wrong attempt to achieve what the code you proposed does perfectly. To elaborate : the Tab control I'm working on contains 5 multi-line edit controls. Each of them is supplying automated text using 3 different methods :- selected items on TreeViews- auto-completion from a list of words- dictation from "Dragon Naturally Speaking"The 2 first methods are working fine now.I don't know yet if 'Dragon' is likely to work "live" in an Autoit Edit Control. I'll have to test it. But anyway, if "live dictation" doesn't work, transcription will do the job. The content of each multi-line editcontrol is to be put in a SQLite database after pressing an Edit-related button. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 26, 2012 Moderators Share Posted December 26, 2012 which1, Glad we got there - even if I did not realise it. 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...
which1 Posted December 26, 2012 Author Share Posted December 26, 2012 Melba23, I'm glad too ! Sharing information : Dragon is working with an Autoit Edit Control without any problem. 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