JoeBurns Posted June 10, 2007 Share Posted June 10, 2007 I wrote this little script:#include <GUIConstants.au3> $add_note = GUICreate("Add Note", 524, 276, 271, 162) $textbox = GUICtrlCreateEdit("", 8, 8, 505, 201) $Button_Add = GUICtrlCreateButton("Add Note", 424, 224, 91, 41, 0) GUISetState(@SW_SHOW) $message = String("") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_Add $message = GUICtrlRead($textbox) Send("!{TAB}") Send($message) EndSelect WEndWhich just grabs the text in the editbox and puts into the application behind it. But when it transfer the text over an extra enter appears when transfered - as shown below.Is this a bug or am i missing something, any help would be great thx Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 10, 2007 Moderators Share Posted June 10, 2007 Weird, after checking it, it's definitely a "Send" issue, seems it's putting an extra crlf in there. The reason I say that, is if you use "FileWrite" on he same thing, it comes out correct. To fix the issue temporarily, Send(StringReplace($message, @LF, '')) works. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
star2 Posted June 10, 2007 Share Posted June 10, 2007 ?? strange before this case #include <GUIConstants.au3> GUICreate("Add Note", 524, 276, 271, 162) $textbox = GUICtrlCreateEdit("", 8, 8, 505, 201) $send = GUICtrlCreateButton("send all to file", 4, 215, 150, 25) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $send Then SendMyData() WEnd Func SendMyData() FileDelete('test.inf') $data = GUICtrlRead($textbox) FileWrite('test.inf', $data) MsgBox(0,'Info','Data written to test.inf') EndFunc but it worked fine but not in ur case [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
martin Posted June 10, 2007 Share Posted June 10, 2007 (edited) You are confusing yourself with what is actually happening. When you type CR in an edit or Notepad or Scite, LF is automatically added. The same will happen with another edit in your GUI. It's not the SEND function which adds another LF it's the editor. This script below demonstrates that another edit box in the gui behaves the same as Notepad. #include <GUIConstants.au3> $add_note = GUICreate("Add Note", 524, 576, 271, 162) $textbox = GUICtrlCreateEdit("", 8, 8, 505, 180) $textbox2 = GUICtrlCreateEdit("", 8, 208, 505, 180) $Button_Add = GUICtrlCreateButton("Add Note", 424, 424, 91, 41, 0) GUISetState(@SW_SHOW) $message = String("") GUICtrlSetState($textbox,$GUI_FOCUS) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_Add $message = GUICtrlRead($textbox) GUICtrlSetState($textbox2,$GUI_FOCUS) Send($message) EndSelect WEnd Edited June 10, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
JoeBurns Posted June 10, 2007 Author Share Posted June 10, 2007 WOW fast responce! At least its not just me. But the "Send(StringReplace($message, @LF, ''))" work sweet. Nice work around SmOke_N, but I don't understand why it works - What does the @LF stand for? Link to comment Share on other sites More sharing options...
Siao Posted June 10, 2007 Share Posted June 10, 2007 (edited) You are confusing yourself with what is actually happening.When you type CR in an edit or Notepad or Scite, LF is automatically added.In Scintilla based editors (Scite, Notepad++) that Send($message) is displayed correctly, without the extra CRLF. Edited June 10, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
martin Posted June 10, 2007 Share Posted June 10, 2007 In Scintilla based editors (Scite, Notepad++) that Send($message) is displayed correctly, without the extra CRLF.Yes but like the effects in Notepad you need to understand why. "Correctly" is not the appropriate description here because both displays are correct, or both are wrong depending on what you think they should do, but actually they are just different.In an edit box (which is what Notepad is) a LIneFeed character is added automatically when you type CarriageReturn.The same happens in Scite.When you read a line from an edit box it has CRLF at the end. When this line is sent to Notepad the CR generates a new LF and then the LF is entered so you get 2 LF's. So every time you copy a line from an edit and paste it into Notepad you get an extra LF. (I don't mean copy and paste like with a mouse drag which won't copy CRLF after the highlighted section.)In Scite, which also adds a LF when CR is entered, the difference is that entering a line feed does nothing. If you send lots of LF characters to Scite followed by some text you will not see empty lines before the text. On the other hand, if you send lots of CR characters followed by a line of text then you will get empty lines. Since no LF was sent you could argue that this effect is incorrect. In Notepad or an edit box you will get empty lines both ways. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 10, 2007 Share Posted June 10, 2007 WOW fast responce! At least its not just me. But the "Send(StringReplace($message, @LF, ''))" work sweet. Nice work around SmOke_N, but I don't understand why it works - What does the @LF stand for? For a multi-line edit box, you may only want the LAST @LF removed, not all of them. I would prefer: Send(StringStripWS($message, 2)) ; 2 = strip trailing whitespace Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
JoeBurns Posted June 11, 2007 Author Share Posted June 11, 2007 Cool, i get thx guys, for the help! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 11, 2007 Moderators Share Posted June 11, 2007 You are confusing yourself with what is actually happening. When you type CR in an edit or Notepad or Scite, LF is automatically added. The same will happen with another edit in your GUI. It's not the SEND function which adds another LF it's the editor. This script below demonstrates that another edit box in the gui behaves the same as Notepad. #include <GUIConstants.au3> $add_note = GUICreate("Add Note", 524, 576, 271, 162) $textbox = GUICtrlCreateEdit("", 8, 8, 505, 180) $textbox2 = GUICtrlCreateEdit("", 8, 208, 505, 180) $Button_Add = GUICtrlCreateButton("Add Note", 424, 424, 91, 41, 0) GUISetState(@SW_SHOW) $message = String("") GUICtrlSetState($textbox,$GUI_FOCUS) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_Add $message = GUICtrlRead($textbox) GUICtrlSetState($textbox2,$GUI_FOCUS) Send($message) EndSelect WEndWhat you say is fine... @CR adds @LF but... @CRLF is adding @CR+@LF... however, it's actually adding another carriage return along with that line feed you say it is adding. It may not be an autoit bug, it may be a windows bug, but it certainly looks to be a bug to me. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Siao Posted June 11, 2007 Share Posted June 11, 2007 (edited) It may not be an autoit bug, it may be a windows bug, but it certainly looks to be a bug to me.Send() sends characters one by one. Program receives CR and converts that to CR+LF. It does not know that LF will follow next. Then it receives LF and converts that to CR+LF... all this to keep uniformity with the standard. So they would say "it's not a bug, it's a feature" Tho the CR+LF concept as such is daft to begin with: two chars to express one thing - a new line. Edited June 11, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 11, 2007 Moderators Share Posted June 11, 2007 Send() sends characters one by one. Program receives CR and converts that to CR+LF.This is true... hadn't stopped to think about that fact, but to be honest, I don't think I ever use "send" for anything to have noticed before. But something I wasn't aware of before this thread was that "Send" added chars to anything at all. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
martin Posted June 13, 2007 Share Posted June 13, 2007 But something I wasn't aware of before this thread was that "Send" added chars to anything at all.It doesn't. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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