Hi, Guys.

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)'.

import win32gui
import win32con
import win32api

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"


However, I wrote another program to validate the SendMessage function.
It will try to add some texts into an existing Notepad program.
But it can get passed on both Win7 and Win8.

print "abc"
hWindow2 = win32gui.FindWindow('Notepad', None)
if hWindow2 <> 0:
    print hWindow2
    hEdit = win32gui.FindWindowEx(hWindow2, 0, 'Edit', None)
    if hEdit <> 0:
        print hEdit
        win32gui.SendMessage(hEdit, win32con.WM_SETTEXT, None, 'hello, czk')
    else:
        print "ghi"
else:
    print "def"


So I wonder whether it is caused by the reason that win32gui.SendMessage only 
partially supports Win8?
As in my examples, you can see win32gui.SendMessage with parameter 
win32con.WM_SETTEXT is OK while with parameters win32con.WM_COMMAND and 
win32con.BN_CLICKED are not supporting win8.
It's only my guessing.

If anyone found I had typed some code wrong, please help to point out.

Thanks and Best Regards
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to