py登陆测试
# -*- coding:gb2312 -*-
from ctypes import *
user32 = windll.LoadLibrary('user32')
hDlg = user32.FindWindowW( '#32770', '用户登录' )
print('hDlg = 0x%08x' % hDlg)
if hDlg == 0:
print('hDlg=NULL')
exit()
hTmp = user32.GetDlgItem(hDlg, 0x3f4);
print('hTmp = 0x%08x' % hTmp)
if hTmp == 0:
print('hTmp=NULL')
exit()
user32.SetFocus(hTmp)
# 通过反编译以前obj文件得到一些常数值 dumpbin /disasm htlogin.obj
user32.SendDlgItemMessageW(hDlg, 0x3f4, 0x0c, 0, '111222') # WM_SETTEXT=0x0c
user32.SendDlgItemMessageW(hDlg, 0x3e9, 0x0c, 0, '333444') # WM_SETTEXT=0x0c
user32.SendDlgItemMessageW(hDlg, 0x3ee, 0xf5, 0, 0) # BM_CLICK=0xf5