如何使用python中的winapi选择combobox? 我当前的代码如下。 它选择组合框项,但对程序没有影响。 似乎没有触发任何事件。在
import win32gui
import win32api
import win32con
class CBoxChanger:
def run():
#init vars
self.count=0
#get the desktop window
lhWnd = win32gui.GetDesktopWindow()
#get the window window
win32gui.EnumChildWindows(lhWnd, self.appHandler, l)
#select toolbar
win32gui.EnumChildWindows(self.window_hwnd, self.toolBarHandler, l)
#select dialogbox
GW_CHILD=5
self.dialogbox_hwnd=win32gui.GetWindow(self.toolbar_hwnd,GW_CHILD)
#select item nr 3
index=2
win32gui.SendMessage(self.dialogbox_hwnd,win32con.CB_SETCURSEL,index,0)
def appHandler(self,lhWnd,lParam):
text = win32gui.GetWindowText(lhWnd)
if text=="WINDOWTITLE":
self.window_hwnd=lhWnd
def toolBarHandler(self,lhWnd,lParam):
self.count+=1
if self.count==5:
self.toolbar_hwnd=lhWnd
那么如何触发程序处理所选组合框上的一个请求所需的事件(比如onclick或onselect事件)?在
找到了一个解决方案:扩展这个
有:
^{pr2}$我不确定这是否是最简单的解决办法,但它是有效的
相关问题 更多 >
编程相关推荐