我看到别人的教程里都好好,我一用怎么输出错误呢?
源码如下:
import win32gui , win32con , win32api
win = win32gui.FindWindow('Notepad','无标题 - 记事本')
print( 'Notepad is %x' % win )
tid = win32gui.FindWindowEx( win , None , 'Edit' , None ) #查找子句柄
hwnd = tid
size = win32gui.SendMessage( hwnd , win32con.WM_GETTEXTLENGTH , 0 , 0 ) + 1 # 要加上截尾的字节
print( size )
str_buffer = win32gui.PyMakeBuffer( size ) # 生成buffer对象
print( str_buffer )
win32gui.SendMessage( hwnd , win32con.WM_GETTEXT , size , str_buffer ) # 获取buffer
print ( str_buffer[:size-1] )
print( 'text: ', str_buffer )