python api post开发实例-Python win32api.PostMessage方法代码示例

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-22 23:40   39   0

本文整理汇总了Python中win32api.PostMessage方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.PostMessage方法的具体用法?Python win32api.PostMessage怎么用?Python win32api.PostMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块win32api的用法示例。

在下文中一共展示了win32api.PostMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: Run

点赞 4

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def Run(self):

while 1:

handles = [self.stopEvent, self.adminEvent]

if self.watchEvent is not None:

handles.append(self.watchEvent)

rc = win32event.WaitForMultipleObjects(handles, 0, win32event.INFINITE)

if rc == win32event.WAIT_OBJECT_0:

break

elif rc == win32event.WAIT_OBJECT_0+1:

self.RefreshEvent()

else:

win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0)

try:

# If the directory has been removed underneath us, we get this error.

win32api.FindNextChangeNotification(self.watchEvent)

except win32api.error as exc:

print("Can not watch file", self.doc.GetPathName(), "for changes -", exc.strerror)

break

# close a circular reference

self.doc = None

if self.watchEvent:

win32api.FindCloseChangeNotification(self.watchEvent)

开发者ID:jasonrbr,项目名称:CodeReader,代码行数:25,

示例2: Run

点赞 3

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def Run(self):

while 1:

handles = [self.stopEvent, self.adminEvent]

if self.watchEvent is not None:

handles.append(self.watchEvent)

rc = win32event.WaitForMultipleObjects(handles, 0, win32event.INFINITE)

if rc == win32event.WAIT_OBJECT_0:

break

elif rc == win32event.WAIT_OBJECT_0+1:

self.RefreshEvent()

else:

win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0)

try:

# If the directory has been removed underneath us, we get this error.

win32api.FindNextChangeNotification(self.watchEvent)

except win32api.error, exc:

print "Can not watch file", self.doc.GetPathName(), "for changes -", exc.strerror

break

# close a circular reference

self.doc = None

if self.watchEvent:

win32api.FindCloseChangeNotification(self.watchEvent)

开发者ID:htwenning,项目名称:remoteControlPPT,代码行数:25,

示例3: move

点赞 3

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def move(self,coords, button=None):

if all(isinstance(elem, float) for elem in coords):

coords = self.to_pixel(coords)

if button == None:

_button_state = 0

elif "right" in button.lower():

_button_state = win32con.MK_RBUTTON

elif "left" in button.lower():

_button_state = win32con.MK_LBUTTON

elif "middle" in button.lower():

_button_state = win32con.MK_MBUTTON

else:

raise SyntaxError(""Button" needs to contain "left", "right" or "middle"")

l_param = win32api.MAKELONG(coords[0], coords[1])

win32api.PostMessage(self.win_handler.get_hwnd(), win32con.WM_MOUSEMOVE, _button_state, l_param)

开发者ID:N0K0,项目名称:pytomatic,代码行数:20,

示例4: __init__

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def __init__(self, reactor):

def stopThreads():

for t in self.threadToMsgWindow.keys():

# PostMessage blocks for dead threads

if t.isAlive() and self.threadToMsgWindowCreated[t]:

win32api.PostMessage(

self.threadToMsgWindow[t], # thread id

WM_CLOSE_THREAD, # message

0, # wParam

0 # lParam

)

reactor.addSystemEventTrigger("before", "shutdown", stopThreads)

开发者ID:adde88,项目名称:hostapd-mana,代码行数:14,

示例5: notifyOnExit

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def notifyOnExit(self, processHandle, processTransport):

processHandleKey = self.phandleToPhandleKey[processHandle]

# If there are available threads, use one of them

if len(self.availableThreads) > 0:

wfmoThread = self.availableThreads[0]

self.threadToNumProcessHandles[wfmoThread] += 1

self.phandleKeyToThreadHandle[processHandleKey] = wfmoThread

# Update used/available thread lists

if self.threadToNumProcessHandles[wfmoThread] == 63:

self.usedThreads.append(wfmoThread)

self.availableThreads.remove(wfmoThread)

# Make sure the message window has been created so

# we can send messages to the thread.

if self.threadToMsgWindowCreated[wfmoThread] is False:

val = WaitForSingleObject(self.threadToMsgWindowCreationEvent[wfmoThread], INFINITE)

