def __init__(self,hwndparent):
styles = win32con.WS_CHILD \
| win32con.WS_VISIBLE \
| win32con.WS_CLIPSIBLINGS \
| win32con.WS_CLIPCHILDREN \
| commctrl.TBSTYLE_LIST \
| commctrl.TBSTYLE_FLAT \
| commctrl.TBSTYLE_TRANSPARENT \
| commctrl.CCS_TOP \
| commctrl.CCS_NODIVIDER \
| commctrl.CCS_NORESIZE \
| commctrl.CCS_NOPARENTALIGN
self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
0, 0, 100, 100,
hwndparent, 0, win32gui.dllhandle,
None)
win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
python类SendMessage()的实例源码
def Stock_option(Index):
try:
#tjxg = win32gui.FindWindow('#32770','????')
gs = win32gui.FindWindowEx(win32gui.FindWindow('#32770','????'),None,'ComboBox',None)
#time.sleep(1)
print(hex(gs))
win32gui.SendMessage(gs,win32con.CB_SHOWDROPDOWN,1,0) #??ComboBox???
time.sleep(1)
win32gui.SendMessage(gs,win32con.CB_SETCURSEL,Index,0)#???????
time.sleep(1)
win32gui.SendMessage(gs,win32con.WM_SETFOCUS,0,0)#????
time.sleep(1)
win32gui.SendMessage(gs,win32con.WM_KEYDOWN,0,0)#???????
time.sleep(1)
win32gui.SendMessage(gs,win32con.WM_KEYUP,0,0)
time.sleep(1)
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#????
def main():
try:
path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
key = OpenKey(reg, path, 0, KEY_ALL_ACCESS)
if len(sys.argv) == 1:
show(key)
else:
name, value = sys.argv[1].split('=')
if name.upper() == 'PATH':
value = queryValue(key, name) + ';' + value
if value:
SetValueEx(key, name, 0, REG_EXPAND_SZ, value)
else:
DeleteValue(key, name)
win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment')
except Exception, e:
print e
CloseKey(key)
CloseKey(reg)
def CreateViewWindow(self, prev, settings, browser, rect):
print "FileSystemView.CreateViewWindow", prev, settings, browser, rect
self.cur_foldersettings = settings
self.browser = browser
self._CreateMainWindow(prev, settings, browser, rect)
self._CreateChildWindow(prev)
# This isn't part of the sample, but the most convenient place to
# test/demonstrate how you can get an IShellBrowser from a HWND
# (but ONLY when you are in the same process as the IShellBrowser!)
# Obviously it is not necessary here - we already have the browser!
browser_ad = win32gui.SendMessage(self.hwnd_parent, win32con.WM_USER+7, 0, 0)
browser_ob = pythoncom.ObjectFromAddress(browser_ad, shell.IID_IShellBrowser)
assert browser==browser_ob
# and make a call on the object to prove it doesn't die :)
assert browser.QueryActiveShellView()==browser_ob.QueryActiveShellView()
def __init__(self,hwndparent):
styles = win32con.WS_CHILD \
| win32con.WS_VISIBLE \
| win32con.WS_CLIPSIBLINGS \
| win32con.WS_CLIPCHILDREN \
| commctrl.TBSTYLE_LIST \
| commctrl.TBSTYLE_FLAT \
| commctrl.TBSTYLE_TRANSPARENT \
| commctrl.CCS_TOP \
| commctrl.CCS_NODIVIDER \
| commctrl.CCS_NORESIZE \
| commctrl.CCS_NOPARENTALIGN
self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
0, 0, 100, 100,
hwndparent, 0, win32gui.dllhandle,
None)
win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
def CreateViewWindow(self, prev, settings, browser, rect):
print "FileSystemView.CreateViewWindow", prev, settings, browser, rect
self.cur_foldersettings = settings
self.browser = browser
self._CreateMainWindow(prev, settings, browser, rect)
self._CreateChildWindow(prev)
# This isn't part of the sample, but the most convenient place to
# test/demonstrate how you can get an IShellBrowser from a HWND
# (but ONLY when you are in the same process as the IShellBrowser!)
# Obviously it is not necessary here - we already have the browser!
browser_ad = win32gui.SendMessage(self.hwnd_parent, win32con.WM_USER+7, 0, 0)
browser_ob = pythoncom.ObjectFromAddress(browser_ad, shell.IID_IShellBrowser)
assert browser==browser_ob
# and make a call on the object to prove it doesn't die :)
assert browser.QueryActiveShellView()==browser_ob.QueryActiveShellView()
def _DoSize(self, cx, cy, repaint = 1):
# right-justify the textbox.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
# The button.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
list_y = b + 10
w = r - l
win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)
# The list control
win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
# The last column of the list control.
new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width)
def OnCommand(self, hwnd, msg, wparam, lparam):
id = win32api.LOWORD(wparam)
if id == IDC_BUTTON_SEARCH:
self.ClearListItems()
def fill_slowly(q, hwnd):
import time
for i in range(20):
q.put(("whatever", str(i+1), "Search result " + str(i) ))
win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
time.sleep(.25)
win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)
import threading
self.result_queue = Queue.Queue()
thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
thread.start()
elif id == IDC_BUTTON_DISPLAY:
print "Display button selected"
sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
print "The selected item is", sel+1
# These function differ based on how the window is used, so may be overridden
def __init__(self,hwndparent):
styles = win32con.WS_CHILD \
| win32con.WS_VISIBLE \
| win32con.WS_CLIPSIBLINGS \
| win32con.WS_CLIPCHILDREN \
| commctrl.TBSTYLE_LIST \
| commctrl.TBSTYLE_FLAT \
| commctrl.TBSTYLE_TRANSPARENT \
| commctrl.CCS_TOP \
| commctrl.CCS_NODIVIDER \
| commctrl.CCS_NORESIZE \
| commctrl.CCS_NOPARENTALIGN
self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
0, 0, 100, 100,
hwndparent, 0, win32gui.dllhandle,
None)
win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
def CreateViewWindow(self, prev, settings, browser, rect):
print("FileSystemView.CreateViewWindow", prev, settings, browser, rect)
self.cur_foldersettings = settings
self.browser = browser
self._CreateMainWindow(prev, settings, browser, rect)
self._CreateChildWindow(prev)
# This isn't part of the sample, but the most convenient place to
# test/demonstrate how you can get an IShellBrowser from a HWND
# (but ONLY when you are in the same process as the IShellBrowser!)
# Obviously it is not necessary here - we already have the browser!
browser_ad = win32gui.SendMessage(self.hwnd_parent, win32con.WM_USER+7, 0, 0)
browser_ob = pythoncom.ObjectFromAddress(browser_ad, shell.IID_IShellBrowser)
assert browser==browser_ob
# and make a call on the object to prove it doesn't die :)
assert browser.QueryActiveShellView()==browser_ob.QueryActiveShellView()
def _DoSize(self, cx, cy, repaint = 1):
# right-justify the textbox.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
# The button.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
list_y = b + 10
w = r - l
win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)
# The list control
win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
# The last column of the list control.
new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width)
def OnCommand(self, hwnd, msg, wparam, lparam):
id = win32api.LOWORD(wparam)
if id == IDC_BUTTON_SEARCH:
self.ClearListItems()
def fill_slowly(q, hwnd):
import time
for i in range(20):
q.put(("whatever", str(i+1), "Search result " + str(i) ))
win32gui.PostMessage(hwnd, WM_SEARCH_RESULT, 0, 0)
time.sleep(.25)
win32gui.PostMessage(hwnd, WM_SEARCH_FINISHED, 0, 0)
import threading
self.result_queue = queue.Queue()
thread = threading.Thread(target = fill_slowly, args=(self.result_queue, self.hwnd) )
thread.start()
elif id == IDC_BUTTON_DISPLAY:
print("Display button selected")
sel = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
print("The selected item is", sel+1)
# These function differ based on how the window is used, so may be overridden
def __init__(self,hwndparent):
styles = win32con.WS_CHILD \
| win32con.WS_VISIBLE \
| win32con.WS_CLIPSIBLINGS \
| win32con.WS_CLIPCHILDREN \
| commctrl.TBSTYLE_LIST \
| commctrl.TBSTYLE_FLAT \
| commctrl.TBSTYLE_TRANSPARENT \
| commctrl.CCS_TOP \
| commctrl.CCS_NODIVIDER \
| commctrl.CCS_NORESIZE \
| commctrl.CCS_NOPARENTALIGN
self.hwnd = win32gui.CreateWindow('ToolbarWindow32', None, styles,
0, 0, 100, 100,
hwndparent, 0, win32gui.dllhandle,
None)
win32gui.SendMessage(self.hwnd, commctrl.TB_BUTTONSTRUCTSIZE, 20, 0)
def foreach_child(self):
def callback(hwnd, window_hwnd):
classname = win32gui.GetClassName(hwnd).lower()
buffer_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
text = array('b', b'\x00\x00' * buffer_len)
text_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, buffer_len, text)
text = win32gui.PyGetString(text.buffer_info()[0], buffer_len - 1).lower()
for match in self._windows[window_hwnd]['matches']:
if match["text"] in text:
self._windows[window_hwnd]['to_click'].append(match["button"])
if "button" in classname:
self._windows[window_hwnd]['buttons'].append({
'text': text,
'handle': hwnd,
})
return True
return callback
def doubleClickStatic(hwnd):
"""Simulates a double mouse click on a static
Parameters
----------
hwnd
Window handle of the required static.
Usage example: TODO
"""
_sendNotifyMessage(hwnd, win32con.STN_DBLCLK)
# def getEditText(hwnd):
# bufLen = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
# print(bufLen)
# buffer = win32gui.PyMakeBuffer(bufLen)
# win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, bufLen, buffer)
#
# text = buffer[:bufLen]
# return text
def sell(self, stock_code, price, amount, **kwargs):
"""
????
:param stock_code: ????
:param price: ????
:param amount: ????
:return: bool ????????
"""
amount = str(amount // 100 * 100)
price = str(price)
try:
win32gui.SendMessage(self.sell_stock_code_hwnd, win32con.WM_SETTEXT, None, stock_code) # ??????
win32gui.SendMessage(self.sell_price_hwnd, win32con.WM_SETTEXT, None, price) # ??????
win32gui.SendMessage(self.sell_price_hwnd, win32con.BM_CLICK, None, None) # ??????
time.sleep(0.2)
win32gui.SendMessage(self.sell_amount_hwnd, win32con.WM_SETTEXT, None, amount) # ??????
time.sleep(0.2)
win32gui.SendMessage(self.sell_btn_hwnd, win32con.BM_CLICK, None, None) # ????
time.sleep(0.3)
except:
traceback.print_exc()
return False
return True
def cancel_entrust(self, stock_code, direction):
"""
??
:param stock_code: str ????
:param direction: str 'buy' ??? 'sell' ??
:return: bool ????????
"""
direction = 0 if direction == 'buy' else 1
try:
win32gui.SendMessage(self.refresh_entrust_hwnd, win32con.BM_CLICK, None, None) # ????
time.sleep(0.2)
win32gui.SendMessage(self.cancel_stock_code_hwnd, win32con.WM_SETTEXT, None, stock_code) # ????
win32gui.SendMessage(self.cancel_query_hwnd, win32con.BM_CLICK, None, None) # ????
time.sleep(0.2)
if direction == 0:
win32gui.SendMessage(self.cancel_buy_hwnd, win32con.BM_CLICK, None, None) # ??
elif direction == 1:
win32gui.SendMessage(self.cancel_sell_hwnd, win32con.BM_CLICK, None, None) # ??
except:
traceback.print_exc()
return False
time.sleep(0.3)
return True
winGuiAuto_bak.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 30
收藏 0
点赞 0
评论 0
def selectComboboxItem(hwnd, item):
'''Selects a specified item in a Combo box control.
Arguments:
hwnd Window handle of the required combo box.
item The reqired item. Either an index, of the text of the
required item.
Usage example: fontComboItems = getComboboxItems(fontCombo)
selectComboboxItem(fontCombo,
random.choice(fontComboItems))
'''
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getComboboxItems(hwnd)
itemIndex = items.index(item)
selectComboboxItem(hwnd, itemIndex)
winGuiAuto_bak.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def selectListboxItem(hwnd, item):
'''Selects a specified item in a list box control.
Arguments:
hwnd Window handle of the required list box.
item The reqired item. Either an index, of the text of the
required item.
Usage example: TODO
'''
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
_sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getListboxItems(hwnd)
itemIndex = items.index(item)
selectListboxItem(hwnd, itemIndex)
winGuiAuto.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def selectComboboxItem(hwnd, item):
'''Selects a specified item in a Combo box control.
Arguments:
hwnd Window handle of the required combo box.
item The reqired item. Either an index, of the text of the
required item.
Usage example: fontComboItems = getComboboxItems(fontCombo)
selectComboboxItem(fontCombo,
random.choice(fontComboItems))
'''
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getComboboxItems(hwnd)
itemIndex = items.index(item)
selectComboboxItem(hwnd, itemIndex)
winGuiAuto.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def selectListboxItem(hwnd, item):
'''Selects a specified item in a list box control.
Arguments:
hwnd Window handle of the required list box.
item The reqired item. Either an index, of the text of the
required item.
Usage example: TODO
'''
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
_sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getListboxItems(hwnd)
itemIndex = items.index(item)
selectListboxItem(hwnd, itemIndex)
TestGui_Pro.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def Bar_code(DoingFlag=True,timesleep='2'):
print 'DoingFlag:',DoingFlag
print "Bar_code"
clsname ="?"
time.sleep(string.atoi(timesleep)*2)
lresults = findTopWindows(clsname)
while True:
lbutton= findControls(lresults[0],wantedText="?",wantedClass="Button")
str_a =controls.win32_controls.ButtonWrapper(lbutton[0]).GetProperties()['IsEnabled']
if str_a == True:
clickButton(lbutton[0])
time.sleep(string.atoi(timesleep)*2)
clsname1 ="ONUtest"
lresults1 = findTopWindows(clsname1)
if len(lresults1)>0:
lbutton1= findControls(lresults1[0],wantedClass="Button")
clickButton(lbutton1[0])
if DoingFlag ==False:
time.sleep(string.atoi(timesleep)*3)
break
time.sleep(string.atoi(timesleep)*3)
win32gui.SendMessage(lresults[0],win32con.WM_CLOSE,0,0)
return True
def selectComboboxItemThird(hwnd, item):
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.CB_SHOWDROPDOWN, 1, 0)
win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
win32gui.SendMessage(hwnd, win32con.WM_SETFOCUS, 0, 0 )
time.sleep(1)
tmp=win32gui.GetWindowRect(hwnd)
#print 'selectComboboxItemThird',tmp
'''
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0]+1, tmp[1]+1)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0]+1, tmp[1]+1)
'''
win32gui.SendMessage(hwnd, win32con.WM_KEYDOWN, 13, 0 )
time.sleep(0.1)
win32gui.SendMessage(hwnd, win32con.WM_KEYUP, 13, 0 )
time.sleep(0.1)
#_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getComboboxItems(hwnd)
itemIndex = items.index(item)
selectComboboxItem(hwnd, itemIndex)
def selectListboxItem(hwnd, item):
'''Selects a specified item in a list box control.
Arguments:
hwnd Window handle of the required list box.
item The reqired item. Either an index, of the text of the
required item.
Usage example: TODO
'''
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.LB_SETCURSEL, item, 0)
_sendNotifyMessage(hwnd, win32con.LBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getListboxItems(hwnd)
itemIndex = items.index(item)
selectListboxItem(hwnd, itemIndex)
def GetChildapp(self,str_app):
print '******** GetChildapp fuction ********'
hwnd = win32gui.FindWindow(None, str_app)
if hwnd < 1:
hwnd = self.find_main_window(str_app)
if hwnd>1:
hChild = win32gui.GetWindow(hwnd,win32con.GW_CHILD)
bufLen=1024
buf =win32gui.PyMakeBuffer(bufLen)
totalnum = 1
while hChild :
hChild = win32gui.GetWindow(hChild,win32con.GW_HWNDNEXT)
n = win32gui.SendMessage(hChild,win32con.WM_GETTEXT,bufLen,buf)
str = buf[:n]
print '@@@@@@@@@@@'
print win32gui.GetWindowText(hChild)
print str
'''
if totalnum ==3:
win32gui.SendMessage(hChild,win32con.WM_SETTEXT,None,'Realtek 10/100/1000 Ethernet NIC')
'''
print totalnum,hChild
totalnum = totalnum + 1
print '******** GetChildapp fuction ********',totalnum
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
desktop = win32gui.GetDesktopWindow()
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)/2, (dt_b-dt_t)/2) )
bmCtrl = win32gui.GetDlgItem(self.hwnd, IDC_BITMAP)
win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE, win32con.IMAGE_BITMAP, self.hSplash)
win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOPMOST,
centre_x-(self.bmWidth/2), centre_y-(self.bmHeight/2),
self.bmWidth, self.bmHeight, win32con.SWP_HIDEWINDOW)
win32gui.SetForegroundWindow(self.hwnd)
def File_name():
try:
win32gui.SendMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???'),None,'Edit',None),win32con.WM_SETTEXT,0,'????'+str(int(time.strftime("%Y%m%d")))+'.EBK')
time.sleep(1)
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#??
def Ctrl_T():
try:
win32api.keybd_event(17,0,0,0)#ctrl????17
win32api.keybd_event(84,0,0,0)#t????84
win32api.keybd_event(84,0,win32con.KEYEVENTF_KEYUP,0)#????
win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
time.sleep(3)
#win32gui.SendMessage(Tab_handle,0x130C,1,0)#????????????????
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#???????
def BrowseCallbackProc(hwnd, msg, lp, data):
if msg== shellcon.BFFM_INITIALIZED:
win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
elif msg == shellcon.BFFM_SELCHANGED:
# Set the status text of the
# For this message, 'lp' is the address of the PIDL.
pidl = shell.AddressAsPIDL(lp)
try:
path = shell.SHGetPathFromIDList(pidl)
win32gui.SendMessage(hwnd, shellcon.BFFM_SETSTATUSTEXT, 0, path)
except shell.error:
# No path for this PIDL
pass
def Refresh(self):
stateMask = commctrl.LVIS_SELECTED | commctrl.LVIS_DROPHILITED
state = 0
self.children = []
# Enumerate and store the child PIDLs
for cid in self.folder.EnumObjects(self.hwnd, 0):
self.children.append(cid)
for row_index, data in enumerate(self.children):
assert len(data)==1, "expecting just a child PIDL"
typ, path = data[0].split('\0')
desc = os.path.exists(path) and "Yes" or "No"
prop_vals = (path, desc)
# first col
data, extras = win32gui_struct.PackLVITEM(
item=row_index,
subItem=0,
text=prop_vals[0],
state=state,
stateMask=stateMask)
win32gui.SendMessage(self.hwnd_child,
commctrl.LVM_INSERTITEM,
row_index, data)
# rest of the cols.
col_index = 1
for prop_val in prop_vals[1:]:
data, extras = win32gui_struct.PackLVITEM(
item=row_index,
subItem=col_index,
text=prop_val)
win32gui.SendMessage(self.hwnd_child,
commctrl.LVM_SETITEM,
0, data)
col_index += 1