Blank517 Posted August 23, 2016 Share Posted August 23, 2016 When i write in inputbox and hit send sends the message, but it also sends when I move the mouse. How can I fix? (sorry for my bad explanation but I don't know english very well) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Client #include <GuiConstants.au3> #include <GuiEdit.au3> TCPStartup() $ip=InputBox("Chat","IP:",@IPAddress1,"",50,123) If $ip="" Then Exit $socket=TCPConnect($ip,2000) If $socket=-1 Then MsgBox(16,"Error","Connection error",5) Exit EndIf GUICreate("Client",300,240) $edit=GUICtrlCreateEdit("",0,0,300,200,BitOr($WS_VSCROLL, $ES_READONLY)) $msg=GUICtrlCreateInput("",10,210,200,20) $send=GUICtrlCreateButton("Send",215,210,80,20) Dim $AccelKeys[1][2] = [["{ENTER}", $send]] GUISetAccelerators($AccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $gui_event_close GUIDelete() Case $send $msg1=GUICtrlRead($msg) TCPSend($socket,$msg1) GUICtrlSetData($msg,"") EndSwitch $recv=TCPRecv($socket,2048) If $recv <> "" Then _GUICtrlEdit_AppendText($edit,$recv & @CRLF) EndIf WEnd Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted August 24, 2016 Share Posted August 24, 2016 I'm no expert, but I can see three things that might be the problem. Dim $AccelKeys[1][2] = [["{ENTER}", $send]] Try removing the brackets '[[ ]]' GUISetAccelerators($AccelKeys) Try adding a position to the array : GUISetAccelerators($AccelKeys[0][1]) Or something like that... not sure exactly how those work. GUISetAccelerators($AccelKeys) Or try removing this line. In my script I don't even use this. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 24, 2016 Moderators Share Posted August 24, 2016 FengHuangWuShen, None of those are sensible solutions: Removing the brackets will give you a syntax error as they are required when defining a 2D array. If you look in the Help file, you will see that you pass the array name, not a random specific element, to GUISetAccelerators. If you remove the Accelerator key, how do you intend to bind the {ENTER} key to the button? Quote not sure exactly how those work So perhaps not a brilliant idea to offer suggestions then? Blank517, Welcome to the AutoIt forums. I do not get the button Case code firing when I move the mouse - is this the whole code? 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...
Blank517 Posted August 24, 2016 Author Share Posted August 24, 2016 2 hours ago, Melba23 said: Blank517, Welcome to the AutoIt forums. I do not get the button Case code firing when I move the mouse - is this the whole code? M23 Thanks for welcome! Yes, this is the whole code but i have rewrited the entire script... Now i use: While 1 _Recv_data_server() If _IsPressed('0D') Then _Send() EndIf Sleep(50) WEnd Link to comment Share on other sites More sharing options...
orbs Posted August 24, 2016 Share Posted August 24, 2016 (edited) 4 hours ago, Melba23 said: If you remove the Accelerator key, how do you intend to bind the {ENTER} key to the button? perhaps like this: GUICtrlSetState($send, $GUI_DEFBUTTON) Edited August 24, 2016 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2016 Moderators Share Posted August 25, 2016 orbs, I know of several ways of linking the key to the button - the point was that the responder did not and so the suggestion he made did not offer a sensible solution. 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...
FengHuangWuShen Posted August 26, 2016 Share Posted August 26, 2016 (edited) Sorry for being a noob and all, but the point of a suggestion is the spark a possible solution, or idea to that solution. I never said I had the solution, and thanks for the correction, i'll be sure to look further next time. :/ You really are an old timer eh Additionally, the reason I brought up the no brackets was because of my section of script here ( found on another thread somewhere here ), which has no brackets, only quotations. It is a 2D Array as well. Local $accelerators[1][2] $accelerators[0][0] = "{ENTER}" $accelerators[0][1] = $Barcode_Entry And it worked fine. Edited August 26, 2016 by FengHuangWuShen Link to comment Share on other sites More sharing options...
argumentum Posted August 26, 2016 Share Posted August 26, 2016 (edited) On 8/24/2016 at 3:07 PM, Blank517 said: While 1 _Recv_data_server() If _IsPressed('0D') Then _Send() EndIf Sleep(50) WEnd While 1 _Recv_data_server() If _IsPressed('0D') Then While _IsPressed('0D') ; this way is better Sleep(30) ; it will send on release WEnd ; avoiding possible problems _Send() EndIf Sleep(50) WEnd tho, $msg=GUICtrlCreateInput("",10,210,200,20) would be better with an edit control, and read it and, when you find a @CRLF then, read the contents minus the @CRLF, send, and clear the control Edited August 26, 2016 by argumentum new idea :) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2016 Moderators Share Posted August 26, 2016 FengHuangWuShen, The problem is not "being a noob and all", but being a noob and making suggestions which are completely wrong in terms of basic syntax - which could have been noticed by a cursory glance at the Help file: ; Set GUIAccelerators for the button controlIDs, these being Ctrl + y and Ctrl + n Local $aAccelKeys[2][2] = [["^y", $idYes], ["^n", $idNo]] GUISetAccelerators($aAccelKeys) As you can see: The 2D array needs the double [[ ]] if you assign elements at the same time as declaring the array. In the example you show, the elements are assigned after declaration and so do not need to be enclosed double [[ ]]. The GUISetAccelerators command takes the entire array (passed by name) as a parameter and not a single element. While I agree that suggestions might well spark possible solutions, they need to be based on some degree of reality - which alas yours were not. But please do not get discouraged - do exactly as you suggested and "look further next time" before posting. M23 (the old timer) 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...
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