if val != WAIT_OBJECT_0:

raise RuntimeError("WaitForSingleObject returned %d. It should only return %d" % (val, WAIT_OBJECT_0))

# Notify the thread that it should wait on the process handle.

if win32api.PostMessage(

self.threadToMsgWindow[wfmoThread],

WM_NEW_PHANDLE, # message

processHandleKey, # wParam

0 # lParam

) == 0:

raise Exception("Failed to post thread message!")

else:

# Create a new thread and wait on the proc handle

wfmoThread = threading.Thread(

target=self.doWaitForProcessExit,

args=(processHandleKey,),

name="iocpreactor.process_waiter.ProcessWaiter.waitForProcessExit pid=%d" % self.realPid)

# Create a window creation event that will be triggered from the thread

self.threadToMsgWindowCreationEvent[wfmoThread] = CreateEvent(None, 0, 0, None)

self.threadToMsgWindowCreated[wfmoThread] = False

self.threadToNumProcessHandles[wfmoThread] = 1

self.availableThreads.append(wfmoThread)

self.phandleKeyToThreadHandle[processHandleKey] = wfmoThread

wfmoThread.start()

开发者ID:adde88,项目名称:hostapd-mana,代码行数:41,

示例6: processEnded

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def processEnded(self, processHandle, processHandleKey):

wfmoThread = self.phandleKeyToThreadHandle[processHandleKey]

processTransport = self.phandleToTransport[processHandle]

self.threadToNumEnded[wfmoThread] += 1

# Decrement proc handle count for thread

self.threadToNumProcessHandles[wfmoThread] -= 1

# If we go from 63 to 62 phandles for the thread, mark it available.

if self.threadToNumProcessHandles[wfmoThread] == 62:

self.availableThreads.append(wfmoThread)

self.usedThreads.remove(wfmoThread)

# If we go to 0 phandles, end the thread

elif self.threadToNumProcessHandles[wfmoThread] == 0:

# Mark thread as unavailable

self.availableThreads.remove(wfmoThread)

# Notify the thread that it should exit.

if not self.threadToMsgWindowCreated[wfmoThread]:

val = WaitForSingleObject(self.threadToMsgWindowCreationEvent[wfmoThread], INFINITE)

if val != WAIT_OBJECT_0:

raise RuntimeError("WaitForSingleObject returned %d. It should only return %d" % (val, WAIT_OBJECT_0))

# Notify the thread that it should wait on the process handle.

win32api.PostMessage(

self.threadToMsgWindow[wfmoThread], # thread id

WM_CLOSE_THREAD, # message

0, # wParam

0 # lParam

)

# Cleanup thread resources

del self.threadToNumProcessHandles[wfmoThread]

del self.threadToMsgWindowCreated[wfmoThread]

#del self.wfmoThread

# Cleanup process handle resources

del self.needWaiting[processHandleKey]

del self.phandleToTransport[processHandle]

# Call the transport"s processEnded method

processTransport.processEnded()

开发者ID:adde88,项目名称:hostapd-mana,代码行数:39,

示例7: NotifyAutoxdShow

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def NotifyAutoxdShow(self, code):

return 0

#????

hwnd = LiveData().getFrameHwnd()

code = int(code)

#lparam????????, wparam???0???

try:

win32api.PostMessage(hwnd,0x400+101,code,6-len(str(code)))

except:

pass

开发者ID:nessessary,项目名称:autoxd,代码行数:12,

示例8: OnTaskbarNotify

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def OnTaskbarNotify(

self,

hwnd,

msg,

wparam,

lparam,

):

if lparam == win32con.WM_LBUTTONUP:

pass

elif lparam == win32con.WM_LBUTTONDBLCLK:

pass

elif lparam == win32con.WM_RBUTTONUP:

menu = win32gui.CreatePopupMenu()

win32gui.AppendMenu(menu, win32con.MF_STRING, 1023,

"Toggle Display")

win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, "")

if self.serverState == self.EnumServerState.STOPPED:

win32gui.AppendMenu(menu, win32con.MF_STRING, 1024,

"Start Server")

win32gui.AppendMenu(menu, win32con.MF_STRING

| win32con.MF_GRAYED, 1025,

"Restart Server")

