Madza91 Posted June 15, 2008 Share Posted June 15, 2008 (edited) Hello everybody, i have little question, i don't know how to fix this, i have one GuiCtrlCreateEdit and i want to add words only in last line of that Edit... I can to do it with GUICtrlSetData($ctrlID, $data, 1), (Edit is readonly) and when select text and use ..SetData command, i lose that selected lines, but i want only to add last line... here is example: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 321, -1, -1) $ctrlID = GUICtrlCreateEdit( "This is line 1..." &@CRLF& "This is line 2... Select ALL and press SEND" &@CRLF& "This is line 3...", 24, 24, 337, 249, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) ;~ $input = GUICtrlCreateInput("", 24, 280, 273, 21) $Button1 = GUICtrlCreateButton("SEND", 304, 280, 59, 20,$BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $data = @CRLF& "...something..." GUICtrlSetData($ctrlID, $data, 1) EndSwitch WEnd Edited August 1, 2008 by n3nE [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
k3v Posted June 15, 2008 Share Posted June 15, 2008 maybe... $data = GUICtrlRead($ctrlID) & @CRLF & "...something..." GUICtrlSetData($ctrlID, $data, 1) Link to comment Share on other sites More sharing options...
Madza91 Posted June 15, 2008 Author Share Posted June 15, 2008 LOL, do you mean on this: $data = GUICtrlRead($ctrlID) & @CRLF & "...something..." GUICtrlSetData($ctrlID, $data) That way is to slow for my script (and i need to be scrolled down), because i have very big text, and i can't read and set all text every time... [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
martin Posted June 15, 2008 Share Posted June 15, 2008 LOL, do you mean on this:$data = GUICtrlRead($ctrlID) & @CRLF & "...something..."GUICtrlSetData($ctrlID, $data)That way is to slow for my script (and i need to be scrolled down), because i have very big text, and i can't read and set all text every time...What about _GUICtrlEdit_AppendText in GuiEdit.au3? 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...
Madza91 Posted June 16, 2008 Author Share Posted June 16, 2008 (edited) Is there a some other way? GUIedit don't support some Unicode characters... check out this example: expandcollapse popup#include <GuiEdit.au3> ;~ #include <ButtonConstants.au3> ;~ #include <EditConstants.au3> #include <GUIConstantsEx.au3> ;~ #include <WindowsConstants.au3> ;~ Opt('MustDeclareVars', 1) $Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work Local $hEdit, $Button1 GUICreate("Edit Append Text", 400, 300) $Button1 = GUICtrlCreateButton("Button1", 52, 272, 75, 25, 0) $asd = _Ansi2Uni("Ä Ä‡ Å¡ ž Ä") $Input1 = GUICtrlCreateInput($asd, 130, 274, 217, 21) $hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $wordtosend = _Uni2Ansi(GUICtrlRead($Input1)) $UniWord = _Ansi2Uni($wordtosend) ;~ MsgBox(0,$UniWord,$wordtosend) GUICtrlSetData($hEdit, "GUICtrlSetData | Ansi 2 Uni: "& $UniWord) _GUICtrlEdit_AppendText($hEdit, @CRLF & "..._AppendText | Ansi 2 Uni: "& $UniWord) _GUICtrlEdit_InsertText($hEdit, @CRLF & " ..._InsertText | Ansi 2 Uni: "& $UniWord) EndSwitch WEnd Func _Uni2Ansi($Unicode) $Binary = StringToBinary($Unicode, 4) $Hex = StringReplace($Binary, '0x', '', 1) $BinaryLength = StringLen($Hex) Local $ANSI For $i = 1 To $BinaryLength Step 2 $Char = StringMid($Hex, $i, 2) $ANSI &= BinaryToString('0x' & $Char) Next Return $ANSI EndFunc ;==>_Uni2Ansi Func _Ansi2Uni($ANSI) $Binary = StringToBinary($ANSI) $Unicode = BinaryToString($Binary, 4) Return $Unicode EndFunc ;==>_Ansi2Uni Edited June 16, 2008 by n3nE [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Madza91 Posted June 16, 2008 Author Share Posted June 16, 2008 (edited) Please look my example and say me, how to fix problem?! :S If _GUICtrlEdit_AppendText don't support Unicode characters, how to Add text on End of CtrlEdit, without bug like in first example ... Edited June 17, 2008 by n3nE [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
martin Posted June 20, 2008 Share Posted June 20, 2008 Anyone?! Does this do what you want? I would expect not since it's a bit obvious but thought I'd try. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 392, 321, -1, -1) $ctrlID = GUICtrlCreateEdit( "This is line 1..." &@CRLF& "This is line 2... Select ALL and press SEND" &@CRLF& "This is line 3...", 24, 24, 337, 249, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) ;~ $input = GUICtrlCreateInput("", 24, 280, 273, 21) $Button1 = GUICtrlCreateButton("SEND", 304, 280, 59, 20,$BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $data = @CRLF& "...something..." $oldtext = GUICtrlRead($ctrlID) GUICtrlSetData($ctrlID, $oldtext & $data) EndSwitch WEnd 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...
Madza91 Posted June 20, 2008 Author Share Posted June 20, 2008 know that...and i think this is too slow way ;/ and it's not scrolling to down...Well... I need something for chat, to scroll down and to support Unicode characters... and to not be bugged [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
inet Posted July 2, 2008 Share Posted July 2, 2008 How about this? _GUICtrlEdit_AppendText($ctrlID, $Data) Link to comment Share on other sites More sharing options...
Madza91 Posted July 2, 2008 Author Share Posted July 2, 2008 I sad already about that... not support Unicode characters... [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Madza91 Posted August 19, 2008 Author Share Posted August 19, 2008 (edited) Hello again, command _GUICtrlEdit_AppendText is bugged like GuiCtrlSetData, check this out:#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> $Form1 = GUICreate("Form1", 633, 447, 0, 0) $Edit1 = GUICtrlCreateEdit("Line number: 1/100", 100, 100, 200, 200) GUISetState(@SW_SHOW) MsgBox(0,"","Just hold down left click and shake mouse up/down over Edit ctrl!") MouseMove(150,150, 0) For $a = 2 To 100 MouseMove(120,150, 1) _GUICtrlEdit_AppendText($Edit1,@CRLF & "Line number: "& $a&"/100") Sleep(50) Next MsgBox(0,"_GUICtrlEdit_GetLineCount",_GUICtrlEdit_GetLineCount($Edit1) &" (Should be 100)") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndSomebody help, is there any way to add text in Edit but without deleting selected words ? Edited August 19, 2008 by n3nE [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
rasim Posted August 20, 2008 Share Posted August 20, 2008 n3nESeem works fine for me:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> $Form1 = GUICreate("Form1", 633, 447, 0, 0) $Edit1 = GUICtrlCreateEdit("Line number: 1/100", 100, 100, 200, 200) GUISetState(@SW_SHOW) For $a = 2 To 100 GUICtrlSetData($Edit1, "Line number: " & $a & "/100" & @CRLF, 1) Sleep(50) Next MsgBox(0,"_GUICtrlEdit_GetLineCount",_GUICtrlEdit_GetLineCount($Edit1) &" (Should be 100)") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Madza91 Posted August 20, 2008 Author Share Posted August 20, 2008 LOL, not works... just hold down left click and select some text in Edit ctrl and shake mouse up and down ;d ...& you will see... [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Madza91 Posted August 27, 2008 Author Share Posted August 27, 2008 Bump?! ;// [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
rover Posted August 28, 2008 Share Posted August 28, 2008 (edited) @n3nEThis was probably addressed somewhere on the forums, but with a quick look at the includes I could see the problem._GUICtrlEdit_AppendText() uses a char array and not a wide char arrayand _SendMessage() is using SendMessage and not SendMessageWI'm not that well versed in Unicode support in AutoIt, perhaps someone else can comment.Try thisEdit: added _GUICtrlEdit_InsertTextW()expandcollapse popup;2 modified functions from GuiEdit.au3 ;and 1 modified function from SendMessage.au3 #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Opt('MustDeclareVars', 1) Local $hEdit, $Button1, $asd, $hEdit, $Input1, $nMsg Local $wordtosend, $UniWord GUICreate("Edit Append Text", 400, 300) $Button1 = GUICtrlCreateButton("Button1", 52, 272, 75, 25, 0) $asd = _Ansi2Uni("Ä Ä Å¡ ž Ä") $Input1 = GUICtrlCreateInput($asd, 130, 274, 217, 21) $hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $wordtosend = _Uni2Ansi(GUICtrlRead($Input1)) $UniWord = _Ansi2Uni($wordtosend) GUICtrlSetData($hEdit, "GUICtrlSetData | Ansi 2 Uni: "& $UniWord) _GUICtrlEdit_AppendTextW($hEdit, @CRLF & "..._AppendText | Ansi 2 Uni: "& $UniWord) _GUICtrlEdit_InsertTextW($hEdit, @CRLF & " ..._InsertText | Ansi 2 Uni: "& $UniWord) EndSwitch WEnd Func _Uni2Ansi($Unicode) Local $Binary, $Hex, $BinaryLength, $ANSI, $Char $Binary = StringToBinary($Unicode, 4) $Hex = StringReplace($Binary, '0x', '', 1) $BinaryLength = StringLen($Hex) For $i = 1 To $BinaryLength Step 2 $Char = StringMid($Hex, $i, 2) $ANSI &= BinaryToString('0x' & $Char) Next Return $ANSI EndFunc ;==>_Uni2Ansi Func _Ansi2Uni($ANSI) Local $Binary, $Unicode $Binary = StringToBinary($ANSI) $Unicode = BinaryToString($Binary, 4) Return $Unicode EndFunc ;==>_Ansi2Uni ;** wchar array instead of char Func _GUICtrlEdit_AppendTextW($hWnd, $sText) If $Debug_Ed Then _GUICtrlEdit_ValidateClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $struct_MemMap, $struct_String, $sBuffer_pointer, $iLength $struct_String = DllStructCreate("wchar Text[" & StringLen($sText) + 1 & "]") $sBuffer_pointer = DllStructGetPtr($struct_String) DllStructSetData($struct_String, "Text", $sText) _MemInit($hWnd, StringLen($sText) + 1, $struct_MemMap) _MemWrite($struct_MemMap, $sBuffer_pointer) $iLength = _GUICtrlEdit_GetTextLen($hWnd) _GUICtrlEdit_SetSel($hWnd, $iLength, $iLength) __SendMessageW($hWnd, $EM_REPLACESEL, True, $sBuffer_pointer, 0, "wparam", "ptr") _MemFree($struct_MemMap) EndFunc ;==>_GUICtrlEdit_AppendText ;** SendMessageW instead of SendMessage Func __SendMessageW($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lparam") Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "int", $iMsg, $wParamType, $wParam, $lParamType, $lParam) If @error Then Return SetError(@error, @extended, "") If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn] Return $aResult EndFunc ;==>_SendMessage ;** wchar array instead of char Func _GUICtrlEdit_InsertTextW($hWnd, $sText, $iIndex = -1) If $Debug_Ed Then _GUICtrlEdit_ValidateClassName($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $struct_MemMap, $struct_String, $sBuffer_pointer If $iIndex = -1 Then _GUICtrlEdit_AppendTextW($hWnd, $sText) Else $struct_String = DllStructCreate("wchar Text[" & StringLen($sText) + 1 & "]") $sBuffer_pointer = DllStructGetPtr($struct_String) DllStructSetData($struct_String, "Text", $sText) _MemInit($hWnd, StringLen($sText) + 1, $struct_MemMap) _MemWrite($struct_MemMap, $sBuffer_pointer) _GUICtrlEdit_SetSel($hWnd, $iIndex, $iIndex) __SendMessageW($hWnd, $EM_REPLACESEL, True, $sBuffer_pointer, 0, "wparam", "ptr") _MemFree($struct_MemMap) EndIf EndFunc ;==>_GUICtrlEdit_InsertTextCheers Edited August 28, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
Madza91 Posted November 4, 2008 Author Share Posted November 4, 2008 n3nE Loves Rover Thanks ;D [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) 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