Menu

#624 The program passes on Win7 but fails on Win8

closed-invalid
nobody
pythonwin (177)
5
2013-01-01
2012-12-31
caizhenkun
No

Hi, Sir.

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 a 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 you found I had typed some code wrong, please help to point out.

Thanks

Discussion

  • Mark Hammond

    Mark Hammond - 2013-01-01

    Thanks for your report, but this tracker is for reporting bugs in pywin32 rather than a support forum.

    Please email support requests to the python-win32 mailing list where many more people will see your request and be able to help. You need to be subscribed to the list before you can post to it - see http://mail.python.org/mailman/listinfo/python-win32 for subscription options.

     
  • Mark Hammond

    Mark Hammond - 2013-01-01
    • status: open --> closed-invalid
     
  • Mark Hammond

    Mark Hammond - 2013-01-01

    This is a thin wrapper around the win32 function, so I doubt the failure has anything to do specifically with pywin32. Try emailing the python-win32 list to see if any others have an idea.