
DarkAngel
Active Members-
Posts
125 -
Joined
-
Last visited
Everything posted by DarkAngel
-
Trying to achieve something like a collaborative editing tool . Something like ACE#. But mine isnt anywhere near i know. This is a pretty lame effort though . My sems are on and this is all i could think of now at this moment . Haven't tested it properly . But somehow it acts wierdly . Can't think of anything that might put the text in the typing area of the other users too . I tried updating the typing area every 1 sec or so .. but its sick cuz the cursor moves to the end of teh line everytime its updated .. I need some help on this .. Is this a good approach of doing what i want to achieve ? If not i want some ideas soon . And i thing theres some problem with the tcp buffer . cuz everytime i update the main screen, the previous texts arrives and then vanishes suddenly. do i need to reduce the size of the buffer ? please help. Server : #Include <ButtonConstants.Au3> #Include <EditConstants.Au3> #Include <GUIConstantsEx.Au3> #Include <StaticConstants.Au3> #Include <WindowsConstants.Au3> #Include <File.Au3> #Include <String.Au3> #include <Date.au3> Opt ('GUIOnEventMode', 1) Global $Max = 10, $Socket[$Max + 1], $User[$Max + 1], $Server = -1, $Admin = -1, $Admin_Pw = 'password', $Connected = 0 For $A = 1 To $Max $Socket[$A] = -1 $User[$A] = -1 Next $GUI = GUICreate ('Server Settings', 180, 100, -1, -1, -1, 128) GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateGroup ('', 5, 0, 170, 94) $IP = GUICtrlCreateInput (@IpAddress1, 12, 13, 100, 21, 1) $Port = GUICtrlCreateInput (50, 117, 13, 50, 21, 1) $Start = GUICtrlCreateButton ('Start', 12, 39, 46, 20, $WS_GROUP) GUICtrlSetOnEvent ($Start, '_Start') $Stop = GUICtrlCreateButton ('Stop', 63, 39, 49, 20, $WS_GROUP) GUICtrlSetState ($Stop, $GUI_DISABLE) GUICtrlSetOnEvent ($Stop, '_Stop') $Pw = GUICtrlCreateInput ($Admin_Pw, 12, 65, 100, 21, BitOr (1, $ES_PASSWORD)) $Set = GUICtrlCreateButton ('Set Pw', 118, 66, 49, 20, $WS_GROUP) GUICtrlSetOnEvent ($Set, '_Set') GUISetState (@SW_SHOW) WinSetOnTop ($GUI, '', 1) While 1 If $Server <> -1 Then If $Connected < $Max Then $Accept = TcpAccept ($Server) If $Accept <> -1 Then If _IsBanned (_SocketGetIP ($Accept)) = 0 Then $Open = _Open () $Timer = TimerInit () Do Sleep (15) $Recv = TcpRecv ($Accept, 1000000) Until $Recv <> '' Or TimerDiff ($Timer) >= 500 If $Recv <> '' Then If _Check ($Recv) = 1 Then $User[$Open] = $Recv $Socket[$Open] = $Accept $Connected = $Connected + 1 _SendAll ($User[$Open] & ' has connected.') Else TcpSend ($Accept, 'Error:Username.Exists;') Sleep (250) TcpCloseSocket ($Accept) EndIf Else TcpCloseSocket ($Accept) EndIf Else TcpSend ($Accept, 'Error:IP.Banned;') Sleep (250) TcpCloseSocket ($Accept) EndIf EndIf ElseIf $Connected = $Max Then $Accept = TcpAccept ($Server) If $Accept <> -1 Then $Timer = TimerInit () Do Sleep (15) $Recv = TcpRecv ($Accept, 1000000) Until $Recv <> '' Or TimerDiff ($Timer) >= 500 Sleep (250) TcpSend ($Accept, 'Error:Max.Connections;') TcpCloseSocket ($Accept) EndIf EndIf For $A = 1 To $Max If $Socket[$A] <> -1 And $User[$A] <> -1 Then $Recv = TcpRecv ($Socket[$A], 1000000) If @Error Then _Disconnect ($A) If $Recv <> '' Then _SendAll ($Recv) EndIf EndIf Next EndIf WEnd Func _IsBanned ($Data) For $A = 1 To _FileCountLines ('Banned.txt') If FileReadLine ('Banned.txt', $A) = $Data Then Return 1 Next Return 0 EndFunc Func _SocketGetIP ($Data) Local $Struct, $Return $Struct = DllStructCreate ('short;ushort;uint;char[8]') $Return = DllCall ('Ws2_32.dll','int','getpeername','int', $Data, 'ptr', DllStructGetPtr ($Struct), 'int*', DllStructGetSize($Struct)) If @Error Or $Return[0] <> 0 Then Return 0 $Return = DllCall ('Ws2_32.dll','str','inet_ntoa','int', DllStructGetData ($Struct, 3)) If @Error Then Return 0 $Struct = 0 Return $Return[0] EndFunc Func _UserGetSocket ($Data) For $A = 1 To $Max If $User[$A] = $Data Then Return $A Next Return -1 EndFunc Func _Check ($Data) For $A = 1 To $Max If $User[$A] = $Data Then Return 0 Next Return 1 EndFunc Func _Disconnect ($ID) _SendAll ($User[$ID] & ' has disconnected.') If $User[$ID] = $Admin Then $Admin = -1 TcpCloseSocket ($Socket[$ID]) $Socket[$ID] = -1 $User[$ID] = -1 $Connected = $Connected - 1 EndFunc Func _SendAll ($Msg) For $A = 1 To $Max If $Socket[$A] <> -1 And $User[$A] <> -1 Then TcpSend ($Socket[$A], $Msg) EndIf Next EndFunc Func _Open () For $A = 1 To $Max If $Socket[$A] = -1 And $User[$A] = -1 Then Return $A Next EndFunc Func _Start () If GUICtrlRead ($IP) == '' Or GUICtrlRead ($Port) == '' Then Return @Error TcpStartUp () $Server = TcpListen (GUICtrlRead ($IP), GUICtrlRead ($Port)) If $Server = -1 Or @Error Then WinSetOnTop ($GUI, '', 0) Sleep (100) MsgBox (16, 'Fatal Error','Unable to start the server, change your settings and try again.') WinSetOnTop ($GUI, '', 1) TcpCloseSocket ($Server) _Reset () Else GUICtrlSetState ($IP, $GUI_DISABLE) GUICtrlSetState ($Port, $GUI_DISABLE) GUICtrlSetState ($Start, $GUI_DISABLE) GUICtrlSetState ($Stop, $GUI_ENABLE) EndIf EndFunc Func _Stop () TcpCloseSocket ($Server) $Server = -1 $Connected = 0 $Admin = -1 _Reset () EndFunc Func _Set () $Admin_Pw = GUICtrlRead ($Pw) EndFunc Func _Reset () For $A = 1 To $Max If $Socket[$A] <> -1 Or $User[$A] <> -1 Then TcpCloseSocket ($Socket[$A]) $Socket[$A] = -1 $User[$A] = -1 EndIf Next TcpShutDown () GUICtrlSetState ($IP, $GUI_ENABLE) GUICtrlSetState ($Port, $GUI_ENABLE) GUICtrlSetState ($Start, $GUI_ENABLE) GUICtrlSetState ($Stop, $GUI_DISABLE) EndFunc Func _Exit () Exit EndFunc Client : #NoTrayIcon #include <ButtonConstants.Au3> #include <EditConstants.Au3> #include <GUIConstantsEx.Au3> #include <StaticConstants.Au3> #include <WindowsConstants.Au3> #include <GUIEdit.Au3> #include <Misc.Au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) TCPStartup() Global $Server = -1, $Logs $Settings = GUICreate('Connection Settings', 180, 100, -1, -1, -1, 128) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') GUICtrlCreateGroup('', 5, 0, 170, 94) $IP = GUICtrlCreateInput(IniRead('Settings.ini', 'Settings', 'IP', @IPAddress1), 12, 13, 100, 21, 1) $Port = GUICtrlCreateInput(IniRead('Settings.ini', 'Settings', 'Port', 50), 117, 13, 50, 21, 1) $User = GUICtrlCreateInput(IniRead('Settings.ini', 'Settings', 'User', 'John'), 12, 39, 156, 21, 1) $Connect = GUICtrlCreateButton('Connect', 12, 66, 100, 20, $WS_GROUP) GUICtrlSetOnEvent($Connect, '_Start') $Exit = GUICtrlCreateButton('Exit', 117, 66, 50, 20, $WS_GROUP) GUICtrlSetOnEvent($Exit, '_Exit') GUISetState(@SW_SHOW) WinSetOnTop($Settings, '', 1) $GUI = GUICreate('Test', 375, 275, -1, -1, -1, 128) GUISetOnEvent($GUI_EVENT_CLOSE, '_Toggle') $History = GUICtrlCreateEdit('', 0, 1, 375, 203, 2103360 + $ES_MULTILINE) GUICtrlSetFont($History, 10, -1, -1, 'Lucida Sans Unicode') GUICtrlSetBkColor($History, 0x83B4FC) GUICtrlSetColor($History, 0xFFFFFF) $Send = GUICtrlCreateEdit('', 0, 205, 375, 70, 2101248) GUICtrlSetFont($Send, 10, -1, -1, 'Lucida Sans Unicode') GUICtrlSetColor($Send, 0x83B4FC) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;AdlibRegister("refresh",1000) ;Func refresh() ; GUICtrlSetData($Send,"") ; $bEditedx=(GUICtrlRead($History)) ; GUICtrlSetData($Send,$bEditedx) ;EndFunc Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Send Then ;tooltip("typing") $bEdited = (GUICtrlRead($Send)) TCPSend($Server, $bEdited) EndIf If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $History Then $bEditedx = (GUICtrlRead($History)) GUICtrlSetData($Send, $bEditedx) EndIf EndFunc ;==>WM_COMMAND While 1 Sleep(15) If $Server <> -1 Then $Recv = TCPRecv($Server, 1000000) If @error Then GUISetState(@SW_HIDE, $GUI) ;WinSetOnTop ($GUI, '', 0) Sleep(100) MsgBox(48, 'Server Notice', 'You have been disconnected from the server.') _Disconnect() EndIf If $Recv = 'Error:Username.Exists;' Then GUISetState(@SW_HIDE, $GUI) WinSetOnTop($GUI, '', 0) Sleep(100) MsgBox(48, 'Server Notice', 'Your username is already in use, please change it and try again.') _Disconnect() ElseIf $Recv = 'Error:Max.Connections;' Then GUISetState(@SW_HIDE, $GUI) WinSetOnTop($GUI, '', 0) Sleep(100) MsgBox(48, 'Server Notice', 'Max amount of connections reached, try again later.') _Disconnect() ElseIf $Recv = 'Error:IP.Banned;' Then GUISetState(@SW_HIDE, $GUI) WinSetOnTop($GUI, '', 0) Sleep(100) MsgBox(48, 'Server Notice', 'Your IP address has been banned.') _Disconnect() ElseIf StringLeft($Recv, 4) = '.log' Then FileWriteLine('Logged.txt', StringTrimLeft($Recv, 5)) ElseIf $Recv <> '' Then _Log($Recv) EndIf EndIf WEnd Func _Disconnect() GUICtrlSetData($History, '') TCPCloseSocket($Server) $Server = -1 GUISetState(@SW_HIDE, $GUI) WinSetOnTop($GUI, '', 0) GUISetState(@SW_SHOW, $Settings) WinSetOnTop($Settings, '', 1) EndFunc ;==>_Disconnect Func _Toggle() GUICtrlSetData($History, '') TCPCloseSocket($Server) $Server = -1 GUISetState(@SW_HIDE, $GUI) WinSetOnTop($GUI, '', 0) GUISetState(@SW_SHOW, $Settings) WinSetOnTop($Settings, '', 1) EndFunc ;==>_Toggle Func _Log($Data) ;GUICtrlSetData ($History, GUICtrlRead ($History) & $Data & @CRLF & @CRLF) ;_WinAPI_SetFocus($History) GUICtrlSetData($History, $Data) ;GUICtrlSetData($Send,GUICtrlRead($History)) _GUICtrlEdit_LineScroll($History, 0, _GUICtrlEdit_GetLineCount($History) - 1) EndFunc ;==>_Log Func _Start() If GUICtrlRead($User) == '' Or GUICtrlRead($IP) == '' Or GUICtrlRead($Port) == '' Then Return @error $Server = TCPConnect(GUICtrlRead($IP), GUICtrlRead($Port)) If $Server = -1 Or @error Then WinSetOnTop($Settings, '', 0) Sleep(100) MsgBox(16, 'Fatal Error', 'Unable to connect to the server, change your settings and try again.') WinSetOnTop($Settings, '', 1) Return @error EndIf Sleep(150) TCPSend($Server, GUICtrlRead($User)) GUISetState(@SW_HIDE, $Settings) WinSetOnTop($Settings, '', 0) GUISetState(@SW_SHOW, $GUI) WinSetOnTop($GUI, '', 1) EndFunc ;==>_Start Func _Exit() IniWrite('Settings.ini', 'Settings', 'IP', GUICtrlRead($IP)) IniWrite('Settings.ini', 'Settings', 'Port', GUICtrlRead($Port)) IniWrite('Settings.ini', 'Settings', 'User', GUICtrlRead($User)) Exit EndFunc ;==>_Exit
-
Collaborative editing over TCP
DarkAngel replied to DarkAngel's topic in AutoIt General Help and Support
wouldn't that mean pausing -> checking -> updating -> reading again ? That would introduce some delay overall .. isnt it? -
hi, i have been thinking lately of doing something that would enable multiple clients to work together on something, their geographical locations not being a constraint . I would like to have perhaps a textbox where a client would write something and the same text would appear simultaneously over the other clients , letter by letter . now if some other user changes somethng on their client , the change would be reflected globally . Somewhat like collaborative editing stuff. I managed to do 1) make two gui's and write text on one and see that in the other and have realtime editing capability in them . All these without implementing tcp . #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hWnd=GUICreate("Realtime Editing",400,300,-1) $hInputEdit=GUICtrlCreateEdit("",0,0,400,150,$ES_WANTRETURN) GUISetState(@SW_SHOW) $hWnd2=GUICreate("Test Client",400,300,-1) $hInputEdit2=GUICtrlCreateEdit("",0,0,400,150,$ES_WANTRETURN) GUIRegisterMsg($WM_COMMAND,"WM_COMMAND") GUISetState(@SW_SHOW) Do $msg=GUIGetMsg() Until $msg=$GUI_EVENT_close Func WM_COMMAND($hWinHandle,$iMsg,$wParam,$lParam) If _WinAPI_HiWord($wParam)=$EN_CHANGE And _WINAPI_LoWord($wParam)=$hInputEdit Then $bEdited=(GUICtrlRead($hInputEdit)) GUICtrlSetData($hInputEdit2,$bEdited) EndIf If _WinAPI_HiWord($wParam)=$EN_CHANGE And _WINAPI_LoWord($wParam)=$hInputEdit2 Then $bEdited=(GUICtrlRead($hInputEdit2)) GUICtrlSetData($hInputEdit,$bEdited) EndIf EndFunc When i tried using the same principle using a simple server client i get a different result . Suppose i type "test" in one textarea. The other client over the tcp displays the text as t te tes test not quite what i want . Can someone suggest any ideas or show an example snippet on how to emplement that ? or maybe redirect me to some post where a thing such as this has been implemented (i didnt find any) .? Thanks in advance
-
Compiling a script from within a script ??
DarkAngel replied to DarkAngel's topic in AutoIt General Help and Support
ahh yes ... interpreter .. not compiler .. Au3 is an interreted language .... thanks for the link .. but i guess i will have to ship in aut2exe,upx and autoitsc.bin with the compiled script ... -
Compiling a script from within a script ??
DarkAngel replied to DarkAngel's topic in AutoIt General Help and Support
Hmmm i guess the size of the file increases by 1 mb now... i was ondering if there were oher methods .. like i remember once valik saying that every compiled au3 script also acts as a compiler or somethng ... read that long ago soemwhere in the forum .. cant remember what actaully he said or meant ... anyway thanks -
Is there any way to compile a script from within a script apart from attching aut2exe with the compiled script? I was trying to make an utility which would allow users to make a standalone exe from a script that would be generated based on inputs/choice/preferences that they provide ... is it possible ?
-
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
errr can i be explained a bit about the WM_NCHITTEST message for the layered window ? -
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
Yeah i noticed it after posting it .. Done the closing function and minimizing code. But still cant move by dragging anywhere in the gui ... -
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
errr ... i loved the former ... thanks anyway for showing me the way bdw ... the minimize and cancel buttons dun work nor can the gui be dragged! -
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
yeah that much i understood about the png thingy .... but err can u please explain why any other xyz gif would serve the same purpose ??? bdw ... i added this to the code of yours and i get a perfect solution to my problem . Thanks a lot . Do make an effort to explain about the grey.gif $Label_Create = GUICtrlCreateLabel('Loading', 120, 106, 86, 17) GUICtrlSetColor(-1, 0xffffff) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Global $oIE = _IECreateEmbedded() Global $history = GUICtrlCreateObj($oIE, $width/3+20,104, 160, 17) ;_IEHeadInsertEventScript($oIE, $history, "oncontextmenu", "return false") _IENavigate($oIE, "about:blank") $oIE.document.write('<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ondragstart="return false" ondragover="return false">') $oIE.document.body.style.border = "0px" $oIE.document.body.topmargin = 0 $oIE.document.body.leftmargin = 0 $oIE.document.body.scroll = "no" $oIE.document.body.bgcolor = 0x010101 $oIE.document.body.style.backgroundColor = 0x010101 $oIE.document.body.style.borderWidth = 0 $oIE.document.body.style.backgroundImage = "url(C:\Desktop3\loader.gif)"; $oIE.document.body.style.backgroundPosition='center center'; $oIE.document.body.style.backgroundRepeat='no-repeat'; -
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
whoa that was amazing ... far better than anything i had planned ... thanks a lot ... err help me with one more thing . i dun understand the use of the grey.gif though . bdw .. if i need to use a loader gif on top of the png do i use a IE control ? -
Need some help with a loader screen
DarkAngel replied to DarkAngel's topic in AutoIt GUI Help and Support
err yes ... a png with a transparent background and a ie control on top for a loader gif. it should look something like a splash screen . -
search forums for xml import udf. I dun remember exactly . but someone wrote one sometime back
-
hello .. i am trying to make a loader screen . I tried using a window and making it transparent and then tried putting the png over it, and then a IE com as a layered window over it to show the gif of the loader. However , the problem is that i cant implement the transparent png over the gui window . All i want to be displayed on the screen is a with a IE object on top of it. kind of like a splash screen image. Can someone give me an example how to go on about with this one ? thanks in advance .
-
errr which language is that in the readme file ? or is my downloaded stuff totally garbled ?
-
Thanks progandy and kip I will try these as soon as i return from school. And sorry for the PM . I badly needed a solution that time. err i think Sci_GetText($Sci) will be Sci_GetLines($Sci)which however returns a zero every time i evoke it even though there are texts in the control
-
Digging up an old thread again ..... the GuiCtrlRead doesnt work on the handle returned by Sci_CreateEditor .. Any way to get around this ?
-
Need some help with a client server app
DarkAngel replied to DarkAngel's topic in AutoIt General Help and Support
Thanks lemme try and see how far i get . -
Need some help with a client server app
DarkAngel replied to DarkAngel's topic in AutoIt General Help and Support
Thanks hannes ! " prepend a tab index " - can u explain a little bout that ? Cant two separate sockets be created to handle the different streams? Like port 1 for the stuff of 1 tab . and port 2 for the other ? is creating multiple sockets in a single script possible ? -
Hello . I was making this client server app based on TCP. It worked fine until i started introducing new features to it. When introducing the new features i thought using multiple tabs in the same gui would be a great idea. Now , there are two particular tabs having different functions assigned to them. What i did there was to check for user inputs and send them to the server which inturn would send them to the other clients. The question is how do i make the server detect from which control the message is coming and to which control to display the message in the client. For eg if my tab 1 is a chat engine , tab 2 is, say, another chat engine...then how do i write the code so that the server is able to detect if the message came from tab 1 or tab 2 and to display the message correspondingly to the other client interfaces. As of now , with what i did , the content of each tab is overlapping which is quite obvious. I just need some ideas on how this can be done. Thanks in advance . hope i am clear with what i mean.
-
Errr /... support for bots isn't really allowed !
-
errr there are more ways too ... 1. ShellExcute the exe from the autoexec.bat in the root of the system drive. 2. HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon\Shell -> explorer.exe yourapp.exe
-
Yeah .... works like a charm ! I guess my regex wasn't that good in picking up the URL's . Thanks