Servidor
1 2 3 4 5 6 7 8 9 10 |
## Server $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,0) $udp = New-Object System.Net.Sockets.UdpClient 2020 $posiciones = [Text.Encoding]::ASCII.GetString($udp.Receive([ref]$ip)) [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((([Int]$posiciones.split("*")[0]+100)),$posiciones.split("*")[1]) $udp.Close() |
Cliente
1 2 3 4 5 6 7 8 9 10 11 12 |
## Cliente $ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,2020) $udp = New-Object System.Net.Sockets.UdpClient $enviar = [System.Windows.Forms.Cursor]::Position.x.ToString()+"*"+[System.Windows.Forms.Cursor]::Position.y.ToString() $mensaje = [Text.Encoding]::ASCII.GetBytes($enviar) $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null $udp.Close() |