Gideon Posted April 30, 2010 Share Posted April 30, 2010 (edited) Hello, When the user types in something and press enter it says: "you typed in:" & $something. and it shows the button. When you press enter again it doesn't work anymore, I realised that it's normal, because you didn't edit it. But I like the user to press enter every time. Is there a way to force that? ps, sorry for my poor english [sOLVED] #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $gui = GUICreate( "test", 200, 200) $inp = GUICtrlCreateInput("", 10, 10,100,20) $but = GUICtrlCreateButton("clear text", 120, 10) GUICtrlSetState($but, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $inp MsgBox(0,"test", "You typed in" & guictrlread($inp)) GUICtrlSetState($but, $GUI_SHOW) Case $msg = $but GUICtrlSetData($inp, "") GUICtrlSetState($but, $GUI_HIDE) EndSelect WEnd GUIDelete() Edited April 30, 2010 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2010 Moderators Share Posted April 30, 2010 Gideon,It is not a bug. To get a message sent from an Input when you press Enter, the text within it needs to have changed (to go all geeky for a moment, it needs to have received an EN_CHANGE mesage). So if you press Enter before the text is changed, you do not get a message and so you do not fire the code. That is why nothing happens if you press Enter immediately the script starts - nothing in the input = no change = no message. I hope that explains what is going on. 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...
Gideon Posted April 30, 2010 Author Share Posted April 30, 2010 (edited) Gideon,It is not a bug. To get a message sent from an Input when you press Enter, the text within it needs to have changed (to go all geeky for a moment, it needs to have received an EN_CHANGE mesage). So if you press Enter before the text is changed, you do not get a message and so you do not fire the code. That is why nothing happens if you press Enter immediately the script starts - nothing in the input = no change = no message. I hope that explains what is going on. M23I already realised that^^, although, thanks for the reply:)How can you say EN_CHANGE = true everytime it's not true? Edited April 30, 2010 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2010 Moderators Share Posted April 30, 2010 Gideon,If you edit your question while I am answering the original version, the response is unlikely to be as helpful as you wanted. Anyway, you do not need to send a message, you can do it this way: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> $gui = GUICreate( "test", 200, 200) $inp = GUICtrlCreateInput("", 10, 10,100,20) $but = GUICtrlCreateButton("clear text", 120, 10) $hDummy = GUICtrlCreateDummy() GUICtrlSetState($but, $GUI_HIDE) GUISetState(@SW_SHOW) ; Set accelerator for Enter to action the Dummy code Dim $AccelKeys[1][2]=[["{ENTER}", $hDummy]] GUISetAccelerators($AccelKeys) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $hDummy ; Check input has focus If _WinAPI_GetFocus() = GUICtrlGetHandle($inp) Then $sText = GUICtrlRead($inp) MsgBox(0,"test", "You typed in " & $sText) GUICtrlSetState($but, $GUI_SHOW) EndIf Case $msg = $but GUICtrlSetData($inp, "") GUICtrlSetState($but, $GUI_HIDE) EndSelect WEnd GUIDelete()By setting the accelerator, we run the $hDummy code when we press Enter. But we need to check if the Input has focus so that we do not fire the code every time we press Enter, only when the Input is active.I hope that helps. 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...
Gideon Posted April 30, 2010 Author Share Posted April 30, 2010 Gideon, If you edit your question while I am answering the original version, the response is unlikely to be as helpful as you wanted. Anyway, you do not need to send a message, you can do it this way: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> $gui = GUICreate( "test", 200, 200) $inp = GUICtrlCreateInput("", 10, 10,100,20) $but = GUICtrlCreateButton("clear text", 120, 10) $hDummy = GUICtrlCreateDummy() GUICtrlSetState($but, $GUI_HIDE) GUISetState(@SW_SHOW) ; Set accelerator for Enter to action the Dummy code Dim $AccelKeys[1][2]=[["{ENTER}", $hDummy]] GUISetAccelerators($AccelKeys) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $hDummy ; Check input has focus If _WinAPI_GetFocus() = GUICtrlGetHandle($inp) Then $sText = GUICtrlRead($inp) MsgBox(0,"test", "You typed in " & $sText) GUICtrlSetState($but, $GUI_SHOW) EndIf Case $msg = $but GUICtrlSetData($inp, "") GUICtrlSetState($but, $GUI_HIDE) EndSelect WEnd GUIDelete() By setting the accelerator, we run the $hDummy code when we press Enter. But we need to check if the Input has focus so that we do not fire the code every time we press Enter, only when the Input is active. I hope that helps. M23 That helps me with my script:) very nice:D Thanks! Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2010 Moderators Share Posted April 30, 2010 Gideon,Glad I could help. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read.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...
Gideon Posted May 4, 2010 Author Share Posted May 4, 2010 Oke^^ Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Gideon Posted May 11, 2010 Author Share Posted May 11, 2010 (edited) Oke, now I have another problem with a gui, just like that. When I want the input only gives a message sent from an Input, and press enter, it presses the last clicked button too:( So I made a button next to it, but the user thinks he can press enter to, but then it presses the last clicked button. How can I fix this too? Edit: I can only fix it, but with the possibility to buttonbash:') Edited May 11, 2010 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 Gideon, If you do not post the code, it is very difficult to offer any help. 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...
GEOSoft Posted May 11, 2010 Share Posted May 11, 2010 Gideon,If you do not post the code, it is very difficult to offer any help. M23Not difficult at all. Just make sure your Crystal Scripalyzer has been recently polished and then look at the script on his computer. It should point you to the exact line which in this case is 2589674 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 George, It is packed and in my suitcase ready to go on holiday with me tomorrow. That is why I need the code in this case. Although I did get the initial impression that the error was closer to Line 3296 than your suggestion. 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...
Gideon Posted May 11, 2010 Author Share Posted May 11, 2010 (edited) hmm... oke, this is my code now. When I posted it here, it didn't fit into the iframeattach.au3 Edited May 11, 2010 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2010 Moderators Share Posted May 11, 2010 Gideon, As I suspected, you are colouring buttons.$ok = GUICtrlCreateButton("OK", 10, 100) GUICtrlSetColor(-1, 0x000000)This is a known bug (#376) where coloured buttons react to the "Enter" key.Solution: Do not colour the button! 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...
Gideon Posted May 11, 2010 Author Share Posted May 11, 2010 (edited) Aha, but I don't want to color buttons. But.. it is a must when you define defcolor, I don't want to put all the buttons above the defcolor, because the script will be unreadable (for me). Although, if that's the problem, I will use the buttonbash-solution. Thanks for the info:) Or, now I read about $BS_DEFPUSHBUTTON, maybe that's the solution. Or not, then the buttonbash will rule again:') It would be great if there was a $BS_NOCOLOR or a GUICtrlSetDefColor ( deftextcolor [, winhandle][,$UNSET_DEFCOLOR = False] ). Can I report that as an idea somewhere(if that's possible)? Edited May 11, 2010 by Gideon Many times you need to think like hobby-bob:') 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