本文整理汇总了Python中win32gui.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.SendMessage方法的具体用法?Python win32gui.SendMessage怎么用?Python win32gui.SendMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnCommand
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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
示例2: CreateViewWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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()
示例3: _DoSize
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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)
示例4: sample_one_person
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def sample_one_person(n, num_x=5, num_y=5):
save_path = 'D:/UnityEyes_Windows/imgs'
if os.path.exists(save_path) == False:
os.mkdir(save_path)
# reset
win32gui.SendMessage(handle, win32con.WM_ACTIVATE, win32con.WA_ACTIVE, 0)
center_x = (clt_left + clt_right) // 2
center_y = (clt_top + clt_bottom) // 2
win32api.SetCursorPos([center_x, center_y])
# press 'L'
win32api.keybd_event(KEY_LIGHT, 0, 0, 0) # key down
time.sleep(1)
win32api.keybd_event(KEY_LIGHT, 0, win32con.KEYEVENTF_KEYUP, 0) # key up
# press 'R'
win32api.keybd_event(KEY_RANDOM, 0, 0, 0) # key down
time.sleep(1)
win32api.keybd_event(KEY_RANDOM, 0, win32con.KEYEVENTF_KEYUP, 0) # key up
# number of points for vertical and horizontal
# num_x, num_y = 5, 5
step_x, step_y = width // (num_x + 1), height // (num_y + 1)
for i in range(1, num_y+1):
for j in range(1, num_x+1):
x = clt_left + j * step_x
y = clt_top + i * step_y
print('{},{}'.format(x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)
win32api.SetCursorPos([x, y])
win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)
time.sleep(0.5)
win32api.keybd_event(KEY_SAVE, 0, 0, 0) # key down
win32api.keybd_event(KEY_SAVE, 0, win32con.KEYEVENTF_KEYUP, 0) # key up
示例5: doubleClickStatic
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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
示例6: foreach_child
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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
示例7: mouse_drag_bg
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def mouse_drag_bg(self, pos1, pos2):
"""
后台鼠标拖拽
:param pos1: (x,y) 起点坐标
:param pos2: (x,y) 终点坐标
"""
if self.client == 0:
move_x = np.linspace(pos1[0], pos2[0], num=20, endpoint=True)[0:]
move_y = np.linspace(pos1[1], pos2[1], num=20, endpoint=True)[0:]
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN,
0, win32api.MAKELONG(pos1[0], pos1[1]))
for i in range(20):
x = int(round(move_x[i]))
y = int(round(move_y[i]))
win32gui.SendMessage(
self.hwnd, win32con.WM_MOUSEMOVE, 0, win32api.MAKELONG(x, y))
time.sleep(0.01)
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONUP,
0, win32api.MAKELONG(pos2[0], pos2[1]))
else:
command = str(pos1[0])+' ' + str(pos1[1]) + \
' '+str(pos2[0])+' '+str(pos2[1])
os.system('adb shell input swipe '+command)
示例8: quit_game
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def quit_game(self):
"""
退出游戏
"""
self.takescreenshot() # 保存一下现场
self.clean_mem() # 清理内存
if not self.run:
return False
if self.quit_game_enable:
if self.client == 0:
win32gui.SendMessage(
self.hwnd, win32con.WM_DESTROY, 0, 0) # 退出游戏
else:
os.system(
'adb shell am force-stop com.netease.onmyoji.netease_simulator')
logging.info('退出,最后显示已保存至/img/screenshots文件夹')
sys.exit(0)
示例9: doubleClickStatic
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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
示例10: Refresh
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
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
示例11: _SendSci
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def _SendSci(self, msg, wparam=0, lparam=0):
return win32gui.SendMessage(self.hwnd, msg, wparam, lparam)
# IShellView
示例12: _SetupList
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def _SetupList(self):
child_style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | win32con.WS_HSCROLL | win32con.WS_VSCROLL
child_style |= commctrl.LVS_SINGLESEL | commctrl.LVS_SHOWSELALWAYS | commctrl.LVS_REPORT
self.hwndList = win32gui.CreateWindow("SysListView32", None, child_style, 0, 0, 100, 100, self.hwnd, IDC_LISTBOX, self.hinst, None)
child_ex_style = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
child_ex_style |= commctrl.LVS_EX_FULLROWSELECT
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, child_ex_style)
# Add an image list - use the builtin shell folder icon - this
# demonstrates the problem with alpha-blending of icons on XP if
# winxpgui is not used in place of win32gui.
il = win32gui.ImageList_Create(
win32api.GetSystemMetrics(win32con.SM_CXSMICON),
win32api.GetSystemMetrics(win32con.SM_CYSMICON),
commctrl.ILC_COLOR32 | commctrl.ILC_MASK,
1, # initial size
0) # cGrow
shell_dll = os.path.join(win32api.GetSystemDirectory(), "shell32.dll")
large, small = win32gui.ExtractIconEx(shell_dll, 4, 1)
win32gui.ImageList_ReplaceIcon(il, -1, small[0])
win32gui.DestroyIcon(small[0])
win32gui.DestroyIcon(large[0])
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETIMAGELIST,
commctrl.LVSIL_SMALL, il)
# Setup the list control columns.
lvc = LVCOLUMN(mask = commctrl.LVCF_FMT | commctrl.LVCF_WIDTH | commctrl.LVCF_TEXT | commctrl.LVCF_SUBITEM)
lvc.fmt = commctrl.LVCFMT_LEFT
lvc.iSubItem = 1
lvc.text = "Title"
lvc.cx = 200
win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
lvc.iSubItem = 0
lvc.text = "Order"
lvc.cx = 50
win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
win32gui.UpdateWindow(self.hwnd)
示例13: ClearListItems
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def ClearListItems(self):
win32gui.SendMessage(self.hwndList, commctrl.LVM_DELETEALLITEMS)
self.list_data = {}
示例14: AddListItem
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def AddListItem(self, data, *columns):
num_items = win32gui.SendMessage(self.hwndList, commctrl.LVM_GETITEMCOUNT)
item = LVITEM(text=columns[0], iItem = num_items)
new_index = win32gui.SendMessage(self.hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam())
col_no = 1
for col in columns[1:]:
item = LVITEM(text=col, iItem = new_index, iSubItem = col_no)
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETITEM, 0, item.toparam())
col_no += 1
self.list_data[new_index] = data
示例15: AddButtons
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import SendMessage [as 别名]
def AddButtons(self,*buttons):
tbbuttons = ''
for button in buttons:
tbbuttons += button.toparam()
return win32gui.SendMessage(self.hwnd, commctrl.TB_ADDBUTTONS,
len(buttons), tbbuttons)