| paic |
| | Questa è una semplice lavagna fatta in autoit, molto spartana fatta in precedenza a cui ho aggiunto il protocollo TCP. L'unico bug rilevato è alla chiusura ma non ho voglia di risolverlo sinceramente. Client: CODICE #include <GDIPlus.au3> #Include <Misc.au3> #include <GuiConstantsEx.au3> #include <ScreenCapture.au3> #Include <Timers.au3> #include <WindowsConstants.au3>
TCPStartUp() $dll = DllOpen("user32.dll")
conn() Func conn()
$port=1550 MsgBox(48,"Attenzione","Hai aperto il client di KingPaic-TCP-Blackboard (BETA)."&@CR&"Prima che tu possa connetterti devi settare prima 2 parametri, la porta d'ascolto e l'ip."&@CR& _ "Deve essere una porta aperta in ambe 2 le reti, la tua e la sua, compresa fra 1000 e 31337."&@CR&"Ricorda che dovrai farti comunicare sia l'ip che la porta, per permetterti di connetterti."&@CR& _ 'OPPURE: Il tuo firewall potrebbe richiederti se permettere o meno la connessione, in tal caso dovrai confermare lo "sblocco" della porta.') while 1 $port=InputBox("Porta","Immetti la porta che ha scelto il portatore del server.",$port) if $port < 1000 or $port > 31337 Then MsgBox(16,"Errore","Hai inserito una porta che non può essere stata usata perchè fuori range!") Else ExitLoop EndIf WEnd $ip=InputBox("IP","Immetti l'ip del portatore del server. "&@crlf&"Gli è apparso allo start del programma.")
while 1 Global $socket = TCPConnect($ip,$port) If $socket = -1 Then $q=MsgBox(4,"Errore","Non sei riuscito a connetterti al server, le cause possono essere:"&@CR& _ "Il server che stai cercando di contattare non è più aperto."&@CR& _ "Il server è andato in timeout dopo i 60 secondi di attesa."&@CR& _ "Hai sbagliato o l'ip o la porta."&@CR& _ "La porta prescelta è bloccata quindi non permette scambio di dati."&@CR&@CR& _ "Quindi assicurati di avere inserito i dati giusti e che il server non sia ne chiuso ne in timeout, dopodichè se tutto dovrebbe essere corretto prova a far cambiare porta al server o a sbloccare questa."&@CRLF&@CRLF& _ "Vuoi riprovare con questo IP e PORTA?") if $q = 6 Then Else Exit EndIf Else ExitLoop EndIf
WEnd MsgBox(48,"Connesso!","Sei riuscito a connetterti al server!",3) work() EndFunc
work() Func work() $whitd=500 $heigth=500 $col="0xFF000000" $sp=5 $colg="0xFFFFFFFF"
$hGUI = GUICreate("KingPaic-TCP-Blackboard Client (BETA)", $whitd, $heigth) GUISetStyle($WS_CAPTION) ;GUISetState GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOW+@SW_MAXIMIZE)
_GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ;$hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hBrush1 = _GDIPlus_BrushCreateSolid() _GDIPlus_BrushSetSolidColor($hBrush1,$col)
Do
$recv=TCPRecv($socket,2040) if $recv <> "" Then $st=StringSplit($recv,"§") _GDIPlus_BrushSetSolidColor($hBrush1,$st[1]) _GDIPlus_GraphicsFillEllipse($hGraphic, $st[2],$st[3], $st[4], $st[4],$hBrush1) $recv="" ElseIf $recv="STOP" Then MsgBox(48,"Disconnesso!","Il tuo interlocutore si è disconnesso!") Exit EndIf
$m=GUIGetCursorInfo() if @error Then Else
If _IsPressed("01", $dll) Then ;colora testo sinistro _GDIPlus_BrushSetSolidColor($hBrush1,$col) _GDIPlus_GraphicsFillEllipse($hGraphic, $m[0]-($sp/2), $m[1]-($sp/2), $sp, $sp,$hBrush1) ;_GDIPlus_GraphicsFillEllipse($hGraphic, $m[0],$m[1], $sp, $sp,$hBrush1) TCPSend($socket,$col&"§"&$m[0]-($sp/2)&"§"&$m[1]-($sp/2)&"§"&$sp&"§")
ElseIf _IsPressed("02", $dll) Then ;cancella tasto destro _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillEllipse($hGraphic, $m[0]-$sp, $m[1]-$sp, $sp*2, $sp*2,$hBrush1) TCPSend($socket,$colg&"§"&$m[0]-$sp&"§"&$m[1]-$sp&"§"&$sp*2&"§")
ElseIf _IsPressed("43",$dll) Then ;scegli colore C $cols=_ChooseColor(2) $colss=StringReplace($cols,"0x","") $col="0xFF"&$colss
ElseIf _IsPressed("47",$dll) Then ;scegli spessore g $sp=InputBox("Spessore","Grandezza:",$sp)
ElseIf _IsPressed("2E",$dll) Then ;resetta schermo Canc _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $whitd, $heigth,$hBrush1)
ElseIf _IsPressed("53",$dll) Then ;sfondo S $cols=_ChooseColor(2) $colss=StringReplace($cols,"0x","") $colg="0xFF"&$colss _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $whitd, $heigth,$hBrush1)
ElseIf _IsPressed("09",$dll) Then ;salva TAB $file=FileSaveDialog("Salva il file",@DesktopDir,"Immagine (*.jpg)") if @error Then Else Sleep(500) _ScreenCapture_Capture($file&".jpg")
EndIf EndIf EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Sleep(500) TCPSend($socket,"STOP") Sleep(2000) Exit
;_GDIPlus_BrushDispose ($hBrush1) ;_GDIPlus_GraphicsDispose($hGraphic) ;_GDIPlus_ShutDown ()
EndFunc Server: CODICE #include <GDIPlus.au3> #Include <Misc.au3> #include <GuiConstantsEx.au3> #include <ScreenCapture.au3> #Include <Timers.au3> #include <WindowsConstants.au3>
$dll = DllOpen("user32.dll") TCPStartUp()
connectinos() func connectinos() $port=1550 MsgBox(48,"Attenzione","Hai aperto il server di KingPaic-TCP-Blackboard (BETA)."&@CR&"Prima che tu possa connetterti devi settare prima 1 parametro, la porta d'ascolto."&@CR& _ "Deve essere una porta aperta in ambe 2 le reti, la tua e la sua, compresa fra 1000 e 31337."&@CR&"Ricorda che dovrai comunicargli sia l'ip (sotto mostrato) che la porta, per permettergli di connettersi."&@CR& _ 'OPPURE: Il tuo firewall potrebbe richiederti se permettere o meno la connessione, in tal caso dovrai confermare lo "sblocco" della porta.'&@CR&@CR& _ "IL TUO IP E': "&@IPAddress1) while 1 $port=InputBox("Porta","Immetti una porta tra 1000 e 31337, che sarà il canale di connessione fra i due pc.",$port) if $port < 1000 or $port > 31337 Then MsgBox(16,"Errore","La porta non è all'interno del range specificato!") Else ExitLoop EndIf WEnd
Global $MainSocket = TCPListen(@IPAddress1, $port) If $MainSocket = -1 Then MsgBox(16,"Arrore","E' stato rilevato un'errore allo start dell'ascolto, ricontrolla i parametri, altrimenti assicurati che il sistema tcp all'interno del tuo sistema non abbia problemi.") EndIf
ProgressOn("Connessione","Circa 1 min di attesa","") ProgressSet(1,"IP: "&@IPAddress1&" Porta: "&$port) Local $starttime = _Timer_Init() while 1 global $ConnectedSocket = TCPAccept( $MainSocket)
If $ConnectedSocket >= 0 Then ExitLoop EndIf $v=(_Timer_Diff($starttime)/60000)*100 ProgressSet($v) if $v > 100 Then ProgressOff() $q=MsgBox(4,"Timer scaduto","Sono passati circa 60 secondi e nessuno si è connesso a tè, vuoi riprovare la connessione con questi parametri?") if $q = 6 Then ProgressOn("Connessione","Circa 1 min di attesa","") ProgressSet(1,"IP: "&@IPAddress1&" Porta: "&$port) Local $starttime = _Timer_Init() Else Exit EndIf
EndIf
WEnd ProgressOff() MsgBox(48,"Connesso!","Una persona si è connessa a tè!",3) work()
EndFunc
work() Func work() $whitd=500 $heigth=500 $col="0xFF000000" $sp=5 $colg="0xFFFFFFFF"
$hGUI = GUICreate("KingPaic-TCP-Blackboard Server (BETA)", $whitd, $heigth) GUISetStyle($WS_CAPTION) ;GUISetState GUISetBkColor(0xFFFFFF) GUISetState(@SW_SHOW+@SW_MAXIMIZE)
_GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ;$hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hBrush1 = _GDIPlus_BrushCreateSolid() _GDIPlus_BrushSetSolidColor($hBrush1,$col)
Do $recv=TCPRecv($ConnectedSocket,2040) if $recv <> "" Then $st=StringSplit($recv,"§") _GDIPlus_BrushSetSolidColor($hBrush1,$st[1]) _GDIPlus_GraphicsFillEllipse($hGraphic, $st[2],$st[3], $st[4], $st[4],$hBrush1) $recv="" ElseIf $recv="STOP" Then MsgBox(48,"Disconnesso!","Il tuo interlocutore si è disconnesso!") Exit EndIf
$m=GUIGetCursorInfo() if @error Then Else
If _IsPressed("01", $dll) Then ;colora testo sinistro _GDIPlus_BrushSetSolidColor($hBrush1,$col) _GDIPlus_GraphicsFillEllipse($hGraphic, $m[0]-($sp/2), $m[1]-($sp/2), $sp, $sp,$hBrush1) ;_GDIPlus_GraphicsFillEllipse($hGraphic, $m[0],$m[1], $sp, $sp,$hBrush1) TCPSend($ConnectedSocket,$col&"§"&$m[0]-($sp/2)&"§"&$m[1]-($sp/2)&"§"&$sp&"§")
ElseIf _IsPressed("02", $dll) Then ;cancella tasto destro _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillEllipse($hGraphic, $m[0]-$sp, $m[1]-$sp, $sp*2, $sp*2,$hBrush1) TCPSend($ConnectedSocket,$colg&"§"&$m[0]-$sp&"§"&$m[1]-$sp&"§"&$sp*2&"§")
ElseIf _IsPressed("43",$dll) Then ;scegli colore C $cols=_ChooseColor(2) $colss=StringReplace($cols,"0x","") $col="0xFF"&$colss
ElseIf _IsPressed("47",$dll) Then ;scegli spessore g $sp=InputBox("Spessore","Grandezza:",$sp)
ElseIf _IsPressed("2E",$dll) Then ;resetta schermo Canc _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $whitd, $heigth,$hBrush1)
ElseIf _IsPressed("53",$dll) Then ;sfondo S $cols=_ChooseColor(2) $colss=StringReplace($cols,"0x","") $colg="0xFF"&$colss _GDIPlus_BrushSetSolidColor($hBrush1,$colg) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $whitd, $heigth,$hBrush1)
ElseIf _IsPressed("09",$dll) Then ;salva TAB $file=FileSaveDialog("Salva il file",@DesktopDir,"Immagine (*.jpg)") if @error Then Else Sleep(500) _ScreenCapture_Capture($file&".jpg")
EndIf EndIf EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Sleep(500) TCPSend($ConnectedSocket,"STOP") Sleep(2000) Exit ;_GDIPlus_BrushDispose ($hBrush1) ;_GDIPlus_GraphicsDispose($hGraphic) ;_GDIPlus_ShutDown ()
EndFunc Un giorno forse ne farò una decente ma per ora condivido questa, spero che vi piaccia.
| | |
| |
|