[python-win32] The program passes on Win7 but fails on Win8

Tim Roberts timr at probo.com
Wed Jan 2 18:36:17 CET 2013


Tim Roberts wrote:
> 震坤 蔡 wrote:
>> I wrote the following program. It could not pass on Win8, but it can
>> pass on Win7.
>> It will try to simulate the action to click the Next button on an
>> existing dialog (I use JDK installation dialog).
>> I believe the issue comes from the statement
>> 'win32gui.SendMessage(win32gui.GetParent(hButton),
>> win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)'.
> Your call is incorrect.  The WPARAM for BN_CLICKED is supposed to have
> the button's control ID in the low word, and the notification code in
> the high word.  So, you should have:
>
>     win32gui.SendMessage( win32gui.GetParent(hButton, win32con.WM_COMMAND,
>         (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton),
> hButton );

(Whoops, there's a missing parenthesis and an extra semicolon there:)

    win32gui.SendMessage( win32gui.GetParent(hButton),
        win32con.WM_COMMAND,
        (win32con.BN_CLICKED << 16) | win32gui.GetDlgCtrlID(hButton),
        hButton )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list