<h1><font size="1"><a href="win32gui.html">win32gui</a>.</font><font style="background-color: rgb(49, 106, 197);" color="#ffffff" size="1">FindWindow</font></h1>
<p><font size="1">int = <b><font style="background-color: rgb(49, 106, 197);" color="#ffffff">FindWindow</font>(<i>className</i><i>, WindowName</i> </b>)
</font></p><p><font size="1">Retrieves a handle to the top-level window whose class name and window name 
match the specified strings.
</font></p><p>
</p><h3><font size="1">Parameters</font></h3>
<p>
</p><dt><font size="1"><i>className</i> : int/string
</font>
</dt><dd>

<br></dd><dt><font size="1"><i>WindowName</i> : string</font>
<p></p></dt><br>HWND FindWindow(<br>&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpClassName, // pointer to class name<br>&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpWindowName&nbsp;&nbsp;// pointer to window name<br>&nbsp;&nbsp; );<br><br><br><br><br><br>BOOL EnumWindows(<br>&nbsp;&nbsp;&nbsp;&nbsp;WNDENUMPROC lpEnumFunc, // pointer to callback function
<br>&nbsp;&nbsp;&nbsp;&nbsp;LPARAM lParam&nbsp;&nbsp;// application-defined value<br>&nbsp;&nbsp; );<br><br>I am not sure what this is for @_@<br><br><br><br>BOOL PostMessage(<br>&nbsp;&nbsp;&nbsp;&nbsp;HWND hWnd, // handle of destination window<br>&nbsp;&nbsp;&nbsp;&nbsp;UINT Msg, // message to post
<br>&nbsp;&nbsp;&nbsp;&nbsp;WPARAM wParam, // first message parameter<br>&nbsp;&nbsp;&nbsp;&nbsp;LPARAM lParam&nbsp;&nbsp;// second message parameter<br>&nbsp;&nbsp; );<br><br><br><br>with pywin32, shouldn&#39;t <br><br><span class="value">
win32api.keybd_event<br>win32api.GetFocus<br>win32api.mouse_event</span><br><br><br><br>be used instead?<br><br><br><br><br><br><div><span class="gmail_quote">On 6/30/07, <b class="gmail_sendername">Alan Gauld</b> &lt;<a href="mailto:alan.gauld@btinternet.com">
alan.gauld@btinternet.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>&quot;Lisa Barrott&quot; &lt;<a href="mailto:lisa.barrott@btinternet.com">
lisa.barrott@btinternet.com</a>&gt; wrote<br><br>&gt; I was wondering if there was any way to force a mouse click at a set<br>&gt; location using python even when the another window is focussed.<br>&gt; I&#39;m using Windows XP
<br><br>Yes, you can use the Win32 API.<br>You need to get the target window handle with<br><br>-------------<br>HWND FindWindow(<br>&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpClassName, // pointer to class name<br>&nbsp;&nbsp;&nbsp;&nbsp;LPCTSTR lpWindowName&nbsp;&nbsp;// pointer to window name
<br>&nbsp;&nbsp; );<br> ---------------<br><br>or<br><br>--------------------<br>BOOL EnumWindows(<br>&nbsp;&nbsp;&nbsp;&nbsp;WNDENUMPROC lpEnumFunc, // pointer to callback function<br>&nbsp;&nbsp;&nbsp;&nbsp;LPARAM lParam&nbsp;&nbsp;// application-defined value<br>&nbsp;&nbsp; );<br>----------------------
<br><br>Then you can use PostMessage() to generate a mouse event.<br><br>BOOL PostMessage(<br>&nbsp;&nbsp;&nbsp;&nbsp;HWND hWnd, // handle of destination window<br>&nbsp;&nbsp;&nbsp;&nbsp;UINT Msg, // message to post<br>&nbsp;&nbsp;&nbsp;&nbsp;WPARAM wParam, // first message parameter
<br>&nbsp;&nbsp;&nbsp;&nbsp;LPARAM lParam&nbsp;&nbsp;// second message parameter<br>&nbsp;&nbsp; );<br><br>You can get the full docs on these functions on MSDN and the winall<br>package should provide access to them, or the ctypes module will<br>allow direct access for a bit more work.
<br><br>There might be other more pythonic modules around that do the<br>heavy lifting for you, but these are not too hard to use.<br><br>HTH,<br><br>--<br>Alan Gauld<br>Author of the Learn to Program web site<br><a href="http://www.freenetpages.co.uk/hp/alan.gauld">
http://www.freenetpages.co.uk/hp/alan.gauld</a><br><br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">
http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>