How to use mouse_move method in Airtest

Best Python code snippet using Airtest

plane_main.py

Source:plane_main.py Github

copy

Full Screen

1from plane_sprites import *2from plane_music import *3import time4import plane_hero as hero5import plane_enemy as enemy6import plane_background as bg7import plane_bullet as bullet8import plane_explosion as explosion9class PlaneGame(object):10 """飞机大战主游戏"""11 def __init__(self):12 print("游戏初始化。。。")13 #1.开始菜单14 self.__start_menu()15 #2.创建游戏窗口16 self.screen = pygame.display.set_mode(SIZE,pygame.FULLSCREEN)17 #self.screen = pygame.display.set_mode((400,600))18 self.caption_icon = pygame.image.load("images/background/caption_icon.png").convert_alpha()19 pygame.display.set_caption("飞机大战")20 pygame.display.set_icon(self.caption_icon)#设置标题图片21 #3.创建游戏时钟22 self.clock = pygame.time.Clock()23 #4.调用私有方法,创建精灵和精灵组24 self.__creat_sprits()25 #5.设置当前帧,用于播放精灵动画26 self.current_frame = 027 #6.设置定时器事件___英雄发射子弹28 pygame.time.set_timer(HERO_FIRE_EVENT,200)29 """30 定义并实现私有方法,31 """32 #开始菜单33 def __start_menu(self):34 self.start_screen = pygame.display.set_mode(SIZE,pygame.FULLSCREEN)35 start_bg = pygame.image.load("images/background/start_bg.png").convert_alpha()36 button1 = pygame.image.load("images/button/button1.png").convert_alpha()37 button2 = pygame.image.load("images/button/button2.png").convert_alpha()38 button3 = pygame.image.load("images/button/button3.png").convert_alpha()39 button4 = pygame.image.load("images/button/button4.png").convert_alpha()40 button5 = pygame.image.load("images/button/button5.png").convert_alpha()41 button6 = pygame.image.load("images/button/button6.png").convert_alpha()42 button7 = pygame.image.load("images/button/button7.png").convert_alpha()43 button8 = pygame.image.load("images/button/button8.png").convert_alpha()44 help_txt = pygame.image.load("images/background/help.png").convert_alpha()45 #约定展示按钮的初始形态46 show_button1 = button147 show_button2 = button348 show_button3 = button549 show_button4 = button750 #获取按钮的rect51 button1_rect = button1.get_rect()52 button3_rect = button3.get_rect()53 button5_rect = button5.get_rect()54 button7_rect = button7.get_rect()55 button1_rect.center = (1100,350)56 button3_rect.center = (1100,420)57 button5_rect.center = (1100,490)58 button7_rect.center = (1100,560)59 while True:60 # 用于展示帮助信息61 show_help = True62 #绘制初始界面背景及按钮初始形态63 self.start_screen.blit(start_bg,(0,0))64 self.start_screen.blit(show_button1, button1_rect)65 self.start_screen.blit(show_button2, button3_rect)66 self.start_screen.blit(show_button3, button5_rect)67 self.start_screen.blit(show_button4, button7_rect)68 for event in pygame.event.get():69 if event.type == pygame.KEYDOWN:70 self.__game_over()71 #绘制和检测 开始游戏,选择战机,帮助,退出游戏按钮72 if event.type == pygame.MOUSEMOTION:73 if button1_rect.collidepoint(event.pos):74 show_button1 = button175 else:76 show_button1 = button277 if button3_rect.collidepoint(event.pos):78 show_button2 = button379 else:80 show_button2 = button481 if button5_rect.collidepoint(event.pos):82 show_button3 = button583 else:84 show_button3 = button685 if button7_rect.collidepoint(event.pos):86 show_button4 = button787 else:88 show_button4 = button889 #按钮响应90 if event.type == pygame.MOUSEBUTTONDOWN:91 if event.button == 1 and button1_rect.collidepoint(event.pos):92 button_sound.play()93 time.sleep(1)94 return 095 if event.button == 1 and button3_rect.collidepoint(event.pos):96 button_sound.play()97 self.select_hero()98 if event.button == 1 and button5_rect.collidepoint(event.pos):99 button_sound.play()100 while show_help:101 self.start_screen.blit(help_txt, (200,100))102 pygame.display.update()103 #再次点击鼠标停止显示帮助信息104 for keydown in pygame.event.get():105 if keydown.type == pygame.MOUSEBUTTONDOWN:106 show_help = False107 if event.button == 1 and button7_rect.collidepoint(event.pos):108 button_sound.play()109 time.sleep(1)110 self.__game_over()111 pygame.display.update()112 #选择战机113 def select_hero(self):114 start_bg = pygame.image.load("images/background/select_bg.png").convert_alpha()115 plane_1 = pygame.image.load("images/me/m1_1.png").convert_alpha()116 plane_2 = pygame.image.load("images/me/m2_1.png").convert_alpha()117 plane_3 = pygame.image.load("images/me/m3_1.png").convert_alpha()118 plane_4 = pygame.image.load("images/me/m4_1.png").convert_alpha()119 plane_5 = pygame.image.load("images/me/m5_1.png").convert_alpha()120 plane_6 = pygame.image.load("images/me/m6_1.png").convert_alpha()121 start_bg_rect = start_bg.get_rect()122 plane_1_rect = plane_1.get_rect()123 plane_2_rect = plane_2.get_rect()124 plane_3_rect = plane_3.get_rect()125 plane_4_rect = plane_4.get_rect()126 plane_5_rect = plane_5.get_rect()127 plane_6_rect = plane_6.get_rect()128 start_bg_rect.x,start_bg_rect.y = (200,100)129 plane_1_rect.x,plane_1_rect.y = (250,200)130 plane_2_rect.x, plane_2_rect.y = (420, 200)131 plane_3_rect.x, plane_3_rect.y = (600, 200)132 plane_4_rect.x, plane_4_rect.y = (250, 400)133 plane_5_rect.x, plane_5_rect.y = (420, 400)134 plane_6_rect.x, plane_6_rect.y = (600, 400)135 show_select = True136 while show_select:137 show_rect1 = show_rect2 = show_rect3 = show_rect4 = show_rect5 = show_rect6 = True138 self.start_screen.blit(start_bg, start_bg_rect)139 self.start_screen.blit(plane_1, plane_1_rect)140 self.start_screen.blit(plane_2, plane_2_rect)141 self.start_screen.blit(plane_3, plane_3_rect)142 self.start_screen.blit(plane_4, plane_4_rect)143 self.start_screen.blit(plane_5, plane_5_rect)144 self.start_screen.blit(plane_6, plane_6_rect)145 for event in pygame.event.get():146 # 再次点击鼠标停止显示帮助信息147 if event.type == pygame.MOUSEMOTION:148 if plane_1_rect.collidepoint(event.pos):149 while show_rect1:150 pygame.draw.rect(self.start_screen, RED, plane_1_rect, 2)151 pygame.display.update()152 for mouse_move in pygame.event.get():153 if mouse_move.type == pygame.MOUSEBUTTONDOWN:154 if mouse_move.button == 1:155 button_sound.play()156 hero.Hero.set_hero_id(0)157 show_select = False158 if mouse_move.type == pygame.MOUSEMOTION:159 if not plane_1_rect.collidepoint(mouse_move.pos):160 show_rect1 = False161 if plane_2_rect.collidepoint(event.pos):162 while show_rect2:163 pygame.draw.rect(self.start_screen, RED, plane_2_rect, 2)164 pygame.display.update()165 for mouse_move in pygame.event.get():166 if mouse_move.type == pygame.MOUSEBUTTONDOWN:167 if mouse_move.button == 1:168 button_sound.play()169 hero.Hero.set_hero_id(2)170 show_select = False171 if mouse_move.type == pygame.MOUSEMOTION:172 if not plane_2_rect.collidepoint(mouse_move.pos):173 show_rect2 = False174 if plane_3_rect.collidepoint(event.pos):175 while show_rect3:176 pygame.draw.rect(self.start_screen, RED, plane_3_rect, 2)177 pygame.display.update()178 for mouse_move in pygame.event.get():179 if mouse_move.type == pygame.MOUSEBUTTONDOWN:180 if mouse_move.button == 1:181 button_sound.play()182 hero.Hero.set_hero_id(4)183 show_select = False184 if mouse_move.type == pygame.MOUSEMOTION:185 if not plane_3_rect.collidepoint(mouse_move.pos):186 show_rect3 = False187 if plane_4_rect.collidepoint(event.pos):188 while show_rect4:189 pygame.draw.rect(self.start_screen, RED, plane_4_rect, 2)190 pygame.display.update()191 for mouse_move in pygame.event.get():192 if mouse_move.type == pygame.MOUSEBUTTONDOWN:193 if mouse_move.button == 1:194 button_sound.play()195 hero.Hero.set_hero_id(6)196 show_select = False197 if mouse_move.type == pygame.MOUSEMOTION:198 if not plane_4_rect.collidepoint(mouse_move.pos):199 show_rect4 = False200 if plane_5_rect.collidepoint(event.pos):201 while show_rect5:202 pygame.draw.rect(self.start_screen, RED, plane_5_rect, 2)203 pygame.display.update()204 for mouse_move in pygame.event.get():205 if mouse_move.type == pygame.MOUSEBUTTONDOWN:206 if mouse_move.button == 1:207 button_sound.play()208 hero.Hero.set_hero_id(8)209 show_select = False210 if mouse_move.type == pygame.MOUSEMOTION:211 if not plane_5_rect.collidepoint(mouse_move.pos):212 show_rect5 = False213 if plane_6_rect.collidepoint(event.pos):214 while show_rect6:215 pygame.draw.rect(self.start_screen, RED, plane_6_rect, 2)216 pygame.display.update()217 for mouse_move in pygame.event.get():218 if mouse_move.type == pygame.MOUSEBUTTONDOWN:219 if mouse_move.button == 1:220 button_sound.play()221 hero.Hero.set_hero_id(10)222 show_select = False223 if mouse_move.type == pygame.MOUSEMOTION:224 if not plane_6_rect.collidepoint(mouse_move.pos):225 show_rect6 = False226 pygame.display.update()227 #创建精灵和精灵组228 #创建精灵和精灵组229 def __creat_sprits(self):230 #创建背景精灵和精灵组231 bg1 = bg.Background()232 bg2 = bg.Background(is_alt=True)233 self.back_group = pygame.sprite.Group(bg1, bg2)234 # 创建英雄精灵---通过动画精灵播放235 self.hero1 = hero.Hero()236 hero.Hero.add_hero_id()237 hero2 = hero.Hero()238 self.hero_frames = [self.hero1,hero2]239 self.show_hero = hero.Hero()240 #创建敌机精灵241 self.enemy_group = pygame.sprite.Group()242 self.plane_enemy_group = pygame.sprite.Group()243 enemy.Enemy.add_enemies(self,self.plane_enemy_group,self.enemy_group,150)244 """self.mid_enemy_group = pygame.sprite.Group()245 enemy.Enemy.add_mid_enemies(self.mid_enemy_group, self.enemy_group, 4)246 self.big_enemy_group = pygame.sprite.Group()247 enemy.Enemy.add_big_enemies(self.big_enemy_group, self.enemy_group, 4)248 """249 #创建爆炸精灵组250 self.expl_group = pygame.sprite.Group()251 #游戏开始252 def start_game(self):253 print("游戏开始。。。")254 #1.播放背景音乐255 pygame.mixer.music.play(-1)256 while running :257 #2.设置刷新帧率258 self.clock.tick(FPS)259 #3,事件监听260 self.__event_handler()261 #4.碰撞检测262 self.__check_collide()263 #5.更新绘制精灵组264 if pygame.display.get_active(): #最小化感知,最小化时暂停游戏265 pygame.mixer.music.unpause() #取消背景音乐暂停266 self.__update_sprites()267 else:268 PlaneGame.pause_game(self)269 # 6播放精灵动画270 self.__animate()271 # 7.绘制游戏中相关信息272 self.draw_text()273 # 8.绘制护盾274 self.draw_shield_bar(self.screen, width-200, 30, self.show_hero.shield_num)275 # 更新/显示276 pygame.display.update()277 self.screen.fill(BLACK)278 #暂停游戏279 def pause_game(self):280 pygame.mixer.music.pause()281 #global running282 # while running:283 # pass284 #事件监听函数285 def __event_handler(self):286 for event in pygame.event.get():287 #判断是否退出游戏288 if event.type == pygame.QUIT:289 PlaneGame.__game_over(self)290 elif event.type == pygame.KEYDOWN:291 if event.type == pygame.K_ESCAPE:292 PlaneGame.__game_over(self)293 #处理定时器事件____英雄发射子弹事件294 elif event.type == HERO_FIRE_EVENT:295 self.show_hero.fire()296 #处理按键响应,使用键盘提供的方法获取键盘按键---返回一个元组,用过索引判断是否持续处理键盘时间297 key_pressed = pygame.key.get_pressed()298 if key_pressed[pygame.K_ESCAPE]:299 self.__game_over()300 self.show_hero.speed = [0,0]301 if key_pressed[pygame.K_RIGHT] or key_pressed[pygame.K_d]:302 self.show_hero.speed[0] = 10303 print("向右移动。。。")304 if key_pressed[pygame.K_LEFT] or key_pressed[pygame.K_a]:305 self.show_hero.speed[0] = -10306 print("向左移动。。。")307 if key_pressed[pygame.K_DOWN] or key_pressed[pygame.K_s]:308 self.show_hero.speed[1] = 10309 print("向下移动。。。")310 if key_pressed[pygame.K_UP] or key_pressed[pygame.K_w]:311 self.show_hero.speed[1] = -10312 print("向上移动。。。")313 if self.show_hero.speed[0] and self.show_hero.speed[1]:314 self.show_hero.speed[0] /= 1.414315 self.show_hero.speed[1] /= 1.414316 #碰撞检测317 def __check_collide(self):318 global score,running319 #子弹摧毁敌机320 hits = pygame.sprite.groupcollide(self.enemy_group,self.show_hero.bullet_group,False,True)321 """pygame.sprite.groupcollide(group1,group2,dokill1,dokill2,collided = None) - > Sprite_dict322 group1中的每个Sprite都被添加到返回字典中。每个项目的值是group2中相交的Sprites列表。323 """324 for hit in hits:325 score += 150 - hit.enemy_size326 bullet_power = hits[hit][0].bullet_power327 if hit.energy < 36:328 hit.real_time_energy = 0329 else:330 hit.real_time_energy -= bullet_power331 if hit.real_time_energy <= 0:332 #random.choice(expl_sounds).play()333 enemy2_down_sound.play()334 expl = explosion.Explosion(hit.rect.center, 'lg')335 self.expl_group.add(expl)336 hit.kill()337 """#敌机与护盾相撞338 hits = pygame.sprite.spritecollide(self.show_hero.shield,self.enemy_group, False)339 for hit in hits:340 score += 150 - hit.enemy_size341 bullet_power = hit.energy342 self.show_hero.shield_num -= hit.enemy_size / 2343 if self.show_hero.shield_num <= 0:344 self.show_hero.shield.kill()345 if hit.energy < 36:346 hit.real_time_energy = 0347 else:348 hit.real_time_energy -= bullet_power349 if hit.real_time_energy <= 0:350 # random.choice(expl_sounds).play()351 enemy2_down_sound.play()352 expl = explosion.Explosion(hit.rect.center, 'sm')353 self.expl_group.add(expl)354 hit.kill()355 """356 #敌机撞毁英雄__发挥发生碰撞的敌机列表357 enemies = pygame.sprite.spritecollide(self.show_hero,self.enemy_group,True,pygame.sprite.collide_mask)358 for hit in enemies:359 self.show_hero.shield_num -= hit.enemy_size / 2360 expl2 = explosion.Explosion(hit.rect.center, 'sm')361 self.expl_group.add(expl2)362 if self.show_hero.shield_num <= 0:363 #self.show_hero.shield.kill()364 running = True365 #如果被摧毁的敌机列表有内容,摧毁英雄366 #if len(enemies):367 #enemy2_down_sound.play()368 #exp2 = explosion.Explosion(hit.rect.center, 'lg')369 #self.expl_group.add(exp2)370 #time.sleep(3)371 #self.show_hero.kill()372 #更新和绘制精灵,精灵组373 def __update_sprites(self):374 global last_update375 now = pygame.time.get_ticks()376 #背景精灵377 self.back_group.update()378 self.back_group.draw(self.screen)379 #英雄精灵380 self.show_hero.update()381 self.show_hero.draw(self.screen)382 #子弹精灵383 self.show_hero.bullet_group.update()384 self.show_hero.bullet_group.draw(self.screen)385 #敌机精灵386 self.enemy_group.update()387 self.enemy_group.draw(self.screen)388 #爆炸精灵389 self.expl_group.update()390 self.expl_group.draw(self.screen)391 #护盾精灵392 #self.show_hero.shield_group.update()393 self.show_hero.shield.draw(self.screen)394 #播放精灵动画395 def __animate(self):396 global last_update397 now = pygame.time.get_ticks()398 if now - last_update > 50:399 last_update = now400 self.current_frame = (self.current_frame + 1) % len(self.hero_frames)401 self.show_hero.image = self.hero_frames[self.current_frame].image402 center = self.show_hero.rect.center403 self.show_hero.mask = self.hero1.mask404 self.show_hero.rect = self.show_hero.image.get_rect()405 self.show_hero.rect.center = center406 #绘制游戏时相关文本407 def draw_text(self):408 #绘制分数409 score_font = pygame.font.Font("font/font.ttf", 36)410 score_text = score_font.render("Score : %s" % str(score), True, WHITE)411 self.screen.blit(score_text, (10, 5))412 #绘制血条413 for each in self.enemy_group:414 if each.enemy_size > 36:415 pygame.draw.line(self.screen, BLACK, \416 (each.rect.left, each.rect.top - 5), \417 (each.rect.right, each.rect.top - 5), \418 2)419 # 当生命大于30%显示绿色,否则显示红色420 energy_remain = each.real_time_energy / each.energy421 if energy_remain > 0.3:422 energy_color = GREEN423 else:424 energy_color = RED425 pygame.draw.line(self.screen, energy_color, \426 (each.rect.left, each.rect.top - 5), \427 (each.rect.left + each.rect.width * energy_remain, \428 each.rect.top - 5), 2)429 #绘制护盾条430 def draw_shield_bar(self,surf , x, y, pct):431 score_font = pygame.font.Font("font/font.ttf", 36)432 score_text = score_font.render("Shield :" , True, WHITE)433 self.screen.blit(score_text, (x-120, y-20))434 if pct < 0:435 pct = 0436 BAR_LENGTH = 100437 BAR_HEIGHT = 10438 fill = (pct / 100) * BAR_LENGTH439 outline_rect = pygame.Rect(x, y, BAR_LENGTH, BAR_HEIGHT)440 fill_rect = pygame.Rect(x, y, fill, BAR_HEIGHT)441 pygame.draw.rect(surf, GREEN, fill_rect)442 pygame.draw.rect(surf, WHITE, outline_rect, 2)443 #游戏结束,定义为静态方法444 @staticmethod445 def __game_over():446 print("游戏结束")447 pygame.quit()448 exit()449if __name__ == "__main__":450 try:451 #创建游戏对象452 game = PlaneGame()453 #启动游戏454 game.start_game()455 #异常处理456 except SystemExit:457 pass458 except:459 #输出错误信息460 traceback.print_exc()461 #退出程序462 pygame.quit()463 #等待用户输入,防止窗体一闪而过...