win32gui.AppendMenu(menu, win32con.MF_STRING

| win32con.MF_GRAYED, 1026,

"Stop Server")

else:

win32gui.AppendMenu(menu, win32con.MF_STRING

| win32con.MF_GRAYED, 1024,

"Start Server")

win32gui.AppendMenu(menu, win32con.MF_STRING, 1025,

"Restart Server")

win32gui.AppendMenu(menu, win32con.MF_STRING, 1026,

"Stop Server")

win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, "")

win32gui.AppendMenu(menu, win32con.MF_STRING, 1027,

"Quit (pid:%i)" % os.getpid())

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,

)

win32api.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)

return 1

开发者ID:StuffShare,项目名称:StuffShare,代码行数:54,

示例9: _get_handles

点赞 2

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import PostMessage [as 别名]

def _get_handles(self):

trade_main_hwnd = win32gui.FindWindow(0, self.Title) # ????

operate_frame_hwnd = win32gui.GetDlgItem(trade_main_hwnd, 59648) # ??????

operate_frame_afx_hwnd = win32gui.GetDlgItem(operate_frame_hwnd, 59648) # ??????

hexin_hwnd = win32gui.GetDlgItem(operate_frame_afx_hwnd, 129)

scroll_hwnd = win32gui.GetDlgItem(hexin_hwnd, 200) # ????????

tree_view_hwnd = win32gui.GetDlgItem(scroll_hwnd, 129) # ????????

# ????????????

win32api.PostMessage(tree_view_hwnd, win32con.WM_KEYDOWN, win32con.VK_F1, 0)

time.sleep(0.5)

# ????

entrust_window_hwnd = win32gui.GetDlgItem(operate_frame_hwnd, 59649) # ??????

self.buy_stock_code_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 1032) # ???????

self.buy_price_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 1033) # ???????

self.buy_amount_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 1034) # ???????

self.buy_btn_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 1006) # ??????

self.refresh_entrust_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 32790) # ??????

entrust_frame_hwnd = win32gui.GetDlgItem(entrust_window_hwnd, 1047) # ??????

entrust_sub_frame_hwnd = win32gui.GetDlgItem(entrust_frame_hwnd, 200) # ??????

self.position_list_hwnd = win32gui.GetDlgItem(entrust_sub_frame_hwnd, 1047) # ????

win32api.PostMessage(tree_view_hwnd, win32con.WM_KEYDOWN, win32con.VK_F2, 0)

time.sleep(0.5)

# ????

sell_entrust_frame_hwnd = win32gui.GetDlgItem(operate_frame_hwnd, 59649) # ??????

self.sell_stock_code_hwnd = win32gui.GetDlgItem(sell_entrust_frame_hwnd, 1032) # ???????

self.sell_price_hwnd = win32gui.GetDlgItem(sell_entrust_frame_hwnd, 1033) # ???????

self.sell_amount_hwnd = win32gui.GetDlgItem(sell_entrust_frame_hwnd, 1034) # ???????

self.sell_btn_hwnd = win32gui.GetDlgItem(sell_entrust_frame_hwnd, 1006) # ??????

# ????

win32api.PostMessage(tree_view_hwnd, win32con.WM_KEYDOWN, win32con.VK_F3, 0)

time.sleep(0.5)

cancel_entrust_window_hwnd = win32gui.GetDlgItem(operate_frame_hwnd, 59649) # ??????

self.cancel_stock_code_hwnd = win32gui.GetDlgItem(cancel_entrust_window_hwnd, 3348) # ???????

self.cancel_query_hwnd = win32gui.GetDlgItem(cancel_entrust_window_hwnd, 3349) # ??????

self.cancel_buy_hwnd = win32gui.GetDlgItem(cancel_entrust_window_hwnd, 30002) # ??

self.cancel_sell_hwnd = win32gui.GetDlgItem(cancel_entrust_window_hwnd, 30003) # ??

chexin_hwnd = win32gui.GetDlgItem(cancel_entrust_window_hwnd, 1047)

chexin_sub_hwnd = win32gui.GetDlgItem(chexin_hwnd, 200)

self.entrust_list_hwnd = win32gui.GetDlgItem(chexin_sub_hwnd, 1047) # ????

开发者ID:yuzhucu,项目名称:easytrader,代码行数:46,

注:本文中的win32api.PostMessage方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP