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

震坤 蔡 caizhenkun19850809 at yahoo.com.cn
Thu Jan 3 16:35:14 CET 2013


Thanks for your reply.
For the program I have written:
print "abc"
hWindow = win32gui.FindWindow('MsiDialogCloseClass', None)
if hWindow <> 0:
    print hWindow
    hButton = win32gui.FindWindowEx(hWindow, 0, 'Button', '&Next >')
    if hButton <> 0:
        print hButton
        win32gui.SendMessage(win32gui.GetParent(hButton), win32con.WM_COMMAND, win32con.BN_CLICKED, hButton)
    else:
        print "ghi"
else:
    print "def"
The hWindow and hButton can both be printed out and they are both not 0.
The application does not crash but the Next button click action is not triggered.

So the problem is: the handles could be found but the click button message is not successfully sent in Win8 (which could be successful in Win7).

I use Spy++ to check the controls of the dialog. I think they are same in WIn7 and Win8. (What I use is the JDK installation file with version 1.6.0_37. A Next button will display during the installation process. What I want to do is to automate the installation steps.)



________________________________
 发件人: Tim Roberts <timr at probo.com>
收件人: Python-Win32 List <python-win32 at python.org> 
发送日期: 2013年1月3日, 星期四, 1:33 上午
主题: Re: [python-win32] The program passes on Win7 but fails on Win8
 
震坤 蔡 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 );

What DOES happen on Win 8?  Does it simply do nothing?  Does the app
crash?  Do you see valid handles for both the hWindow and the hButton? 
Are you sure the dialog has the same structure in Win 8 that it did in
Win 7?

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

_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20130103/198207d1/attachment.html>


More information about the python-win32 mailing list