卡键神器:win32api,SetBkMode,PostMessage
#coding:utf-8

import win32api
import win32con
import win32gui
if __name__ == "__main__":
        textCtrlXian = '2'
        hWndText  = win32gui.FindWindow("Notepad",u'新建文本文档 ('+bytes(textCtrlXian)+u').txt - 记事本')
        hWndEdit = win32gui.FindWindowEx(hWndText,None,"Edit",None)

        win32gui.SetBkMode(hWndEdit, win32con.TRANSPARENT)

        iStr = 'abcdefghizxy'
        for i in iStr:
            if int(hWndEdit) <= 0:
                print(u'没有找到模拟器,退出进程................')
                exit(0)
            yy = ord(i)

            if yy>96 and yy<123 :
                zz= yy-32
                win32api.PostMessage(hWndEdit, win32con.WM_KEYDOWN, zz, 0) #w
                win32api.PostMessage(hWndEdit, win32con.WM_KEYUP, zz, 0) #w
            else:

                print (u'不是a-z之间字符................')

标签:win32gui FindWindow SetBkMode win32api PostMessage