Nahuel Posted October 8, 2007 Posted October 8, 2007 I made a little script to talk to other computers in my LAN. It works fine, but I'm having troubles with the edit control where the messages are displayed. When a new text is set, it won't scroll down so I added: _GUICtrlEditScroll ($RcvMsg, $SB_PAGEDOWN ) It works alright.. but if you check it, you'll see that the way it scrolls down is very annoying. Is there a smoother way to do this? expandcollapse popup#include <GUIConstants.au3> #include <GuiIPAddress.au3> #Include <GuiStatusBar.au3> #Include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #NoTrayIcon HotKeySet("^!c","connect") Global $NickN Global $connsock=-1 Global $NewMessage Global $mainsock $Main = GUICreate("Messenger Loco - Nahuel", 419, 358) GUISetBkColor(0x000080) $RcvMsg = GUICtrlCreateEdit("", 8, 8, 393, 233, BitOR($ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL), $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 10, 400, 0, "Microsoft Sans Serif") GUICtrlSetBkColor(-1, 0xA6CAF0) $SendMsg = GUICtrlCreateEdit("", 8, 256, 313, 57, $WS_VSCROLL) $SendButton = GUICtrlCreateButton("&Enviar", 336, 256, 65, 57, $BS_DEFPUSHBUTTON) $Conversation = GUICtrlCreateMenu("&Conversación") $UserData = GUICtrlCreateMenu("Co&nfiguración") $Connect = GUICtrlCreateMenuItem("Co&nectar Ctrl+Alt+C", $Conversation) $Quit = GUICtrlCreateMenuItem( "&Salir Esc", $Conversation) $MenuItem3 = GUICtrlCreateMenuItem("Cambiar Nick", $UserData) $Status = _GUICtrlStatusBarCreate($Main, 650,"Status Bar") _GUICtrlStatusBarSetText($Status,"Desconectado") GUISetState(@SW_SHOW) $NickN=IniRead("userdata.ini","Personal","Nick",@UserName&" en "&@ComputerName) While 1 Sleep(25) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $SendButton _SendMsg() ControlFocus("","",$SendMsg) Case $MenuItem3 $InpNick=InputBox("Messenger loco","Inserte su nuevo nick:", $NickN ,"",Default,150) If not @error Then $NickN=$InpNick IniWrite("userdata.ini","Personal","Nick",$InpNick) EndIf Case $Quit ExitLoop Case $Connect connect() EndSwitch _RcvMsg() ;~ _GUICtrlEditScroll ($RcvMsg, $SB_PAGEDOWN ); <====HERE! WEnd If $connsock <> -1 Then TCPSend($connsock,$NickN&" se ha desconectado...") Else TCPSend($mainsock,$NickN&" se ha desconectado...") EndIf TCPShutdown() Func _SendMsg() ;~ If _GUICtrlStatusBarGetText($Status) <>"Conectado" Then ;~ GUICtrlSetData($RcvMsg,"-ERROR- El sistema está desconectado"&@CRLF) ;~ GUICtrlSetData($SendMsg,"") ;~ Return ;~ EndIf $NewMessage=GUictrlread($SendMsg) $msg2send="[*]"&$NickN&" dice: "&@CRLF&$NewMessage&@CRLF If $NewMessage="" then Return If $connsock <> -1 Then TCPSend($connsock,$msg2send ) $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$msg2send) GUICtrlSetData($SendMsg,"") Else TCPSend($mainsock,$msg2send ) $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$msg2send) GUICtrlSetData($SendMsg,"") EndIf EndFunc Func _RcvMsg() If _GUICtrlStatusBarGetText($Status) ="Conectado" Then If $connsock <> -1 Then $NewMessage = TCPRecv($connsock, 2048) If StringInStr($NewMessage,"se ha desconectado...")<>0 Then MsgBox(0,"",$NewMessage) _GUICtrlStatusBarSetText($Status,"Desconectado") GUICtrlSetState($Connect,$GUI_ENABLE) $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$NewMessage&@CRLF) TCPShutdown() Return EndIf If $NewMessage <> "" Then $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$NewMessage) WinFlash($Main,"",2) EndIf Else $NewMessage = TCPRecv($mainsock, 2048) If StringInStr($NewMessage,"se ha desconectado...")<>0 Then MsgBox(0,"",$NewMessage) _GUICtrlStatusBarSetText($Status,"Desconectado") GUICtrlSetState($Connect,$GUI_ENABLE) $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$NewMessage&@CRLF) TCPShutdown() Return EndIf If $NewMessage <> "" Then $ExConv=GUictrlread($RcvMsg) GUICtrlSetData($RcvMsg,$ExConv&$NewMessage) WinFlash($Main,"",2) EndIf EndIf EndIf EndFunc Func connect() $Form1 = GUICreate("Conectar", 266, 181, 253, 228, -1,-1,$Main) $BeServer = GUICtrlCreateRadio("Servidor", 8, 32, 81, 17) GUICtrlSetState(-1,$GUI_CHECKED) $BeClient = GUICtrlCreateRadio("Cliente", 8, 80, 65, 17) $Group1 = GUICtrlCreateGroup("", 0, 8, 257, 57) $Group2 = GUICtrlCreateGroup("", 0, 64, 257, 73) $sIpAddress = _GUICtrlIpAddressCreate ($Form1, 10, 104, 241, 21) $Connect1 = GUICtrlCreateButton("&Conectar", 48, 152, 153, 25, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) GUISetState(@SW_DISABLE,$Main) While 1 $nMsg1 = GUIGetMsg() Switch $nMsg1 Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE,$Main) GUIDelete($Form1) ExitLoop Case $Connect1 If GUICtrlRead($BeClient)=$GUI_CHECKED Then ;Be client TCPStartup() $mainsock = TCPConnect(_GUICtrlIpAddressGet($sIPAddress), 65433) GUISetState(@SW_HIDE, $Form1) GUISwitch($Main) ;====== If $mainsock = -1 Then Msgbox(0, "Error de conexión", "No se puede conectar con el servidor en : " & _GUICtrlIpAddressGet($sIpAddress) & @CRLF & "Verifique la dirección en intente de nuevo.") GUISetState(@SW_ENABLE,$Main) Return Else _GUICtrlStatusBarSetText($Status, "Conectado") GUICtrlSetState($Connect,$GUI_DISABLE) GUISetState(@SW_ENABLE,$Main) Return EndIf Else ;Be server GUISetState(@SW_ENABLE,$Main) GUIDelete($Form1) TCPStartup() $mainsock = TCPListen(TCPNameToIP(@ComputerName), 65433) If $mainsock = -1 Then Exit _GUICtrlStatusBarSetText($Status, "Esperando conexiones... (IP: " & TCPNameToIP(@ComputerName) & ")") Do If GUIGetMsg()=$GUI_EVENT_CLOSE Then Exit $connsock = TCPAccept($mainsock) Until $connsock <> -1 ;============= _GUICtrlStatusBarSetText($Status, "Conectado") GUICtrlSetState($Connect,$GUI_DISABLE) Return EndIf EndSwitch WEnd EndFunc
GaryFrost Posted October 8, 2007 Posted October 8, 2007 Take a look at _GUICtrlEdit_AppendText in the beta, scrolls as it adds SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
enaiman Posted October 8, 2007 Posted October 8, 2007 Also you might take a look at: Quote Scrolls the text in a multiline edit control.#Include <GuiEdit.au3>_GUICtrlEditLineScroll ( $h_edit, $i_horiz, $i_vert ) SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Nahuel Posted October 8, 2007 Author Posted October 8, 2007 @GaryFrost: Thanks, will do so @enaiman: Thanks, but that's the one I'm using (well, one from the same library) and it has an awful effect when the text is too big.
Nahuel Posted October 8, 2007 Author Posted October 8, 2007 GaryFrost said: Take a look at _GUICtrlEdit_AppendText in the beta, scrolls as it addsYes. Just perfect. Thanks Btw, is there a way I can make SciTe work with the beta include directory? I've looked but I can't find it...
GaryFrost Posted October 9, 2007 Posted October 9, 2007 Nahuel said: Yes. Just perfect. Thanks Btw, is there a way I can make SciTe work with the beta include directory? I've looked but I can't find it...Make sure you have the latest SciTE for AutoItAlt+F5 run betaAlt+F7 compile betaCtrl+1 SciTE Config SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Nahuel Posted October 9, 2007 Author Posted October 9, 2007 Thanks. When I installed AtuoIt beta it didn't install the newest SciTe apparently.. but it does recognize the function _GUICtrlEdit_AppendText though... Anyway, thanks
GaryFrost Posted October 9, 2007 Posted October 9, 2007 Nahuel said: Thanks. When I installed AtuoIt beta it didn't install the newest SciTe apparently.. but it does recognize the function _GUICtrlEdit_AppendText though...Anyway, thanks The AutoIt contains the bare minimum SciTE, you have to Download and install the Latest SciTE for AutoIT which should be able to switch to 3.2.9.3 function names SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
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