【发布时间】:2014-02-05 19:26:38
【问题描述】:
我正在尝试单击桌面上的某个位置,我正在使用带有 win32 api 的 python,我正在使用 python 32 位但我的计算机是 64 位计算机。我相信 lParam 变量没有保持我期望的值,而且我仍然对这个变量本身有点困惑,假设我从 wintypes 导入它,谁能告诉我如何使用它?为什么我下面的功能不起作用?
我有一个功能如下,这似乎不起作用:
def clickDesktop(x=0, y=0):
# Get handle to desktop window
desktop = win32gui.GetDesktopWindow()
# Create variable lParam that contains the x-coordinate in the low-order word while
# the high-order word contains the y coordinate.
lParam = y << 16 | x
# Click at x, y in the desktop window
win32gui.PostMessage(desktop, win32con.WM_LBUTTONDOWN, MK_LBUTTON, lParam)
win32gui.PostMessage(desktop, win32con.WM_LBUTTONUP, 0, lParam)
【问题讨论】:
-
您应该使用 SendInput Win32 API。
-
你想点击的地方会显示什么?
-
使用 ctypes 调用 SendInput。例如,请参阅 stackoverflow.com/questions/19288656/… 以获取伪造键盘。
-
这也不起作用,我没有看到任何事情发生..
-
你想点击的地方会显示什么?
标签: python winapi click desktop lparam