Python win32api_python api文档

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

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

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

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

示例1: sample_one_person

​点赞 6

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

# 或者: from win32api import SetCursorPos [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

开发者ID:BlueWinters,项目名称:DeepWarp,代码行数:37,

示例2: tap

​点赞 6

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

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

def tap(self, x, y):

if self.run_time.stop:

return

x, y = int(x), int(y)

self.root.debug(“Tapping at location ({},{})”.format(x, y))

if self._debug:

# Helper to debug taps

input(“waiting for confirmation press enter”)

ox, oy = win32api.GetCursorPos()

curr_window = win32gui.GetForegroundWindow()

win32gui.ShowWindow(self.win_handle, win32con.SW_RESTORE)

x, y = int(x), int(y)

cx, cy = win32gui.ClientToScreen(self.win_handle, (x, y))

x, y = self.__calculate_absolute_coordinates__(cx, cy)

win32api.mouse_event(win32con.MOUSEEVENTF_MOVE | win32con.MOUSEEVENTF_ABSOLUTE,

x, y, 0, 0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

time.sleep(20 / 1000)

win32api.SetCursorPos((ox, oy))

win32gui.SetActiveWindow(curr_window)

开发者ID:will7200,项目名称:Yugioh-bot,代码行数:23,

示例3: touch

​点赞 5

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

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

def touch(self, x, y, duration=0.1):

”’ Simulate touch ”’

(ox, oy) = self.mouseposition() # remember mouse position

x, y = self._resetpt(x, y)

win32api.SetCursorPos((x,y))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)

time.sleep(duration)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)

win32api.SetCursorPos((ox,oy)) # move back mouse position

开发者ID:NetEase,项目名称:airtest,代码行数:12,

示例4: clickMenuButton

​点赞 5

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

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

def clickMenuButton(hwnd, offset):

left, top, right, bottom = win32gui.GetWindowRect(hwnd)

win32api.SetCursorPos([left + offset, (bottom – top) // 2 + top])

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

time.sleep(0.1)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

time.sleep(0.3)

开发者ID:ynzheng,项目名称:pyautotrade_tdx,代码行数:9,

示例5: autoRelease

​点赞 5

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

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

def autoRelease(result,game_x,game_y):

for i in range(0,len(result)):

for j in range(0,len(result[0])):

# 以上两个for循环,定位第一个选中点

if result[i][j] != 0:

for m in range(0,len(result)):

for n in range(0,len(result[0])):

if result[m][n] != 0:

# 后两个for循环定位第二个选中点

if matching.canConnect(i,j,m,n,result):

# 执行消除算法并返回

result[i][j] = 0

result[m][n] = 0

print(‘可消除点:’+ str(i+1) + ‘,’ + str(j+1) + ‘和’ + str(m+1) + ‘,’ + str(n+1))

x1 = game_x + j*SQUARE_WIDTH

y1 = game_y + i*SQUARE_HEIGHT

x2 = game_x + n*SQUARE_WIDTH

y2 = game_y + m*SQUARE_HEIGHT

win32api.SetCursorPos((x1 + 15,y1 + 18))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x1+15, y1+18, 0, 0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x1+15, y1+18, 0, 0)

time.sleep(TIME_INTERVAL)

win32api.SetCursorPos((x2 + 15, y2 + 18))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x2 + 15, y2 + 18, 0, 0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x2 + 15, y2 + 18, 0, 0)

time.sleep(TIME_INTERVAL)

return True

return False

开发者ID:TheThreeDog,项目名称:Auto-Lianliankan,代码行数:31,

示例6: _input_left_mouse

​点赞 5

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

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

def _input_left_mouse(self, x, y):

left, top, right, bottom = self.rect

width, height = right – left, bottom – top

if x < 0 or x > width or y < 0 or y > height:

return

win32gui.SetForegroundWindow(self.hwnd)

pos = win32gui.GetCursorPos()

win32api.SetCursorPos((left+x, top+y))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)

win32api.Sleep(100) #ms

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)

win32api.Sleep(100) #ms

# win32api.SetCursorPos(pos)

开发者ID:NetEaseGame,项目名称:ATX,代码行数:16,

示例7: mouse_move

​点赞 5

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

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

def mouse_move(self, pos, pos_end=None):

“””

模拟鼠标移动

:param pos: (x,y) 鼠标移动的坐标

:param pos_end=None: (x,y) 若pos_end不为空,则鼠标移动至以pos为左上角坐标pos_end为右下角坐标的区域内的随机位置

“””

pos2 = win32gui.ClientToScreen(self.hwnd, pos)

if pos_end == None:

win32api.SetCursorPos(pos2)

else:

pos_end2 = win32gui.ClientToScreen(self.hwnd, pos_end)

pos_rand = (random.randint(

pos2[0], pos_end2[0]), random.randint(pos2[1], pos_end2[1]))

win32api.SetCursorPos(pos_rand)

开发者ID:AcademicDog,项目名称:onmyoji_bot,代码行数:16,

示例8: clickWindow

​点赞 5

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

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

def clickWindow(hwnd, offset):

left, top, right, bottom = win32gui.GetWindowRect(hwnd)

# print(‘left, top, right, bottom’, left, top, right, bottom)

win32api.SetCursorPos([left + offset, (bottom – top) // 2 + top])

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

time.sleep(0.2)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

time.sleep(0.2)

开发者ID:drongh,项目名称:pyAutoTrading,代码行数:10,

示例9: click

​点赞 5

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

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

def click(x,y):

win32api.SetCursorPos((x,y))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

开发者ID:scholi,项目名称:pySPM,代码行数:6,

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/183107.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • SystemUI.apk等特殊APK文件的反编译和编译技巧[通俗易懂]

    SystemUI.apk等特殊APK文件的反编译和编译技巧[通俗易懂]SystemUI.apk等特殊APK文件的反编译和编译技巧   第一:要在你的PC上建立Java的环境,才能执行编译工作。具体方法我这个就不说了,你百度或者Google下就知道了,很简单的。   第二:下载必要的工具。Apktool工具。   下载后解压(有三个文件aapt.exe,apktool.bat,apktool.jar),为了方便。将解压出

    2026年1月18日
    3
  • Luajit 概述「建议收藏」

    Luajit 概述「建议收藏」一、JIT即时编译器JIT:即时编译器。将频繁执行的代码,通过JIT编译器编译成机器码缓存起来,下次再调用时直接执行机器码。相比与原生Lua的逐条执行虚拟机指令效率更高。对于那些只执行一次的代码,则保持于原生Lua一样,逐条执行。JIT带来的效率提升,并不一定能抵消编译效率的下降。当虚拟机执行指令时并不会立刻用JIT进行编译。只有部分指令需要JIT进行编译,JIT将决定那些代码将被编译。延迟编译有…

    2022年10月7日
    4
  • H5添加QQ好友的链接

    tencent://AddContact/?fromId=45&amp;fromSubId=1&amp;subcmd=all&amp;uin=你的QQ号&amp;website=www.oicqzone.com既点击有如下效果:

    2022年4月17日
    108
  • 2021python激活码【在线注册码/序列号/破解码】[通俗易懂]

    2021python激活码【在线注册码/序列号/破解码】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月18日
    56
  • 特征选择的几种方法[通俗易懂]

    目录1过滤法(Filter)1.1方差选择法1.2相关系数法1.3卡方检验1.4互信息法1.5relief算法2包裹法(Wrapper)2.1递归特征消除法2.2特征干扰法3嵌入法(Embedded)3.1基于惩罚项的特征选择法3.2基于树模型的特征选择法4特征选择方法的优…

    2022年4月8日
    56
  • vue父组件操作子组件的方法_vue父组件获取子组件数据

    vue父组件操作子组件的方法_vue父组件获取子组件数据父组件和子组件我们经常分不清什么是父组件,什么是子组件。现在来简单总结下:我们将某段代码封装成一个组件,而这个组件又在另一个组件中引入,而引入该封装的组件的文件叫做父组件,被引入的组件叫做子组件。具

    2022年7月29日
    10

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号