SendKeys and Python 2.7

Jakson A. Aquino jaksonaquino at
Sat Sep 18 01:04:51 CEST 2010

> On Mon, Sep 13, 2010 at 4:02 PM, Michel Claveau - MVP
> <enleverLesX_XXmcX at> wrote:
>> Sorry for time, but I am very busy...
>> With Python + Pywin32, you can force the activation of a window (before
>> send some keys...)
>> See:
>>  win32gui.SetForegroundWindow(w_handle)
>> or
>>  win32gui.SetActiveWindow(w_handle)
>> For to find a windows (and his handle), see:
>>  win32gui.EnumWindows()
>>  win32gui.GetWindowTex()
>> or
>>  win32gui.FindWindowEx()

I ended up using Dispatch("WScript.Shell") and AppActivate("R
Console") of the win32com.client module because they are higher level
functions. I guess that your code runs faster, but I don't have an old
machine to compare the performance of the two codes. I still may
switch to your code in the future, when I have easy access to a real
machine running Windows to make some tests. The released version of
the plugin is here:

Thanks for your help!

Jakson Aquino

More information about the Python-list mailing list