Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The only way to detect mouse events outside your program is to install a Windows hook using <a href="http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx" rel="noreferrer">SetWindowsHookEx</a>. The <a href="http://www.cs.unc.edu/Research/assist/developer.shtml" rel="noreferrer">pyHook</a> module encapsulates the nitty-gritty details. Here's a sample that will print the location of every mouse click:</p> <pre><code>import pyHook import pythoncom def onclick(event): print event.Position return True hm = pyHook.HookManager() hm.SubscribeMouseAllButtonsDown(onclick) hm.HookMouse() pythoncom.PumpMessages() hm.UnhookMouse() </code></pre> <p>You can check the <strong>example.py</strong> script that is installed with the module for more info about the <strong>event</strong> parameter.</p> <p>pyHook might be tricky to use in a pure Python script, because it requires an active message pump. From the <a href="https://web.archive.org/web/20100501173949/http://mindtrove.info/articles/monitoring-global-input-with-pyhook/" rel="noreferrer">tutorial</a>:</p> <blockquote> <p>Any application that wishes to receive notifications of global input events must have a Windows message pump. The easiest way to get one of these is to use the PumpMessages method in the Win32 Extensions package for Python. [...] When run, this program just sits idle and waits for Windows events. If you are using a GUI toolkit (e.g. wxPython), this loop is unnecessary since the toolkit provides its own.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload