Popular recipes tagged "computer"http://code.activestate.com/recipes/tags/computer/2016-05-27T05:28:21-07:00ActiveState Code RecipesShutdown your computer via E-mail - Python (Python) 2016-05-27T05:28:21-07:00Burak Tandoganhttp://code.activestate.com/recipes/users/4191373/http://code.activestate.com/recipes/580668-shutdown-your-computer-via-e-mail-python/ <p style="color: grey"> Python recipe 580668 by <a href="/recipes/users/4191373/">Burak Tandogan</a> (<a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/email/">email</a>, <a href="/recipes/tags/mail/">mail</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shutdown/">shutdown</a>). Revision 2. </p> <p>Shutdown your computer via E-mail.</p> <p>Basically, send an e-mail to your e-mail address SHUTDOWN YOURSELF {YEAR-MONTH-DATE} format in Subject. Your mail's SUBJECT must be in SHUTDOWN YOURSELF {YEAR-MONTH-DATE} format.</p> OpenKinect Mouse Control Using Python (Python) 2012-04-15T18:49:00-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578104-openkinect-mouse-control-using-python/ <p style="color: grey"> Python recipe 578104 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/computer_vision/">computer_vision</a>, <a href="/recipes/tags/depth/">depth</a>, <a href="/recipes/tags/hand_tracking/">hand_tracking</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/opencv/">opencv</a>, <a href="/recipes/tags/openkinect/">openkinect</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tracking/">tracking</a>, <a href="/recipes/tags/vision/">vision</a>). Revision 2. </p> <p>This is a simple code that lets a user control the mouse and left-click using the Microsoft Kinect, Python, and OpenKinect. </p> <pre class="prettyprint"><code>Computer Prerequisites: -OpenKinect -Python Wrapper for OpenKinect -A Linux machine using Ubuntu -OpenCV 2.1 -OpenCV 2.3 -Python 2.7.2 -A Microsoft Kinect -A Microsoft Kinect USB Adapter -PyGame -Xlib for Python </code></pre> <p>To run this code you either need to start it in the terminal or you need to write a short bash script that runs the code. This is necessary because it requires super-user privileges.</p> <p>The Bash script is (Assuming the code is saved by the name 'Hand Tracking.py' in /home/$USER directory:</p> <pre class="prettyprint"><code>#!bin/bash cd 'home/$USER' gksudo python 'Hand Tracking.py' </code></pre> <p>The code is heavily commented and most of what you will need to know is there. </p> Control your mouse with the Microsoft Kinect using OpenKinect (Python) 2012-03-19T21:28:08-07:00Alexander James Wallarhttp://code.activestate.com/recipes/users/4179768/http://code.activestate.com/recipes/578082-control-your-mouse-with-the-microsoft-kinect-using/ <p style="color: grey"> Python recipe 578082 by <a href="/recipes/users/4179768/">Alexander James Wallar</a> (<a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/control/">control</a>, <a href="/recipes/tags/freenect/">freenect</a>, <a href="/recipes/tags/kinect/">kinect</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/microsoft/">microsoft</a>, <a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/openkinect/">openkinect</a>, <a href="/recipes/tags/vision/">vision</a>, <a href="/recipes/tags/xlib/">xlib</a>). </p> <p>This is a simple code that uses the Kinect in order to simulate the mouse on the screen. In order for this code to work you must have a Linux machine, the freenect module from OpenKinect, NumPy, and Xlib. The last three can be downloaded and installed by running sudo apt-get install {PROGRAM NAME HERE}. Freenect needs to be downloaded and installed for python using the terminal and there are good instructions here how to do it <a href="http://openkinect.org/wiki/Getting_Started" rel="nofollow">http://openkinect.org/wiki/Getting_Started</a>. You will also need to install the python wrapper. This can be done by following the instructions on this site: <a href="http://openkinect.org/wiki/Python_Wrapper" rel="nofollow">http://openkinect.org/wiki/Python_Wrapper</a>. To run the code you must first cd into the directory in which the code resides and then in the terminal run the command sudo python {THE NAME YOU STORED THE CODE BELOW AS}.py. This should run the code. The code needs superuser privileges. Also if you wonder why the mouse will stop tracking your hand, there are two reasons. 1) This code is not super sophisticated, all it does is find the minimum point in the depth image and scales the coordinates to the size of the screen and moves the mouse there so if your stomach is the closest thing to the screen it will track it and place the mouse there. The other reason the mouse might stop tracking is because there is a counter in the that will only let it run 10000 iterations. This is just a safety precaution in case you are not able to control the mouse and the computer freaks out. The last thing you need to know to run this code is that the main_mouse() function takes to arguments, the first is the x dimension of your screen and the second is the y dimension. THE CODE WILL NOT FUNCTION PROPERLY ON MULTIDISPLAY COMPUTERS. Thank You</p> Check PC Power (Python) 2011-08-28T12:25:49-07:00Frank Larkinhttp://code.activestate.com/recipes/users/4179117/http://code.activestate.com/recipes/577861-check-pc-power/ <p style="color: grey"> Python recipe 577861 by <a href="/recipes/users/4179117/">Frank Larkin</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/passing/">passing</a>, <a href="/recipes/tags/pointers/">pointers</a>, <a href="/recipes/tags/power/">power</a>, <a href="/recipes/tags/widows/">widows</a>). </p> <p>Call windows API GetSystemPowerStatus to determine if the AC power is on or off. Great example of calling Windows APIs using Ptyhon.</p>