本文整理汇总了Python中win32gui.PostMessage方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.PostMessage方法的具体用法?Python win32gui.PostMessage怎么用?Python win32gui.PostMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.PostMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnCommand
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [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: click_drag
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def click_drag(x :int, y :int, x2 :int, y2 :int) -> None:
"""Click at pixel xy."""
x += Window.x
y += Window.y
x2 += Window.x
y2 += Window.y
lParam = win32api.MAKELONG(x, y)
lParam2 = win32api.MAKELONG(x2, y2)
# MOUSEMOVE event is required for game to register clicks correctly
win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam)
while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
win32api.GetKeyState(wcon.VK_MENU) < 0):
time.sleep(0.005)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
wcon.MK_LBUTTON, lParam)
time.sleep(userset.LONG_SLEEP * 2)
win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam2)
time.sleep(userset.SHORT_SLEEP)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
wcon.MK_LBUTTON, lParam2)
time.sleep(userset.MEDIUM_SLEEP)
示例3: ctrl_click
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def ctrl_click(x :int, y :int) -> None:
"""Clicks at pixel x, y while simulating the CTRL button to be down."""
x += Window.x
y += Window.y
lParam = win32api.MAKELONG(x, y)
while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
win32api.GetKeyState(wcon.VK_MENU) < 0):
time.sleep(0.005)
win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, wcon.VK_CONTROL, 0)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
wcon.MK_LBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
wcon.MK_LBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_KEYUP, wcon.VK_CONTROL, 0)
time.sleep(userset.MEDIUM_SLEEP)
示例4: OnTaskbarNotify
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
if lparam==win32con.WM_LBUTTONUP:
print "You clicked me."
elif lparam==win32con.WM_LBUTTONDBLCLK:
print "You double-clicked me - goodbye"
win32gui.DestroyWindow(self.hwnd)
elif lparam==win32con.WM_RBUTTONUP:
print "You right clicked me."
menu = win32gui.CreatePopupMenu()
win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
pos = win32gui.GetCursorPos()
# See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
win32gui.SetForegroundWindow(self.hwnd)
win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
return 1
示例5: enumChildCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumChildCallback(hwnd, windowName):
"""
Will get called by win32gui.EnumWindows, once for each
top level application window.
"""
try:
# Get window title
title = win32gui.GetWindowText(hwnd)
# Is this our guy?
if title.find(windowName) == -1:
return
# Send WM_CLOSE message
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except:
pass
#print sys.exc_info()
示例6: show_menu
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def show_menu(self):
"""Draw the popup menu."""
menu = win32gui.CreatePopupMenu()
self._create_menu(menu, self.menu_options)
pos = win32gui.GetCursorPos()
# See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
win32gui.SetForegroundWindow(self.hwnd)
win32gui.TrackPopupMenu(menu,
win32con.TPM_LEFTALIGN,
pos[0],
pos[1],
0,
self.hwnd,
None)
win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
self.logger.debug('Menu displayed.')
示例7: show_menu
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def show_menu(self):
menu = win32gui.CreatePopupMenu()
self.create_menu(menu, self.menu_options)
# win32gui.SetMenuDefaultItem(menu, 1000, 0)
pos = win32gui.GetCursorPos()
# See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
win32gui.SetForegroundWindow(self.hwnd)
win32gui.TrackPopupMenu(menu,
win32con.TPM_LEFTALIGN,
pos[0],
pos[1],
0,
self.hwnd,
None)
win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
示例8: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, self):
title = win32gui.GetWindowText(hwnd)
for name in self.WindowNames:
if title.find(name) > -1:
try:
self.FoundWindowEvent.set()
if self.CloseWindows:
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except:
pass
else:
try:
win32gui.EnumChildWindows(hwnd, _WindowWatcher.enumChildCallback, self)
except:
pass
return True
示例9: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, args):
"""
Will get called by win32gui.EnumWindows, once for each
top level application window.
"""
proc = args[0]
windowName = args[1]
try:
# Get window title
title = win32gui.GetWindowText(hwnd)
# Is this our guy?
if title.find(windowName) == -1:
win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, args)
return
# Send WM_CLOSE message
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except:
pass
示例10: enumChildCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumChildCallback(hwnd, args):
"""
Will get called by win32gui.EnumWindows, once for each
top level application window.
"""
proc = args[0]
windowName = args[1]
try:
# Get window title
title = win32gui.GetWindowText(hwnd)
# Is this our guy?
if title.find(windowName) == -1:
return
# Send WM_CLOSE message
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except:
pass
#print sys.exc_info()
示例11: enumCallback
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def enumCallback(hwnd, windowName):
"""
Will get called by win32gui.EnumWindows, once for each
top level application window.
"""
try:
# Get window title
title = win32gui.GetWindowText(hwnd)
# Is this our guy?
if title.find(windowName) == -1:
win32gui.EnumChildWindows(hwnd, FileWriterLauncherGui.enumChildCallback, windowName)
return
# Send WM_CLOSE message
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
except:
pass
示例12: _notify
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def _notify(klass, hwnd, msg, wparam, lparam):
self = klass._instance[hwnd]
if lparam == win32con.WM_LBUTTONDBLCLK:
menu = self.get_popup()
wid = win32gui.GetMenuDefaultItem(menu, 0, 0)
if 0 < wid:
win32gui.PostMessage(hwnd, win32con.WM_COMMAND, wid, 0)
elif lparam == win32con.WM_RBUTTONUP:
menu = self.get_popup()
pos = win32gui.GetCursorPos()
win32gui.SetForegroundWindow(hwnd)
win32gui.TrackPopupMenu(
menu, win32con.TPM_LEFTALIGN,
pos[0], pos[1], 0, hwnd, None)
win32gui.PostMessage(hwnd, win32con.WM_NULL, 0, 0)
elif lparam == win32con.WM_LBUTTONUP:
pass
return True
示例13: show_menu
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def show_menu(self):
menu = win32gui.CreatePopupMenu()
self.create_menu(menu, self.menu_options)
#win32gui.SetMenuDefaultItem(menu, 1000, 0)
pos = win32gui.GetCursorPos()
# See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
win32gui.SetForegroundWindow(self.hwnd)
win32gui.TrackPopupMenu(menu,
win32con.TPM_LEFTALIGN,
pos[0],
pos[1],
0,
self.hwnd,
None)
win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
示例14: _show_menu
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def _show_menu( self ):
menu = win32gui.CreatePopupMenu()
for action in self.menu_actions:
if action:
flags = win32con.MF_STRING
if not action.sensitive:
flags |= win32con.MF_GRAYED
win32gui.AppendMenu( menu, flags, action.get_id(), action.label )
else:
win32gui.AppendMenu( menu, win32con.MF_SEPARATOR, 0, '' )
pos = win32gui.GetCursorPos()
win32gui.SetForegroundWindow( self.window_handle )
win32gui.TrackPopupMenu( menu,
win32con.TPM_LEFTALIGN | win32con.TPM_BOTTOMALIGN,
pos[ 0 ],
pos[ 1 ],
0,
self.window_handle,
None )
win32gui.PostMessage( self.window_handle, win32con.WM_NULL, 0, 0 )
示例15: _win32gui_post
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import PostMessage [as 别名]
def _win32gui_post(message, w=0, l=0):
return lambda self: win32gui.PostMessage(self._handle, message, w, l)