winHwnd = FindWindowEx_(0,0,"ClassName","窗口标题")
Debug winHwnd
comHwnd = FindWindowEx_(winHwnd,0,"ComboBox",0)
Debug comHwnd
Debug GetDlgItem_(tabHwnd,340) ;根据控件ID获得hwnd,对于有些程序,更精准
l = SendMessage_(comHwnd,#WM_GETTEXTLENGTH,0,0)+1
a.s=Space(l*2);
Debug l
l = SendMessage_(comHwnd,#WM_GETTEXT,l,@a)
Debug a
;选择指定项目
b.s = str2Hex("新疆")
Debug Str2hex(b)
itemLen = SendMessage_(comHwnd,#CB_GETCOUNT,0,0);获取子项总量
For i=0 To itemLen-1 ;遍历子项
l = SendMessage_(comHwnd,#CB_GETLBTEXTLEN,0,0)+1 ;获取子项文本长度
Debug Str(l)
a.s=Space(l*2);
SendMessage_(comHwnd,#CB_GETLBTEXT,i,@a);
Debug a ;
Debug Str2hex(a)
If Str2hex(a) = b
Debug "设置"
Debug SendMessage_(comHwnd, #CB_SHOWDROPDOWN, 1,0);
Debug SendMessage_(comHwnd, #CB_SETCURSEL,i,0)
Debug SendMessage_(comHwnd, #WM_KEYDOWN, 13, 0)
Debug SendMessage_(comHwnd, #WM_KEYUP, 13, 0)
Break
EndIf
Next