Servidor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
## Server $MouseEventSig=@' [DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)] public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo); '@ $MouseEvent = Add-Type -memberDefinition $MouseEventSig -name "MouseEventWinApi" -passThru $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($posiciones.split("*")[0],($posiciones.split("*")[1]+100)) $MouseEvent::mouse_event(0x00000002, 0, 0, 0, 0) $MouseEvent::mouse_event(0x00000004, 0, 0, 0, 0) $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() |