Full Screen

Full Screen

mouse.py

Source:mouse.py Github

copy

Full Screen

1import sys2from typing import TYPE_CHECKING, FrozenSet3from prompt_toolkit.data_structures import Point4from prompt_toolkit.key_binding.key_processor import KeyPress, KeyPressEvent5from prompt_toolkit.keys import Keys6from prompt_toolkit.mouse_events import (7 MouseButton,8 MouseEvent,9 MouseEventType,10 MouseModifier,11)12from ..key_bindings import KeyBindings13if TYPE_CHECKING:14 from prompt_toolkit.key_binding.key_bindings import NotImplementedOrNone15__all__ = [16 "load_mouse_bindings",17]18E = KeyPressEvent19# fmt: off20# flake8: noqa E20121SCROLL_UP = MouseEventType.SCROLL_UP22SCROLL_DOWN = MouseEventType.SCROLL_DOWN23MOUSE_DOWN = MouseEventType.MOUSE_DOWN24MOUSE_MOVE = MouseEventType.MOUSE_MOVE25MOUSE_UP = MouseEventType.MOUSE_UP26NO_MODIFIER : FrozenSet[MouseModifier] = frozenset()27SHIFT : FrozenSet[MouseModifier] = frozenset({MouseModifier.SHIFT})28ALT : FrozenSet[MouseModifier] = frozenset({MouseModifier.ALT})29SHIFT_ALT : FrozenSet[MouseModifier] = frozenset({MouseModifier.SHIFT, MouseModifier.ALT})30CONTROL : FrozenSet[MouseModifier] = frozenset({MouseModifier.CONTROL})31SHIFT_CONTROL : FrozenSet[MouseModifier] = frozenset({MouseModifier.SHIFT, MouseModifier.CONTROL})32ALT_CONTROL : FrozenSet[MouseModifier] = frozenset({MouseModifier.ALT, MouseModifier.CONTROL})33SHIFT_ALT_CONTROL: FrozenSet[MouseModifier] = frozenset({MouseModifier.SHIFT, MouseModifier.ALT, MouseModifier.CONTROL})34UNKNOWN_MODIFIER : FrozenSet[MouseModifier] = frozenset()35LEFT = MouseButton.LEFT36MIDDLE = MouseButton.MIDDLE37RIGHT = MouseButton.RIGHT38NO_BUTTON = MouseButton.NONE39UNKNOWN_BUTTON = MouseButton.UNKNOWN40xterm_sgr_mouse_events = {41 ( 0, 'm') : (LEFT, MOUSE_UP, NO_MODIFIER), # left_up 0+ + + =042 ( 4, 'm') : (LEFT, MOUSE_UP, SHIFT), # left_up Shift 0+4+ + =443 ( 8, 'm') : (LEFT, MOUSE_UP, ALT), # left_up Alt 0+ +8+ =844 (12, 'm') : (LEFT, MOUSE_UP, SHIFT_ALT), # left_up Shift Alt 0+4+8+ =1245 (16, 'm') : (LEFT, MOUSE_UP, CONTROL), # left_up Control 0+ + +16=1646 (20, 'm') : (LEFT, MOUSE_UP, SHIFT_CONTROL), # left_up Shift Control 0+4+ +16=2047 (24, 'm') : (LEFT, MOUSE_UP, ALT_CONTROL), # left_up Alt Control 0+ +8+16=2448 (28, 'm') : (LEFT, MOUSE_UP, SHIFT_ALT_CONTROL), # left_up Shift Alt Control 0+4+8+16=2849 ( 1, 'm') : (MIDDLE, MOUSE_UP, NO_MODIFIER), # middle_up 1+ + + =150 ( 5, 'm') : (MIDDLE, MOUSE_UP, SHIFT), # middle_up Shift 1+4+ + =551 ( 9, 'm') : (MIDDLE, MOUSE_UP, ALT), # middle_up Alt 1+ +8+ =952 (13, 'm') : (MIDDLE, MOUSE_UP, SHIFT_ALT), # middle_up Shift Alt 1+4+8+ =1353 (17, 'm') : (MIDDLE, MOUSE_UP, CONTROL), # middle_up Control 1+ + +16=1754 (21, 'm') : (MIDDLE, MOUSE_UP, SHIFT_CONTROL), # middle_up Shift Control 1+4+ +16=2155 (25, 'm') : (MIDDLE, MOUSE_UP, ALT_CONTROL), # middle_up Alt Control 1+ +8+16=2556 (29, 'm') : (MIDDLE, MOUSE_UP, SHIFT_ALT_CONTROL), # middle_up Shift Alt Control 1+4+8+16=2957 ( 2, 'm') : (RIGHT, MOUSE_UP, NO_MODIFIER), # right_up 2+ + + =258 ( 6, 'm') : (RIGHT, MOUSE_UP, SHIFT), # right_up Shift 2+4+ + =659 (10, 'm') : (RIGHT, MOUSE_UP, ALT), # right_up Alt 2+ +8+ =1060 (14, 'm') : (RIGHT, MOUSE_UP, SHIFT_ALT), # right_up Shift Alt 2+4+8+ =1461 (18, 'm') : (RIGHT, MOUSE_UP, CONTROL), # right_up Control 2+ + +16=1862 (22, 'm') : (RIGHT, MOUSE_UP, SHIFT_CONTROL), # right_up Shift Control 2+4+ +16=2263 (26, 'm') : (RIGHT, MOUSE_UP, ALT_CONTROL), # right_up Alt Control 2+ +8+16=2664 (30, 'm') : (RIGHT, MOUSE_UP, SHIFT_ALT_CONTROL), # right_up Shift Alt Control 2+4+8+16=3065 ( 0, 'M') : (LEFT, MOUSE_DOWN, NO_MODIFIER), # left_down 0+ + + =066 ( 4, 'M') : (LEFT, MOUSE_DOWN, SHIFT), # left_down Shift 0+4+ + =467 ( 8, 'M') : (LEFT, MOUSE_DOWN, ALT), # left_down Alt 0+ +8+ =868 (12, 'M') : (LEFT, MOUSE_DOWN, SHIFT_ALT), # left_down Shift Alt 0+4+8+ =1269 (16, 'M') : (LEFT, MOUSE_DOWN, CONTROL), # left_down Control 0+ + +16=1670 (20, 'M') : (LEFT, MOUSE_DOWN, SHIFT_CONTROL), # left_down Shift Control 0+4+ +16=2071 (24, 'M') : (LEFT, MOUSE_DOWN, ALT_CONTROL), # left_down Alt Control 0+ +8+16=2472 (28, 'M') : (LEFT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # left_down Shift Alt Control 0+4+8+16=2873 ( 1, 'M') : (MIDDLE, MOUSE_DOWN, NO_MODIFIER), # middle_down 1+ + + =174 ( 5, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT), # middle_down Shift 1+4+ + =575 ( 9, 'M') : (MIDDLE, MOUSE_DOWN, ALT), # middle_down Alt 1+ +8+ =976 (13, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_ALT), # middle_down Shift Alt 1+4+8+ =1377 (17, 'M') : (MIDDLE, MOUSE_DOWN, CONTROL), # middle_down Control 1+ + +16=1778 (21, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_CONTROL), # middle_down Shift Control 1+4+ +16=2179 (25, 'M') : (MIDDLE, MOUSE_DOWN, ALT_CONTROL), # middle_down Alt Control 1+ +8+16=2580 (29, 'M') : (MIDDLE, MOUSE_DOWN, SHIFT_ALT_CONTROL), # middle_down Shift Alt Control 1+4+8+16=2981 ( 2, 'M') : (RIGHT, MOUSE_DOWN, NO_MODIFIER), # right_down 2+ + + =282 ( 6, 'M') : (RIGHT, MOUSE_DOWN, SHIFT), # right_down Shift 2+4+ + =683 (10, 'M') : (RIGHT, MOUSE_DOWN, ALT), # right_down Alt 2+ +8+ =1084 (14, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_ALT), # right_down Shift Alt 2+4+8+ =1485 (18, 'M') : (RIGHT, MOUSE_DOWN, CONTROL), # right_down Control 2+ + +16=1886 (22, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_CONTROL), # right_down Shift Control 2+4+ +16=2287 (26, 'M') : (RIGHT, MOUSE_DOWN, ALT_CONTROL), # right_down Alt Control 2+ +8+16=2688 (30, 'M') : (RIGHT, MOUSE_DOWN, SHIFT_ALT_CONTROL), # right_down Shift Alt Control 2+4+8+16=3089 (32, 'M') : (LEFT, MOUSE_MOVE, NO_MODIFIER), # left_drag 32+ + + =3290 (36, 'M') : (LEFT, MOUSE_MOVE, SHIFT), # left_drag Shift 32+4+ + =3691 (40, 'M') : (LEFT, MOUSE_MOVE, ALT), # left_drag Alt 32+ +8+ =4092 (44, 'M') : (LEFT, MOUSE_MOVE, SHIFT_ALT), # left_drag Shift Alt 32+4+8+ =4493 (48, 'M') : (LEFT, MOUSE_MOVE, CONTROL), # left_drag Control 32+ + +16=4894 (52, 'M') : (LEFT, MOUSE_MOVE, SHIFT_CONTROL), # left_drag Shift Control 32+4+ +16=5295 (56, 'M') : (LEFT, MOUSE_MOVE, ALT_CONTROL), # left_drag Alt Control 32+ +8+16=5696 (60, 'M') : (LEFT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # left_drag Shift Alt Control 32+4+8+16=6097 (33, 'M') : (MIDDLE, MOUSE_MOVE, NO_MODIFIER), # middle_drag 33+ + + =3398 (37, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT), # middle_drag Shift 33+4+ + =3799 (41, 'M') : (MIDDLE, MOUSE_MOVE, ALT), # middle_drag Alt 33+ +8+ =41100 (45, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_ALT), # middle_drag Shift Alt 33+4+8+ =45101 (49, 'M') : (MIDDLE, MOUSE_MOVE, CONTROL), # middle_drag Control 33+ + +16=49102 (53, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_CONTROL), # middle_drag Shift Control 33+4+ +16=53103 (57, 'M') : (MIDDLE, MOUSE_MOVE, ALT_CONTROL), # middle_drag Alt Control 33+ +8+16=57104 (61, 'M') : (MIDDLE, MOUSE_MOVE, SHIFT_ALT_CONTROL), # middle_drag Shift Alt Control 33+4+8+16=61105 (34, 'M') : (RIGHT, MOUSE_MOVE, NO_MODIFIER), # right_drag 34+ + + =34106 (38, 'M') : (RIGHT, MOUSE_MOVE, SHIFT), # right_drag Shift 34+4+ + =38107 (42, 'M') : (RIGHT, MOUSE_MOVE, ALT), # right_drag Alt 34+ +8+ =42108 (46, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_ALT), # right_drag Shift Alt 34+4+8+ =46109 (50, 'M') : (RIGHT, MOUSE_MOVE, CONTROL), # right_drag Control 34+ + +16=50110 (54, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_CONTROL), # right_drag Shift Control 34+4+ +16=54111 (58, 'M') : (RIGHT, MOUSE_MOVE, ALT_CONTROL), # right_drag Alt Control 34+ +8+16=58112 (62, 'M') : (RIGHT, MOUSE_MOVE, SHIFT_ALT_CONTROL), # right_drag Shift Alt Control 34+4+8+16=62113 (35, 'M') : (NO_BUTTON, MOUSE_MOVE, NO_MODIFIER), # none_drag 35+ + + =35114 (39, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT), # none_drag Shift 35+4+ + =39115 (43, 'M') : (NO_BUTTON, MOUSE_MOVE, ALT), # none_drag Alt 35+ +8+ =43116 (47, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT), # none_drag Shift Alt 35+4+8+ =47117 (51, 'M') : (NO_BUTTON, MOUSE_MOVE, CONTROL), # none_drag Control 35+ + +16=51118 (55, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_CONTROL), # none_drag Shift Control 35+4+ +16=55119 (59, 'M') : (NO_BUTTON, MOUSE_MOVE, ALT_CONTROL), # none_drag Alt Control 35+ +8+16=59120 (63, 'M') : (NO_BUTTON, MOUSE_MOVE, SHIFT_ALT_CONTROL), # none_drag Shift Alt Control 35+4+8+16=63121 (64, 'M') : (NO_BUTTON, SCROLL_UP, NO_MODIFIER), # scroll_up 64+ + + =64122 (68, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT), # scroll_up Shift 64+4+ + =68123 (72, 'M') : (NO_BUTTON, SCROLL_UP, ALT), # scroll_up Alt 64+ +8+ =72124 (76, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_ALT), # scroll_up Shift Alt 64+4+8+ =76125 (80, 'M') : (NO_BUTTON, SCROLL_UP, CONTROL), # scroll_up Control 64+ + +16=80126 (84, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_CONTROL), # scroll_up Shift Control 64+4+ +16=84127 (88, 'M') : (NO_BUTTON, SCROLL_UP, ALT_CONTROL), # scroll_up Alt Control 64+ +8+16=88128 (92, 'M') : (NO_BUTTON, SCROLL_UP, SHIFT_ALT_CONTROL), # scroll_up Shift Alt Control 64+4+8+16=92129 (65, 'M') : (NO_BUTTON, SCROLL_DOWN, NO_MODIFIER), # scroll_down 64+ + + =65130 (69, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT), # scroll_down Shift 64+4+ + =69131 (73, 'M') : (NO_BUTTON, SCROLL_DOWN, ALT), # scroll_down Alt 64+ +8+ =73132 (77, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT), # scroll_down Shift Alt 64+4+8+ =77133 (81, 'M') : (NO_BUTTON, SCROLL_DOWN, CONTROL), # scroll_down Control 64+ + +16=81134 (85, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_CONTROL), # scroll_down Shift Control 64+4+ +16=85135 (89, 'M') : (NO_BUTTON, SCROLL_DOWN, ALT_CONTROL), # scroll_down Alt Control 64+ +8+16=89136 (93, 'M') : (NO_BUTTON, SCROLL_DOWN, SHIFT_ALT_CONTROL), # scroll_down Shift Alt Control 64+4+8+16=93137}138typical_mouse_events = {139 32: (LEFT , MOUSE_DOWN , UNKNOWN_MODIFIER),140 33: (MIDDLE , MOUSE_DOWN , UNKNOWN_MODIFIER),141 34: (RIGHT , MOUSE_DOWN , UNKNOWN_MODIFIER),142 35: (UNKNOWN_BUTTON , MOUSE_UP , UNKNOWN_MODIFIER),143 64: (LEFT , MOUSE_MOVE , UNKNOWN_MODIFIER),144 65: (MIDDLE , MOUSE_MOVE , UNKNOWN_MODIFIER),145 66: (RIGHT , MOUSE_MOVE , UNKNOWN_MODIFIER),146 67: (NO_BUTTON , MOUSE_MOVE , UNKNOWN_MODIFIER),147 96: (NO_BUTTON , SCROLL_UP , UNKNOWN_MODIFIER),148 97: (NO_BUTTON , SCROLL_DOWN, UNKNOWN_MODIFIER),149}150urxvt_mouse_events={151 32: (UNKNOWN_BUTTON, MOUSE_DOWN , UNKNOWN_MODIFIER),152 35: (UNKNOWN_BUTTON, MOUSE_UP , UNKNOWN_MODIFIER),153 96: (NO_BUTTON , SCROLL_UP , UNKNOWN_MODIFIER),154 97: (NO_BUTTON , SCROLL_DOWN, UNKNOWN_MODIFIER),155}156# fmt:on157def load_mouse_bindings() -> KeyBindings:158 """159 Key bindings, required for mouse support.160 (Mouse events enter through the key binding system.)161 """162 key_bindings = KeyBindings()163 @key_bindings.add(Keys.Vt100MouseEvent)164 def _(event: E) -> "NotImplementedOrNone":165 """166 Handling of incoming mouse event.167 """168 # TypicaL: "eSC[MaB*"169 # Urxvt: "Esc[96;14;13M"170 # Xterm SGR: "Esc[<64;85;12M"171 # Parse incoming packet.172 if event.data[2] == "M":173 # Typical.174 mouse_event, x, y = map(ord, event.data[3:])175 # TODO: Is it possible to add modifiers here?176 mouse_button, mouse_event_type, mouse_modifiers = typical_mouse_events[177 mouse_event178 ]179 # Handle situations where `PosixStdinReader` used surrogateescapes.180 if x >= 0xDC00:181 x -= 0xDC00182 if y >= 0xDC00:183 y -= 0xDC00184 x -= 32185 y -= 32186 else:187 # Urxvt and Xterm SGR.188 # When the '<' is not present, we are not using the Xterm SGR mode,189 # but Urxvt instead.190 data = event.data[2:]191 if data[:1] == "<":192 sgr = True193 data = data[1:]194 else:195 sgr = False196 # Extract coordinates.197 mouse_event, x, y = map(int, data[:-1].split(";"))198 m = data[-1]199 # Parse event type.200 if sgr:201 try:202 (203 mouse_button,204 mouse_event_type,205 mouse_modifiers,206 ) = xterm_sgr_mouse_events[mouse_event, m]207 except KeyError:208 return NotImplemented209 else:210 # Some other terminals, like urxvt, Hyper terminal, ...211 (212 mouse_button,213 mouse_event_type,214 mouse_modifiers,215 ) = urxvt_mouse_events.get(216 mouse_event, (UNKNOWN_BUTTON, MOUSE_MOVE, UNKNOWN_MODIFIER)217 )218 x -= 1219 y -= 1220 # Only handle mouse events when we know the window height.221 if event.app.renderer.height_is_known and mouse_event_type is not None:222 # Take region above the layout into account. The reported223 # coordinates are absolute to the visible part of the terminal.224 from prompt_toolkit.renderer import HeightIsUnknownError225 try:226 y -= event.app.renderer.rows_above_layout227 except HeightIsUnknownError:228 return NotImplemented229 # Call the mouse handler from the renderer.230 # Note: This can return `NotImplemented` if no mouse handler was231 # found for this position, or if no repainting needs to232 # happen. this way, we avoid excessive repaints during mouse233 # movements.234 handler = event.app.renderer.mouse_handlers.mouse_handlers[y][x]235 return handler(236 MouseEvent(237 position=Point(x=x, y=y),238 event_type=mouse_event_type,239 button=mouse_button,240 modifiers=mouse_modifiers,241 )242 )243 return NotImplemented244 @key_bindings.add(Keys.ScrollUp)245 def _scroll_up(event: E) -> None:246 """247 Scroll up event without cursor position.248 """249 # We don't receive a cursor position, so we don't know which window to250 # scroll. Just send an 'up' key press instead.251 event.key_processor.feed(KeyPress(Keys.Up), first=True)252 @key_bindings.add(Keys.ScrollDown)253 def _scroll_down(event: E) -> None:254 """255 Scroll down event without cursor position.256 """257 event.key_processor.feed(KeyPress(Keys.Down), first=True)258 @key_bindings.add(Keys.WindowsMouseEvent)259 def _mouse(event: E) -> "NotImplementedOrNone":260 """261 Handling of mouse events for Windows.262 """263 # This key binding should only exist for Windows.264 if sys.platform == "win32":265 # Parse data.266 pieces = event.data.split(";")267 button = MouseButton(pieces[0])268 event_type = MouseEventType(pieces[1])269 x = int(pieces[2])270 y = int(pieces[3])271 # Make coordinates absolute to the visible part of the terminal.272 output = event.app.renderer.output273 from prompt_toolkit.output.win32 import Win32Output274 from prompt_toolkit.output.windows10 import Windows10_Output275 if isinstance(output, (Win32Output, Windows10_Output)):276 screen_buffer_info = output.get_win32_screen_buffer_info()277 rows_above_cursor = (278 screen_buffer_info.dwCursorPosition.Y279 - event.app.renderer._cursor_pos.y280 )281 y -= rows_above_cursor282 # Call the mouse event handler.283 # (Can return `NotImplemented`.)284 handler = event.app.renderer.mouse_handlers.mouse_handlers[y][x]285 return handler(286 MouseEvent(287 position=Point(x=x, y=y),288 event_type=event_type,289 button=button,290 modifiers=UNKNOWN_MODIFIER,291 )292 )293 # No mouse handler found. Return `NotImplemented` so that we don't294 # invalidate the UI.295 return NotImplemented...

