It is not easy to flip pages when explaining the PPT content on the stage. Of course, we can do it with an e-pen, but if we only have a mobile phone and WiFi environment, it is not better to directly use a mobile phone to control it.
I wanted to use the touch screen of the mobile phone and the acceleration sensor to operate the PPT. Due to the limited programming level of Android, A webapp is directly created.
Use a mobile phone to access the target computer (the computer that demonstrates the PPT). Then, the target computer intercepts Parameters Based on the accessed page and responds accordingly.
1. In response to an HTTP request, you can write an HTTP service by yourself because URL parameters are intercepted.Program.
Private void button#click (Object sender, eventargs e) {This. button1.enabled = false; httplistener listener = new httplistener (); listener. authenticationschemes = authenticationschemes. anonymous; string port = string. format ("http: // *: {0}/", textbox1.text); listener. prefixes. add (port); listener. start (); listener. begingetcontext (New asynccallback (getcontext), listener);} private void getcontext (iasyncresult result) {httplistener listener = result. asyncstate as httplistener; httplistenercontext context = listener. endgetcontext (result); new system. threading. thread (delegate () {This. command (context. request. rawurl );}). start (); context. response. contentencoding = system. text. encoding. utf8; context. response. statuscode = 200; // string filename = appdomain. currentdomain. basedirectory + "ppt.html"; // string content = system. io. file. readalltext (filename); string content = HTML; system. io. streamwriter writer = new system. io. streamwriter (context. response. outputstream, context. response. contentencoding); writer. write (content); writer. close (); context. response. close (); listener. begingetcontext (New asynccallback (getcontext), listener );}
The httplistener class is used here. Because operations such as previous pages and next pages are on the same page, all requests return the same page. You can put HTML in a file and read it. In order to make the generated program concise, I directly wrote CSCode. (This is a very bad habit, although it is just a test program)
2. The second is to convert the Web request parameters to the simulated keyboard operation on the local computer.
Public class virtualcontrol {[system. runtime. interopservices. dllimport ("USER32")] Private Static extern int mouse_event (INT dwflags, int dx, int dy, int cbuttons, int dwextrainfo); public static void sendkeys (string keys) {system. windows. forms. sendkeys. send (KEYS);} public static void Pagedown () {system. windows. forms. sendkeys. sendwait ("{pgdn}");} public static void Pageup () {system. windows. forms. sendkeys. sendwait ("{pgup}");} public static void home () {system. windows. forms. sendkeys. sendwait ("{home}");} public static void ESC () {system. windows. forms. sendkeys. sendwait ("{ESC}");} public static void mouseevent (mouseoption option, int X, int y) {mouse_event (INT) option, X, Y, 0, 0);} public static void mousecontext () {mouseevent (mouseoption. rightdown, 0, 0); mouseevent (mouseoption. rightup, 0, 0);} public static void mouseclick () {mouseevent (mouseoption. leftdown, 0, 0); mouseevent (mouseoption. leftup, 0, 0);} public Enum mouseoption: int {move = 0x0001, leftdown = 0x0002, leftup = 0x0004, rightdown = 0x0008, rightup = 0x0010, middledown = 0x0020, middleup = 0x0040, absolute = 0x8000 }}
Therefore, when the HTTP service receives a request, it parses the request URL and converts it to the corresponding command. In this way, we can use our mobile phone to control the PPT presentation on the computer.
My original idea was to use the screen of a smartphone as a paint brush and acceleration sensor to control the top and bottom pages. Here is an idea. We hope that some cool people will achieve the following and share it with us on that day.
The source code is attached.
Http://files.cnblogs.com/Linjianyu/ControlServer.rar