用python怎么查看syslistview32的内容
1个回答
2015-09-08
展开全部
参考一下Notepad的
# encoding: cp936
import win32gui,win32api,win32con
def MsgBox(text, title="Python"):
win32api.MessageBox(0, text, title, 0)
def ShellExecute(file="", option="", dir=""):
win32api.ShellExecute(0, "open", file, option, dir, win32con.SW_SHOWNORMAL)
def SetForegroundWindow(whnd):
win32gui.SetForegroundWindow(whnd)
def FindWindow(classname=None, title=None):
whnd = win32gui.FindWindow(classname, None)
return whnd
def FindWindowEx(handle=None, classname=None):
ehnd = win32gui.FindWindowEx(handle,0,classname,None)
return ehnd
def SetText(ehnd, text):
win32gui.SendMessage(ehnd, win32con.WM_SETTEXT, 0, text)
def SetSelText(ehnd, text):
win32gui.SendMessage(ehnd, win32con.EM_REPLACESEL, 0, text)
def GetText(ehnd):
buf_size = 1 + win32gui.SendMessage(ehnd, win32con.WM_GETTEXTLENGTH, 0, 0)
buffer = win32gui.PyMakeBuffer(buf_size)
win32gui.SendMessage(ehnd, win32con.WM_GETTEXT, buf_size, buffer)
return buffer[:buf_size]
if __name__=='__main__':
whnd = FindWindow("Notepad", None)
ehnd = FindWindowEx(whnd, "Edit")
print whnd,ehnd
SetForegroundWindow(whnd)
SetText(ehnd, "xyz")
print GetText(ehnd)
# encoding: cp936
import win32gui,win32api,win32con
def MsgBox(text, title="Python"):
win32api.MessageBox(0, text, title, 0)
def ShellExecute(file="", option="", dir=""):
win32api.ShellExecute(0, "open", file, option, dir, win32con.SW_SHOWNORMAL)
def SetForegroundWindow(whnd):
win32gui.SetForegroundWindow(whnd)
def FindWindow(classname=None, title=None):
whnd = win32gui.FindWindow(classname, None)
return whnd
def FindWindowEx(handle=None, classname=None):
ehnd = win32gui.FindWindowEx(handle,0,classname,None)
return ehnd
def SetText(ehnd, text):
win32gui.SendMessage(ehnd, win32con.WM_SETTEXT, 0, text)
def SetSelText(ehnd, text):
win32gui.SendMessage(ehnd, win32con.EM_REPLACESEL, 0, text)
def GetText(ehnd):
buf_size = 1 + win32gui.SendMessage(ehnd, win32con.WM_GETTEXTLENGTH, 0, 0)
buffer = win32gui.PyMakeBuffer(buf_size)
win32gui.SendMessage(ehnd, win32con.WM_GETTEXT, buf_size, buffer)
return buffer[:buf_size]
if __name__=='__main__':
whnd = FindWindow("Notepad", None)
ehnd = FindWindowEx(whnd, "Edit")
print whnd,ehnd
SetForegroundWindow(whnd)
SetText(ehnd, "xyz")
print GetText(ehnd)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询