Full Screen

Full Screen

mouse_bindings.py

Source:mouse_bindings.py Github

copy

Full Screen

1from ..events import Mods, MouseEventType, MouseButton2MOUSE_UP = MouseEventType.MOUSE_UP3MOUSE_DOWN = MouseEventType.MOUSE_DOWN4MOUSE_MOVE = MouseEventType.MOUSE_MOVE5SCROLL_UP = MouseEventType.SCROLL_UP6SCROLL_DOWN = MouseEventType.SCROLL_DOWN7LEFT = MouseButton.LEFT8MIDDLE = MouseButton.MIDDLE9RIGHT = MouseButton.RIGHT10NO_BUTTON = MouseButton.NO_BUTTON11UNKNOWN_BUTTON = MouseButton.UNKNOWN_BUTTON12NO_MODS = Mods.NO_MODS13ALT = Mods(True , False, False)14CONTROL = Mods(False, True , False)15SHIFT = Mods(False, False, True )16ALT_CONTROL = Mods(True , True , False)17ALT_SHIFT = Mods(True , False, True )18CONTROL_SHIFT = Mods(False, True , True )19ALT_CONTROL_SHIFT = Mods(True , True , True )20TERM_SGR = {21 ( 0, "m"): (MOUSE_UP, LEFT, NO_MODS),22 ( 4, "m"): (MOUSE_UP, LEFT, SHIFT),23 ( 8, "m"): (MOUSE_UP, LEFT, ALT),24 (12, "m"): (MOUSE_UP, LEFT, ALT_SHIFT),25 (16, "m"): (MOUSE_UP, LEFT, CONTROL),26 (20, "m"): (MOUSE_UP, LEFT, CONTROL_SHIFT),27 (24, "m"): (MOUSE_UP, LEFT, ALT_CONTROL),28 (28, "m"): (MOUSE_UP, LEFT, ALT_CONTROL_SHIFT),29 ( 1, "m"): (MOUSE_UP, MIDDLE, NO_MODS),30 ( 5, "m"): (MOUSE_UP, MIDDLE, SHIFT),31 ( 9, "m"): (MOUSE_UP, MIDDLE, ALT),32 (13, "m"): (MOUSE_UP, MIDDLE, ALT_SHIFT),33 (17, "m"): (MOUSE_UP, MIDDLE, CONTROL),34 (21, "m"): (MOUSE_UP, MIDDLE, CONTROL_SHIFT),35 (25, "m"): (MOUSE_UP, MIDDLE, ALT_CONTROL),36 (29, "m"): (MOUSE_UP, MIDDLE, ALT_CONTROL_SHIFT),37 ( 2, "m"): (MOUSE_UP, RIGHT, NO_MODS),38 ( 6, "m"): (MOUSE_UP, RIGHT, SHIFT),39 (10, "m"): (MOUSE_UP, RIGHT, ALT),40 (14, "m"): (MOUSE_UP, RIGHT, ALT_SHIFT),41 (18, "m"): (MOUSE_UP, RIGHT, CONTROL),42 (22, "m"): (MOUSE_UP, RIGHT, CONTROL_SHIFT),43 (26, "m"): (MOUSE_UP, RIGHT, ALT_CONTROL),44 (30, "m"): (MOUSE_UP, RIGHT, ALT_CONTROL_SHIFT),45 ( 0, "M"): (MOUSE_DOWN, LEFT, NO_MODS),46 ( 4, "M"): (MOUSE_DOWN, LEFT, SHIFT),47 ( 8, "M"): (MOUSE_DOWN, LEFT, ALT),48 (12, "M"): (MOUSE_DOWN, LEFT, ALT_SHIFT),49 (16, "M"): (MOUSE_DOWN, LEFT, CONTROL),50 (20, "M"): (MOUSE_DOWN, LEFT, CONTROL_SHIFT),51 (24, "M"): (MOUSE_DOWN, LEFT, ALT_CONTROL),52 (28, "M"): (MOUSE_DOWN, LEFT, ALT_CONTROL_SHIFT),53 ( 1, "M"): (MOUSE_DOWN, MIDDLE, NO_MODS),54 ( 5, "M"): (MOUSE_DOWN, MIDDLE, SHIFT),55 ( 9, "M"): (MOUSE_DOWN, MIDDLE, ALT),56 (13, "M"): (MOUSE_DOWN, MIDDLE, ALT_SHIFT),57 (17, "M"): (MOUSE_DOWN, MIDDLE, CONTROL),58 (21, "M"): (MOUSE_DOWN, MIDDLE, CONTROL_SHIFT),59 (25, "M"): (MOUSE_DOWN, MIDDLE, ALT_CONTROL),60 (29, "M"): (MOUSE_DOWN, MIDDLE, ALT_CONTROL_SHIFT),61 ( 2, "M"): (MOUSE_DOWN, RIGHT, NO_MODS),62 ( 6, "M"): (MOUSE_DOWN, RIGHT, SHIFT),63 (10, "M"): (MOUSE_DOWN, RIGHT, ALT),64 (14, "M"): (MOUSE_DOWN, RIGHT, ALT_SHIFT),65 (18, "M"): (MOUSE_DOWN, RIGHT, CONTROL),66 (22, "M"): (MOUSE_DOWN, RIGHT, CONTROL_SHIFT),67 (26, "M"): (MOUSE_DOWN, RIGHT, ALT_CONTROL),68 (30, "M"): (MOUSE_DOWN, RIGHT, ALT_CONTROL_SHIFT),69 (32, "M"): (MOUSE_MOVE, LEFT, NO_MODS),70 (36, "M"): (MOUSE_MOVE, LEFT, SHIFT),71 (40, "M"): (MOUSE_MOVE, LEFT, ALT),72 (44, "M"): (MOUSE_MOVE, LEFT, ALT_SHIFT),73 (48, "M"): (MOUSE_MOVE, LEFT, CONTROL),74 (52, "M"): (MOUSE_MOVE, LEFT, CONTROL_SHIFT),75 (56, "M"): (MOUSE_MOVE, LEFT, ALT_CONTROL),76 (60, "M"): (MOUSE_MOVE, LEFT, ALT_CONTROL_SHIFT),77 (33, "M"): (MOUSE_MOVE, MIDDLE, NO_MODS),78 (37, "M"): (MOUSE_MOVE, MIDDLE, SHIFT),79 (41, "M"): (MOUSE_MOVE, MIDDLE, ALT),80 (45, "M"): (MOUSE_MOVE, MIDDLE, ALT_SHIFT),81 (49, "M"): (MOUSE_MOVE, MIDDLE, CONTROL),82 (53, "M"): (MOUSE_MOVE, MIDDLE, CONTROL_SHIFT),83 (57, "M"): (MOUSE_MOVE, MIDDLE, ALT_CONTROL),84 (61, "M"): (MOUSE_MOVE, MIDDLE, ALT_CONTROL_SHIFT),85 (34, "M"): (MOUSE_MOVE, RIGHT, NO_MODS),86 (38, "M"): (MOUSE_MOVE, RIGHT, SHIFT),87 (42, "M"): (MOUSE_MOVE, RIGHT, ALT),88 (46, "M"): (MOUSE_MOVE, RIGHT, ALT_SHIFT),89 (50, "M"): (MOUSE_MOVE, RIGHT, CONTROL),90 (54, "M"): (MOUSE_MOVE, RIGHT, CONTROL_SHIFT),91 (58, "M"): (MOUSE_MOVE, RIGHT, ALT_CONTROL),92 (62, "M"): (MOUSE_MOVE, RIGHT, ALT_CONTROL_SHIFT),93 (35, "M"): (MOUSE_MOVE, NO_BUTTON, NO_MODS),94 (39, "M"): (MOUSE_MOVE, NO_BUTTON, SHIFT),95 (43, "M"): (MOUSE_MOVE, NO_BUTTON, ALT),96 (47, "M"): (MOUSE_MOVE, NO_BUTTON, ALT_SHIFT),97 (51, "M"): (MOUSE_MOVE, NO_BUTTON, CONTROL),98 (55, "M"): (MOUSE_MOVE, NO_BUTTON, CONTROL_SHIFT),99 (59, "M"): (MOUSE_MOVE, NO_BUTTON, ALT_CONTROL),100 (63, "M"): (MOUSE_MOVE, NO_BUTTON, ALT_CONTROL_SHIFT),101 # This is duplicated from the block above with lowercase "m" for WSL.102 (35, "m"): (MOUSE_MOVE, NO_BUTTON, NO_MODS),103 (39, "m"): (MOUSE_MOVE, NO_BUTTON, SHIFT),104 (43, "m"): (MOUSE_MOVE, NO_BUTTON, ALT),105 (47, "m"): (MOUSE_MOVE, NO_BUTTON, ALT_SHIFT),106 (51, "m"): (MOUSE_MOVE, NO_BUTTON, CONTROL),107 (55, "m"): (MOUSE_MOVE, NO_BUTTON, CONTROL_SHIFT),108 (59, "m"): (MOUSE_MOVE, NO_BUTTON, ALT_CONTROL),109 (63, "m"): (MOUSE_MOVE, NO_BUTTON, ALT_CONTROL_SHIFT),110 (64, "M"): (SCROLL_UP, NO_BUTTON, NO_MODS),111 (68, "M"): (SCROLL_UP, NO_BUTTON, SHIFT),112 (72, "M"): (SCROLL_UP, NO_BUTTON, ALT),113 (76, "M"): (SCROLL_UP, NO_BUTTON, ALT_SHIFT),114 (80, "M"): (SCROLL_UP, NO_BUTTON, CONTROL),115 (84, "M"): (SCROLL_UP, NO_BUTTON, CONTROL_SHIFT),116 (88, "M"): (SCROLL_UP, NO_BUTTON, ALT_CONTROL),117 (92, "M"): (SCROLL_UP, NO_BUTTON, ALT_CONTROL_SHIFT),118 (65, "M"): (SCROLL_DOWN, NO_BUTTON, NO_MODS),119 (69, "M"): (SCROLL_DOWN, NO_BUTTON, SHIFT),120 (73, "M"): (SCROLL_DOWN, NO_BUTTON, ALT),121 (77, "M"): (SCROLL_DOWN, NO_BUTTON, ALT_SHIFT),122 (81, "M"): (SCROLL_DOWN, NO_BUTTON, CONTROL),123 (85, "M"): (SCROLL_DOWN, NO_BUTTON, CONTROL_SHIFT),124 (89, "M"): (SCROLL_DOWN, NO_BUTTON, ALT_CONTROL),125 (93, "M"): (SCROLL_DOWN, NO_BUTTON, ALT_CONTROL_SHIFT),126}127TYPICAL = {128 32: (MOUSE_DOWN, LEFT, NO_MODS),129 33: (MOUSE_DOWN, MIDDLE, NO_MODS),130 34: (MOUSE_DOWN, RIGHT, NO_MODS),131 35: (MOUSE_UP, UNKNOWN_BUTTON, NO_MODS),132 64: (MOUSE_MOVE, LEFT, NO_MODS),133 65: (MOUSE_MOVE, MIDDLE, NO_MODS),134 66: (MOUSE_MOVE, RIGHT, NO_MODS),135 67: (MOUSE_MOVE, NO_BUTTON, NO_MODS),136 96: (SCROLL_UP, NO_BUTTON, NO_MODS),137 97: (SCROLL_DOWN, NO_BUTTON, NO_MODS),138}139URXVT = {140 32: (MOUSE_DOWN, UNKNOWN_BUTTON, NO_MODS),141 35: (MOUSE_UP, UNKNOWN_BUTTON, NO_MODS),142 96: (SCROLL_UP, NO_BUTTON, NO_MODS),143 97: (SCROLL_DOWN, NO_BUTTON, NO_MODS),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful