I want to write a Simple P2P RDP Client and Server in Python. This is how I Sketched it out.
- Take Screenshots in short Interval
- Compress them and send to the server application
- Get Keyboard, Mouse events from server application. Serialize them and send to client. Client will unserialize them and will use SendInput Calls to reflect them
and What I need to know is
- Do there exist and rdp library in Python that I can use to simplify my Job ?
- How to get Keyboard or Mouse Event from Server Operator with Python ?
- Whats the easiest and simplest way of serialization of events ?
- How can I measure the relative X,Y coordinates of Mouseevent ?
- can you provide any example thats easy to follow ?
- and the Final question I've heard it will be easier to do it in .net if both the platforms are using Microsoft derivative OS. Is it true ?
My Client Application will run in Windows XP,Vista,7 and the server Application will run on Windows/Linux and also Please mention If I am missing something.
Some time ago I wrote something called easyrfb which, too, is based on python-vnc-viewer, but I never published it. It does not cover exactly what you asked, but it is very similar. In the hope it might be helpful, parts of it now can be found at http://hydra.geht.net/easyrfb/
Note that the files there are not always in a working state, because the files are directly linked to my working copy. But I am not editing often.
It's now available on GitHub, too: https://github.com/hilbix/pyrfb/tree/easyrfb
This it what it does at my side:
- Connect to a locally running Xvnc (technically any VNC server will do)
- Continuously write the current screen contents to a highly compressed test.jpg
- Some web page grabs that using AJAX and updates an image
- Mouse clicks on that image are forwarded to the VNC server as mouse clicks
- Keyboard input can be simulated using forms
- And one can take lossless PNG screenshots
- There is an edit.html to do fuzzy matching based on the PNG screenshots (called templates)
- Shell scripts can check if such templates are matched or wait for them to match.
The internal communication is done using TCP, Unix-Sockets and some files, so it's not difficult to change it such, that every component runs at a different location:
- The VNC server (the screen to show)
rfbimg.py
(which does VNC -> image and offers the control.sock
)- The shell scripts (if needed, using
sendsock.py
to talk to.sock
) - The web service (
AJAX
, andGET
image) with stubs (forwarding commands to.sock
) - The controlling web client (any browser, even
lynx
ortelnet
can do)
Please do not ask me for documentation! Use the source, Luke!
Mental health warning! The complete picture is a big and ugly grown unclean pile of headache-inducing-facepalm creating bits of mostly unrelated randomly placed complex scripts with wrong and misleading names, unclean copies, uncommented and unfinished half-edits, everything hardcoded to exactly one single machine, probably needing some undocumented local 10 year old tweaks to nonupgraded packages, or even older stuff. So I will not hand out everything. (And even if this sounds familiar, nope, I am not working for Microsoft.)
Well apart from the "in Python", sounds like you're just reinventing another VNC. Most modern derivatives are based on TightVNC which is open source. If you can understand the VNC code (C++) and the RFB protocol it uses, you'll find all of your questions answered.
This python implementation of a VNC client might also be interesting to you. However, note the comment on that page:
What is it good for? Nothing ;-) Use the original VNC viewer for better performance.
Maybe you can achieve your goals by reusing VNC technology in some way ? (e.g creating Python bindings for the VNC C++ code and/or using the RFB protocol so you can interoperate with existing VNC servers/clients ?)
As per this GitHub comment, you can use libfreerdp
via ctypes
in Python.
See: FreeRDP library at GitHub.
FreeRDP is a free remote desktop protocol library and clients http://www.freerdp.com/
来源:https://stackoverflow.com/questions/5381152/p2p-rdp-with-python